/*     */ package main;
/*     */ 
/*     */ import DFT.TraceDFT;
/*     */ import java.awt.Color;
/*     */ import java.awt.Cursor;
/*     */ import java.awt.Font;
/*     */ import java.awt.FontMetrics;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Graphics2D;
/*     */ import java.awt.RenderingHints;
/*     */ import java.awt.event.ActionEvent;
/*     */ import java.awt.event.ActionListener;
/*     */ import java.awt.event.MouseEvent;
/*     */ import java.awt.event.MouseListener;
/*     */ import java.awt.event.MouseMotionListener;
/*     */ import java.io.File;
/*     */ import java.util.ArrayList;
/*     */ import javax.swing.JCheckBox;
/*     */ import javax.swing.JMenu;
/*     */ import javax.swing.JMenuItem;
/*     */ import javax.swing.JOptionPane;
/*     */ import javax.swing.JPanel;
/*     */ import javax.swing.JPopupMenu;
/*     */ import javax.swing.Timer;
/*     */ import signals.Signals;
/*     */ import tools.Arrow;
/*     */ import tools.VertLines;
/*     */ 
/*     */ 
/*     */ 
/*     */ public class ChronoPanel
/*     */   extends JPanel
/*     */   implements MouseListener, MouseMotionListener
/*     */ {
/*     */   private static final long serialVersionUID = 1L;
/*     */   public File openedFile;
/*  37 */   public String fileName = "New";
/*  38 */   public boolean saveFileOk = false;
/*  39 */   public boolean modifToSave = false;
/*     */   
/*  41 */   public ArrayList<Signals> signals = new ArrayList();
/*     */   public int selected;
/*  43 */   public boolean elmt_to_edit = false;
/*     */   public int selected_bus;
/*     */   public int selected_signal;
/*     */   public int bus_offset;
/*  47 */   public int[][] timeLapse = new int[5][4];
/*  48 */   public int nbrTimeLapse = 0;
/*  49 */   public boolean setTimeLapse = false;
/*  50 */   public boolean getTimeLapseWidth = false;
/*     */   
/*  52 */   public boolean displayBackLines = false;
/*  53 */   public boolean antialiasing = true;
/*     */   
/*  55 */   public ArrayList<Arrow> arrows = new ArrayList();
/*  56 */   public boolean placeAssertionFrom = false;
/*  57 */   public boolean placeAssertionTo = false;
/*  58 */   public int assertionIndex = -1;
/*     */   
/*  60 */   private Cursor normalCursor = new Cursor(0);
/*  61 */   private Cursor handCursor = new Cursor(12);
/*  62 */   private Cursor moveCursor = new Cursor(13);
/*     */   
/*  64 */   private JPopupMenu busMenu = new JPopupMenu();
/*  65 */   private JMenuItem bus_name = new JMenuItem("Set Name");
/*  66 */   private JMenuItem bus_fill = new JMenuItem("Fill");
/*  67 */   private JMenuItem bus_clean = new JMenuItem("Clean");
/*     */   
/*  69 */   private JPopupMenu signalMenu = new JPopupMenu();
/*  70 */   private JMenu signal_style = new JMenu("Style");
/*  71 */   private JCheckBox signal_style_bold = new JCheckBox("Bold");
/*  72 */   private JMenu signal_style_color = new JMenu("Color");
/*  73 */   private JMenuItem signal_style_color_red = new JMenuItem("Red");
/*  74 */   private JMenuItem signal_style_color_blue = new JMenuItem("Blue");
/*  75 */   private JMenuItem signal_style_color_green = new JMenuItem("Green");
/*  76 */   private JMenuItem signal_style_color_orange = new JMenuItem("Orange");
/*  77 */   private JMenuItem signal_style_color_black = new JMenuItem("Black");
/*  78 */   private JMenuItem signal_properties = new JMenuItem("Properties");
/*  79 */   private JMenuItem signal_set_values = new JMenuItem("Set wave values");
/*  80 */   private JMenuItem signal_traceDFT = new JMenuItem("Trace DFT");
/*  81 */   private JMenuItem signal_delete = new JMenuItem("Delete");
/*     */   
/*     */ 
/*  84 */   private boolean doubleClic = false;
/*  85 */   private boolean moveSelection = false;
/*     */   
/*  87 */   public static Font myFont = new Font("Arial", 0, 12);
/*  88 */   public static Font myBoldFont = new Font("Arial", 1, 12);
/*     */   public static FontMetrics metrics;
/*     */   
/*     */   public ChronoPanel() {
/*  92 */     addMouseListener(this);
/*  93 */     addMouseMotionListener(this);
/*     */     
/*  95 */     this.busMenu.add(this.bus_name);
/*  96 */     this.busMenu.add(this.bus_fill);
/*  97 */     this.busMenu.add(this.bus_clean);
/*     */     
/*  99 */     this.signal_style.add(this.signal_style_bold);
/*     */     
/* 101 */     this.signal_style_color.add(this.signal_style_color_black);
/* 102 */     this.signal_style_color.addSeparator();
/* 103 */     this.signal_style_color.add(this.signal_style_color_blue);
/* 104 */     this.signal_style_color.add(this.signal_style_color_green);
/* 105 */     this.signal_style_color.add(this.signal_style_color_orange);
/* 106 */     this.signal_style_color.add(this.signal_style_color_red);
/* 107 */     this.signal_style.add(this.signal_style_color);
/*     */     
/* 109 */     this.signalMenu.add(this.signal_style);
/* 110 */     this.signalMenu.add(this.signal_properties);
/* 111 */     this.signalMenu.add(this.signal_set_values);
/* 112 */     this.signalMenu.addSeparator();
/* 113 */     this.signalMenu.add(this.signal_traceDFT);
/* 114 */     this.signalMenu.addSeparator();
/* 115 */     this.signalMenu.add(this.signal_delete);
/*     */     
/* 117 */     popUpMenuInit();
/*     */   }
/*     */   
/*     */   public void reinit() {
/* 121 */     this.signals.clear();
/* 122 */     Signals.resetIdBank();
/* 123 */     this.elmt_to_edit = false;
/* 124 */     this.timeLapse = new int[5][4];
/* 125 */     this.nbrTimeLapse = 0;
/* 126 */     this.setTimeLapse = false;
/* 127 */     this.getTimeLapseWidth = false;
/*     */   }
/*     */   
/*     */   public void paintComponent(Graphics g) {
/* 131 */     ArrayList<VertLines> verts = new ArrayList();
/* 132 */     metrics = g.getFontMetrics(myFont);
/* 133 */     updateLeftSpace();
/*     */     
/*     */ 
/* 136 */     if (this.antialiasing) {
/* 137 */       Graphics2D g2 = (Graphics2D)g;
/* 138 */       g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
/*     */     }
/*     */     
/* 141 */     g.setColor(Color.white);
/* 142 */     g.fillRect(0, 0, getWidth(), getHeight());
/*     */     
/* 144 */     if (this.displayBackLines) {
/* 145 */       g.setColor(new Color(230, 230, 230));
/* 146 */       for (int i = 1; i < this.signals.size(); i += 2) {
/* 147 */         g.fillRect(0, i * (Signals.heightUnit + Signals.Yspace) + Signals.Yspace / 2, ChronoWindow.WIDTH, Signals.heightUnit + Signals.Yspace);
/*     */       }
/*     */     }
/*     */     
/* 151 */     g.setColor(new Color(100, 100, 220));
/* 152 */     if (this.setTimeLapse) {
/* 153 */       g.fillRect(this.timeLapse[this.nbrTimeLapse][0], 0, this.timeLapse[this.nbrTimeLapse][3] - this.timeLapse[this.nbrTimeLapse][0], ChronoWindow.HEIGHT);
/*     */     }
/*     */     
/* 156 */     g.setColor(Color.black);
/* 157 */     for (int i = 0; i < this.signals.size(); i++) {
/* 158 */       ((Signals)this.signals.get(i)).draw(g, this, i, ChronoWindow.WIDTH);
/* 159 */       if (((Signals)this.signals.get(i)).displayRisingEdges) { verts.add(new VertLines((Signals)this.signals.get(i), ((Signals)this.signals.get(i)).widthUnit + Signals.leftSpace, ChronoWindow.WIDTH - 15, i, this.signals.size()));
/*     */       }
/*     */     }
/*     */     
/* 163 */     for (int i = 0; i < verts.size(); i++) {
/* 164 */       ((VertLines)verts.get(i)).draw(g, this);
/*     */     }
/*     */     
/*     */ 
/* 168 */     for (int i = 0; i < this.arrows.size(); i++) {
/* 169 */       ((Arrow)this.arrows.get(i)).draw(g);
/*     */     }
/*     */     
/*     */ 
/* 173 */     Main.window.checkModifToSave();
/*     */   }
/*     */   
/*     */   public void add(Signals s) {
/* 177 */     changeClockDomain(s);
/* 178 */     this.signals.add(s);
/* 179 */     updateLeftSpace();
/* 180 */     this.modifToSave = true;
/* 181 */     repaint();
/*     */   }
/*     */   
/*     */   public void changeSelClockDomain(int id) {
/* 185 */     if ((this.elmt_to_edit) && (((Signals)this.signals.get(this.selected)).dependsOnClk)) {
/* 186 */       ((Signals)this.signals.get(this.selected)).clockDomainId = id;
/* 187 */       changeClockDomain((Signals)this.signals.get(this.selected));
/*     */     }
/*     */   }
/*     */   
/*     */   public void changeClockDomain(Signals s) {
/* 192 */     int period = 20;
/* 193 */     if ((s.id != s.clockDomainId) && (s.dependsOnClk)) {
/* 194 */       for (int i = 0; i < this.signals.size(); i++) {
/* 195 */         if ((((Signals)this.signals.get(i)).clock) && (((Signals)this.signals.get(i)).id == s.clockDomainId)) period = ((Signals)this.signals.get(i)).widthUnit;
/*     */       }
/* 197 */       s.widthUnit = ((int)(period * s.ratio));
/*     */     }
/*     */   }
/*     */   
/*     */   public void updateClockDomain() {
/* 202 */     for (int i = 0; i < this.signals.size(); i++) {
/* 203 */       changeClockDomain((Signals)this.signals.get(i));
/*     */     }
/*     */   }
/*     */   
/*     */   public void changeClockDomainName(int prevId, int newId) {
/* 208 */     for (int i = 0; i < this.signals.size(); i++) {
/* 209 */       if (((Signals)this.signals.get(i)).clockDomainId == prevId) {
/* 210 */         ((Signals)this.signals.get(i)).clockDomainId = newId;
/* 211 */         changeClockDomain((Signals)this.signals.get(i));
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */   public void updateLeftSpace() {
/* 217 */     int lengthMax = 0;
/* 218 */     for (int i = 0; i < this.signals.size(); i++) {
/* 219 */       if (metrics.stringWidth(((Signals)this.signals.get(i)).name) > lengthMax) lengthMax = metrics.stringWidth(((Signals)this.signals.get(i)).name);
/*     */     }
/* 221 */     Signals.leftSpace = Math.max(lengthMax + 13, 30);
/*     */   }
/*     */   
/*     */   public void moveTo(int offset)
/*     */   {
/* 226 */     if ((this.elmt_to_edit) && (this.selected + offset >= 0) && (this.selected + offset < this.signals.size())) {
/* 227 */       Signals temp = (Signals)this.signals.get(this.selected);
/* 228 */       this.signals.remove(this.selected);
/* 229 */       this.signals.add(this.selected + offset, temp);
/*     */     }
/*     */   }
/*     */   
/*     */   public void removeSelected() {
/* 234 */     String warning = "";
/* 235 */     String toErase = "";
/* 236 */     if (this.assertionIndex > -1) { toErase = "arrow assertion";
/* 237 */     } else if (this.elmt_to_edit) toErase = ((Signals)this.signals.get(this.selected)).name + " signal";
/* 238 */     int n = JOptionPane.showConfirmDialog(null, "Erase " + toErase + "?", "Confirmation", 0, 3);
/*     */     
/* 240 */     if (n == 0)
/*     */     {
/* 242 */       if (this.assertionIndex > -1) {
/* 243 */         this.arrows.remove(this.assertionIndex);
/*     */ 
/*     */       }
/* 246 */       else if (this.elmt_to_edit) {
/* 247 */         for (int i = 0; i < this.signals.size(); i++) {
/* 248 */           if ((i != this.selected) && (((Signals)this.signals.get(i)).clockDomainId == ((Signals)this.signals.get(this.selected)).id)) { warning = warning + "- " + ((Signals)this.signals.get(i)).name + "\n";
/*     */           }
/*     */         }
/* 251 */         if ((warning == "") || (!((Signals)this.signals.get(this.selected)).clock)) {
/* 252 */           this.signals.remove(this.selected);
/* 253 */           this.selected = 0;
/* 254 */           this.elmt_to_edit = false;
/*     */         }
/*     */         else {
/* 257 */           JOptionPane.showMessageDialog(null, "These signals/bus are depending on " + ((Signals)this.signals.get(this.selected)).name + ":\n" + warning, "Warning", 2);
/*     */         }
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */   public void changePeriod(int p)
/*     */   {
/* 265 */     if ((this.elmt_to_edit) && (((Signals)this.signals.get(this.selected)).clockDomainId == ((Signals)this.signals.get(this.selected)).id)) {
/* 266 */       int clkId = ((Signals)this.signals.get(this.selected)).id;
/* 267 */       for (int i = 0; i < this.signals.size(); i++) {
/* 268 */         if (((Signals)this.signals.get(i)).clockDomainId == clkId) ((Signals)this.signals.get(i)).widthUnit = ((int)(p * ((Signals)this.signals.get(i)).ratio));
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */   public boolean checkIfSignalIndependent(int id) {
/* 274 */     boolean res = true;
/* 275 */     for (int i = 0; i < this.signals.size(); i++) {
/* 276 */       if ((((Signals)this.signals.get(i)).id != id) && (((Signals)this.signals.get(i)).clock) && (((Signals)this.signals.get(i)).clockDomainId == id) && (((Signals)this.signals.get(i)).dependsOnClk)) res = false;
/*     */     }
/* 278 */     return res;
/*     */   }
/*     */   
/*     */   public void addTimeLapse() {
/* 282 */     this.timeLapse[this.nbrTimeLapse][0] = 0;
/* 283 */     this.timeLapse[this.nbrTimeLapse][1] = 0;
/* 284 */     this.timeLapse[this.nbrTimeLapse][2] = 0;
/* 285 */     this.timeLapse[this.nbrTimeLapse][3] = 0;
/* 286 */     this.getTimeLapseWidth = false;
/* 287 */     this.setTimeLapse = true;
/*     */   }
/*     */   
/*     */   public void removeTimeLapse() {
/* 291 */     this.timeLapse = new int[5][4];
/* 292 */     this.nbrTimeLapse = 0;
/*     */   }
/*     */   
/*     */   public void newAssertion() {
/* 296 */     this.arrows.add(new Arrow(this));
/* 297 */     this.placeAssertionFrom = true;
/*     */   }
/*     */   
/*     */   public int getPosFromId(int id) {
/* 301 */     for (int i = 0; i < this.signals.size(); i++) {
/* 302 */       if (((Signals)this.signals.get(i)).id == id) return i;
/*     */     }
/* 304 */     return 0;
/*     */   }
/*     */   
/*     */   public void removeAssertions() {
/* 308 */     this.arrows.clear();
/*     */   }
/*     */   
/*     */   public void releaseSelection() {
/* 312 */     ((Signals)this.signals.get(this.selected)).selected = false;
/* 313 */     if (this.assertionIndex >= 0) ((Arrow)this.arrows.get(this.assertionIndex)).selected = false;
/* 314 */     repaint();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public void mouseClicked(MouseEvent e)
/*     */   {
/* 322 */     if (e.getX() < Signals.leftSpace) {
/* 323 */       if (!this.doubleClic) {
/* 324 */         this.doubleClic = true;
/* 325 */         ActionListener taskPerformer = new ActionListener() {
/*     */           public void actionPerformed(ActionEvent evt) {
/* 327 */             ChronoPanel.this.doubleClic = false;
/*     */           }
/* 329 */         };
/* 330 */         Timer t = new Timer(500, taskPerformer);
/* 331 */         t.setRepeats(false);
/* 332 */         t.start();
/*     */       }
/*     */       else
/*     */       {
/* 336 */         this.doubleClic = false;
/*     */         
/* 338 */         editSignalProperties();
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */   public void mouseEntered(MouseEvent e) {}
/*     */   
/*     */ 
/*     */   public void mouseExited(MouseEvent e)
/*     */   {
/* 349 */     if ((this.selected >= 0) && (this.selected < this.signals.size())) ((Signals)this.signals.get(this.selected)).selected = false;
/* 350 */     this.moveSelection = false;
/* 351 */     repaint();
/*     */   }
/*     */   
/*     */   public void mousePressed(MouseEvent e)
/*     */   {
/* 356 */     int nbr = (int)((e.getY() - Signals.Yspace / 2.0F) / (Signals.heightUnit + Signals.Yspace));
/* 357 */     if ((nbr >= 0) && (nbr < this.signals.size()) && (!this.setTimeLapse)) {
/* 358 */       if ((!this.placeAssertionFrom) && (!this.placeAssertionTo)) {
/* 359 */         if (e.getX() >= Signals.leftSpace) {
/* 360 */           this.modifToSave = true;
/* 361 */           if (e.getButton() == 1) {
/* 362 */             ((Signals)this.signals.get(nbr)).setWave(e.getX(), ((Signals)this.signals.get(nbr)).bus);
/*     */           }
/* 364 */           if (e.getButton() == 3) {
/* 365 */             if (!((Signals)this.signals.get(nbr)).bus) ((Signals)this.signals.get(nbr)).setWave(e.getX(), true);
/* 366 */             if (((Signals)this.signals.get(nbr)).bus) {
/* 367 */               this.selected_bus = nbr;
/* 368 */               this.bus_offset = e.getX();
/* 369 */               this.busMenu.show(this, e.getX(), e.getY());
/*     */             }
/*     */           }
/*     */         }
/* 373 */         else if (e.getX() < Signals.leftSpace)
/*     */         {
/* 375 */           if (e.getButton() == 1) { this.moveSelection = true;
/*     */           }
/* 377 */           if (e.getButton() == 3) {
/* 378 */             this.modifToSave = true;
/* 379 */             this.selected_signal = nbr;
/* 380 */             this.signal_style_bold.setSelected(((Signals)this.signals.get(nbr)).bold);
/* 381 */             this.signal_set_values.setEnabled(true);
/* 382 */             this.signal_traceDFT.setEnabled(true);
/* 383 */             if ((((Signals)this.signals.get(nbr)).clock) || (((Signals)this.signals.get(nbr)).bus)) this.signal_set_values.setEnabled(false);
/* 384 */             if (((Signals)this.signals.get(nbr)).bus) this.signal_traceDFT.setEnabled(false);
/* 385 */             this.signalMenu.show(this, e.getX(), e.getY());
/*     */           }
/*     */           
/*     */         }
/*     */         
/*     */       }
/* 391 */       else if (this.placeAssertionFrom) {
/* 392 */         this.placeAssertionFrom = false;
/* 393 */         this.placeAssertionTo = true;
/*     */       }
/* 395 */       else if (this.placeAssertionTo) {
/* 396 */         this.placeAssertionTo = false;
/* 397 */         ((Arrow)this.arrows.get(this.arrows.size() - 1)).done();
/*     */       }
/*     */       
/* 400 */       repaint();
/*     */     }
/*     */     
/* 403 */     if (this.setTimeLapse) {
/* 404 */       this.getTimeLapseWidth = true;
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */   public void mouseReleased(MouseEvent e)
/*     */   {
/* 411 */     if (this.moveSelection) {
/* 412 */       this.moveSelection = false;
/* 413 */       setCursor(this.normalCursor);
/* 414 */       int nbr = (int)((e.getY() - Signals.Yspace) / (Signals.heightUnit + Signals.Yspace));
/* 415 */       if ((nbr >= 0) && (nbr < this.signals.size())) {
/* 416 */         moveTo(nbr - this.selected);
/* 417 */         repaint();
/*     */       }
/*     */     }
/*     */     
/*     */ 
/* 422 */     if (this.getTimeLapseWidth) {
/* 423 */       this.getTimeLapseWidth = false;
/* 424 */       this.setTimeLapse = false;
/*     */       
/*     */ 
/* 427 */       this.timeLapse[this.nbrTimeLapse][1] = (this.timeLapse[this.nbrTimeLapse][0] + (this.timeLapse[this.nbrTimeLapse][3] - this.timeLapse[this.nbrTimeLapse][0]) / 4);
/*     */       
/* 429 */       this.timeLapse[this.nbrTimeLapse][2] = (this.timeLapse[this.nbrTimeLapse][0] + 3 * (this.timeLapse[this.nbrTimeLapse][3] - this.timeLapse[this.nbrTimeLapse][0]) / 4);
/*     */       
/*     */ 
/* 432 */       this.timeLapse[this.nbrTimeLapse][0] -= Signals.leftSpace;
/* 433 */       this.timeLapse[this.nbrTimeLapse][1] -= Signals.leftSpace;
/* 434 */       this.timeLapse[this.nbrTimeLapse][2] -= Signals.leftSpace;
/* 435 */       this.timeLapse[this.nbrTimeLapse][3] -= Signals.leftSpace;
/*     */       
/* 437 */       this.nbrTimeLapse += 1;
/* 438 */       sortTimeLapseArray();
/*     */       
/* 440 */       repaint();
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */   public void mouseDragged(MouseEvent e)
/*     */   {
/* 447 */     if (this.moveSelection) {
/* 448 */       this.modifToSave = true;
/* 449 */       setCursor(this.moveCursor);
/* 450 */       int nbr = (int)((e.getY() - Signals.Yspace) / (Signals.heightUnit + Signals.Yspace));
/* 451 */       if ((nbr >= 0) && (nbr < this.signals.size())) {
/* 452 */         moveTo(nbr - this.selected);
/* 453 */         this.selected = nbr;
/* 454 */         repaint();
/*     */       }
/*     */     }
/*     */     
/* 458 */     if (this.getTimeLapseWidth) {
/* 459 */       this.modifToSave = true;
/* 460 */       this.timeLapse[this.nbrTimeLapse][3] = e.getX();
/* 461 */       repaint();
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */   public void mouseMoved(MouseEvent e)
/*     */   {
/* 468 */     setCursor(this.normalCursor);
/*     */     
/* 470 */     int nbr = (int)((e.getY() - Signals.Yspace / 2.0F) / (Signals.heightUnit + Signals.Yspace));
/* 471 */     if ((nbr >= 0) && (nbr < this.signals.size()) && (!this.setTimeLapse)) {
/* 472 */       ((Signals)this.signals.get(this.selected)).selected = false;
/* 473 */       ((Signals)this.signals.get(nbr)).selected = true;
/* 474 */       this.elmt_to_edit = true;
/* 475 */       this.selected = nbr;
/*     */       
/* 477 */       if (e.getX() < Signals.leftSpace) {
/* 478 */         setCursor(this.handCursor);
/*     */       }
/*     */       
/* 481 */       if (this.placeAssertionFrom) ((Arrow)this.arrows.get(this.arrows.size() - 1)).setStart((Signals)this.signals.get(nbr), e.getX());
/* 482 */       if (this.placeAssertionTo) { ((Arrow)this.arrows.get(this.arrows.size() - 1)).setEnd((Signals)this.signals.get(nbr), e.getX());
/*     */       }
/* 484 */       repaint();
/*     */     }
/* 486 */     else if ((this.selected >= 0) && (this.selected < this.signals.size())) {
/* 487 */       ((Signals)this.signals.get(this.selected)).selected = false;
/* 488 */       repaint();
/*     */     }
/*     */     
/* 491 */     if ((this.setTimeLapse) && (!this.getTimeLapseWidth)) {
/* 492 */       this.timeLapse[this.nbrTimeLapse][0] = e.getX();
/* 493 */       this.timeLapse[this.nbrTimeLapse][3] = (e.getX() + 1);
/*     */     }
/*     */     
/*     */ 
/* 497 */     int dMin = 8;
/* 498 */     this.assertionIndex = -1;
/* 499 */     for (int i = 0; i < this.arrows.size(); i++) {
/* 500 */       ((Arrow)this.arrows.get(i)).selected = false;
/* 501 */       if (((Arrow)this.arrows.get(i)).getDistance(e.getX(), e.getY()) < dMin) {
/* 502 */         dMin = ((Arrow)this.arrows.get(i)).getDistance(e.getX(), e.getY());
/* 503 */         this.assertionIndex = i;
/*     */       }
/*     */     }
/* 506 */     if (this.assertionIndex != -1) ((Arrow)this.arrows.get(this.assertionIndex)).selected = true;
/*     */   }
/*     */   
/*     */   public void popUpMenuInit()
/*     */   {
/* 511 */     this.bus_name.addActionListener(new ActionListener() {
/*     */       public void actionPerformed(ActionEvent arg0) {
/* 513 */         DialogBox db = new DialogBox(null, "Set bus data name");
/* 514 */         db.showDialog();
/* 515 */         if (db.name != null) ((Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected_bus)).setBusName(ChronoPanel.this.bus_offset, db.name);
/* 516 */         ChronoPanel.this.repaint();
/*     */       }
/*     */       
/* 519 */     });
/* 520 */     this.bus_fill.addActionListener(new ActionListener() {
/*     */       public void actionPerformed(ActionEvent arg0) {
/* 522 */         ((Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected_bus)).setBusFill(ChronoPanel.this.bus_offset, false);
/* 523 */         ChronoPanel.this.repaint();
/*     */       }
/*     */       
/* 526 */     });
/* 527 */     this.bus_clean.addActionListener(new ActionListener() {
/*     */       public void actionPerformed(ActionEvent arg0) {
/* 529 */         ((Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected_bus)).setBusName(ChronoPanel.this.bus_offset, null);
/* 530 */         ((Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected_bus)).setBusFill(ChronoPanel.this.bus_offset, true);
/* 531 */         ChronoPanel.this.repaint();
/*     */       }
/*     */       
/* 534 */     });
/* 535 */     this.signal_style_bold.addActionListener(new ActionListener() {
/*     */       public void actionPerformed(ActionEvent event) {
/* 537 */         ((Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected_signal)).bold = ChronoPanel.this.signal_style_bold.isSelected();
/* 538 */         ChronoPanel.this.signalMenu.setVisible(false);
/* 539 */         ChronoPanel.this.repaint();
/*     */       }
/*     */       
/* 542 */     });
/* 543 */     this.signal_style_color_red.addActionListener(new ActionListener() {
/*     */       public void actionPerformed(ActionEvent event) {
/* 545 */         ((Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected_signal)).color = new Color(180, 0, 0);
/* 546 */         ChronoPanel.this.repaint();
/*     */       }
/*     */       
/* 549 */     });
/* 550 */     this.signal_style_color_blue.addActionListener(new ActionListener() {
/*     */       public void actionPerformed(ActionEvent event) {
/* 552 */         ((Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected_signal)).color = new Color(0, 0, 180);
/* 553 */         ChronoPanel.this.repaint();
/*     */       }
/*     */       
/* 556 */     });
/* 557 */     this.signal_style_color_orange.addActionListener(new ActionListener() {
/*     */       public void actionPerformed(ActionEvent event) {
/* 559 */         ((Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected_signal)).color = new Color(255, 102, 50);
/* 560 */         ChronoPanel.this.repaint();
/*     */       }
/*     */       
/* 563 */     });
/* 564 */     this.signal_style_color_green.addActionListener(new ActionListener() {
/*     */       public void actionPerformed(ActionEvent event) {
/* 566 */         ((Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected_signal)).color = new Color(0, 180, 0);
/* 567 */         ChronoPanel.this.repaint();
/*     */       }
/*     */       
/* 570 */     });
/* 571 */     this.signal_style_color_black.addActionListener(new ActionListener() {
/*     */       public void actionPerformed(ActionEvent event) {
/* 573 */         ((Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected_signal)).color = Color.black;
/* 574 */         ChronoPanel.this.repaint();
/*     */       }
/*     */       
/* 577 */     });
/* 578 */     this.signal_properties.addActionListener(new ActionListener() {
/*     */       public void actionPerformed(ActionEvent arg0) {
/* 580 */         ChronoPanel.this.editSignalProperties();
/* 581 */         ChronoPanel.this.repaint();
/*     */       }
/*     */       
/* 584 */     });
/* 585 */     this.signal_traceDFT.addActionListener(new ActionListener() {
/*     */       public void actionPerformed(ActionEvent arg0) {
/* 587 */         new TraceDFT((Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected_signal), ChronoWindow.WIDTH);
/* 588 */         ChronoPanel.this.repaint();
/*     */       }
/*     */       
/* 591 */     });
/* 592 */     this.signal_set_values.addActionListener(new ActionListener() {
/*     */       public void actionPerformed(ActionEvent arg0) {
/* 594 */         DialogBox db = new DialogBox(null, "Set Wave Values", (Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected), true);
/* 595 */         db.showDialog();
/* 596 */         if (db.valid) for (int i = 0; i < ((Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected)).wave.length; i++) ((Signals)ChronoPanel.this.signals.get(ChronoPanel.this.selected)).wave[i] = db.waveSet[i];
/* 597 */         ChronoPanel.this.repaint();
/*     */       }
/*     */       
/* 600 */     });
/* 601 */     this.signal_delete.addActionListener(new ActionListener() {
/*     */       public void actionPerformed(ActionEvent arg0) {
/* 603 */         ChronoPanel.this.removeSelected();
/* 604 */         ChronoPanel.this.repaint();
/*     */       }
/*     */     });
/*     */   }
/*     */   
/*     */ 
/*     */   public void editSignalProperties()
/*     */   {
/* 612 */     if (this.elmt_to_edit) {
/* 613 */       DialogBox db = new DialogBox(null, "Properties", (Signals)this.signals.get(this.selected));
/* 614 */       db.showDialog();
/* 615 */       if (db.valid) {
/* 616 */         this.modifToSave = true;
/* 617 */         if (db.name != null) ((Signals)this.signals.get(this.selected)).name = db.name;
/* 618 */         repaint();
/* 619 */         if (db.freq != -1) changePeriod(db.freq);
/* 620 */         repaint();
/* 621 */         if ((!((Signals)this.signals.get(this.selected)).clock) && (db.clockDomain != -1)) changeSelClockDomain(db.clockDomain);
/* 622 */         repaint();
/* 623 */         if (((Signals)this.signals.get(this.selected)).clock)
/*     */         {
/* 625 */           ((Signals)this.signals.get(this.selected)).displayRisingEdges = db.displayRisingEdges;
/* 626 */           ((Signals)this.signals.get(this.selected)).generate(db.beginOnRisingEdge);
/*     */           
/* 628 */           if ((db.clockDomain != -1) && (db.clkDependency)) {
/* 629 */             if (checkIfSignalIndependent(((Signals)this.signals.get(this.selected)).id)) {
/* 630 */               ((Signals)this.signals.get(this.selected)).ratio = db.ratio;
/* 631 */               ((Signals)this.signals.get(this.selected)).dependsOnClk = true;
/* 632 */               changeSelClockDomain(db.clockDomain);
/*     */             }
/*     */             else
/*     */             {
/* 636 */               JOptionPane.showMessageDialog(null, ((Signals)this.signals.get(this.selected)).name + " can not depend on " + ((Signals)this.signals.get(db.clockDomain)).name + " as other clocks depend on " + ((Signals)this.signals.get(this.selected)).name, "Warning", 2);
/*     */             }
/*     */           }
/*     */           else
/*     */           {
/* 641 */             ((Signals)this.signals.get(this.selected)).ratio = 1.0F;
/* 642 */             changeSelClockDomain(((Signals)this.signals.get(this.selected)).id);
/* 643 */             ((Signals)this.signals.get(this.selected)).dependsOnClk = false;
/* 644 */             if (db.freq != -1) { changePeriod(db.freq);
/*     */             }
/*     */           }
/* 647 */           updateClockDomain();
/*     */         }
/* 649 */         ((Signals)this.signals.get(this.selected)).clkToQdelay = db.clkToQdelay;
/* 650 */         repaint();
/* 651 */         if (!((Signals)this.signals.get(this.selected)).bus) {
/* 652 */           if (!db.setUp) ((Signals)this.signals.get(this.selected)).setUpTime = 0;
/* 653 */           if (db.setUp) ((Signals)this.signals.get(this.selected)).setUpTime = 8;
/* 654 */           repaint();
/*     */         }
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */   public void sortTimeLapseArray()
/*     */   {
/* 663 */     int[][] temp = new int[9][4];
/* 664 */     int[] rank = new int[this.nbrTimeLapse];
/*     */     
/*     */ 
/* 667 */     for (int i = 0; i < this.nbrTimeLapse; i++) {
/* 668 */       temp[i][0] = this.timeLapse[i][0];
/* 669 */       temp[i][1] = this.timeLapse[i][1];
/* 670 */       temp[i][2] = this.timeLapse[i][2];
/* 671 */       temp[i][3] = this.timeLapse[i][3];
/*     */     }
/*     */     
/* 674 */     for (int i = 0; i < this.nbrTimeLapse; i++) {
/* 675 */       rank[i] = i;
/* 676 */       for (int j = 0; j < i; j++) {
/* 677 */         if (this.timeLapse[i][0] < this.timeLapse[j][0]) {
/* 678 */           rank[i] -= 1;
/* 679 */           rank[j] += 1;
/*     */         }
/*     */       }
/*     */     }
/*     */     
/* 684 */     for (int i = 0; i < this.nbrTimeLapse; i++) {
/* 685 */       this.timeLapse[rank[i]][0] = temp[i][0];
/* 686 */       this.timeLapse[rank[i]][1] = temp[i][1];
/* 687 */       this.timeLapse[rank[i]][2] = temp[i][2];
/* 688 */       this.timeLapse[rank[i]][3] = temp[i][3];
/*     */     }
/*     */   }
/*     */ }


/* Location:              F:\JAVA\WORKSPACE\chronoEditor_v2.3.jar!\main\ChronoPanel.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */