/*
 * Decompiled with CFR 0_132.
 */
package main;

import DFT.TraceDFT;
import java.awt.Color;
import java.awt.Component;
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.JFrame;
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 main.ChronoWindow;
import main.DialogBox;
import main.Main;
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;
    public String fileName = "New";
    public boolean saveFileOk = false;
    public boolean modifToSave = false;
    public ArrayList<Signals> signals = new ArrayList();
    public int selected;
    public boolean elmt_to_edit = false;
    public int selected_bus;
    public int selected_signal;
    public int bus_offset;
    public int[][] timeLapse = new int[5][4];
    public int nbrTimeLapse = 0;
    public boolean setTimeLapse = false;
    public boolean getTimeLapseWidth = false;
    public boolean displayBackLines = false;
    public boolean antialiasing = true;
    public ArrayList<Arrow> arrows = new ArrayList();
    public boolean placeAssertionFrom = false;
    public boolean placeAssertionTo = false;
    public int assertionIndex = -1;
    private Cursor normalCursor = new Cursor(0);
    private Cursor handCursor = new Cursor(12);
    private Cursor moveCursor = new Cursor(13);
    private JPopupMenu busMenu = new JPopupMenu();
    private JMenuItem bus_name = new JMenuItem("Set Name");
    private JMenuItem bus_fill = new JMenuItem("Fill");
    private JMenuItem bus_clean = new JMenuItem("Clean");
    private JPopupMenu signalMenu = new JPopupMenu();
    private JMenu signal_style = new JMenu("Style");
    private JCheckBox signal_style_bold = new JCheckBox("Bold");
    private JMenu signal_style_color = new JMenu("Color");
    private JMenuItem signal_style_color_red = new JMenuItem("Red");
    private JMenuItem signal_style_color_blue = new JMenuItem("Blue");
    private JMenuItem signal_style_color_green = new JMenuItem("Green");
    private JMenuItem signal_style_color_orange = new JMenuItem("Orange");
    private JMenuItem signal_style_color_black = new JMenuItem("Black");
    private JMenuItem signal_properties = new JMenuItem("Properties");
    private JMenuItem signal_set_values = new JMenuItem("Set wave values");
    private JMenuItem signal_traceDFT = new JMenuItem("Trace DFT");
    private JMenuItem signal_delete = new JMenuItem("Delete");
    private boolean doubleClic = false;
    private boolean moveSelection = false;
    public static Font myFont = new Font("Arial", 0, 12);
    public static Font myBoldFont = new Font("Arial", 1, 12);
    public static FontMetrics metrics;

    public ChronoPanel() {
        this.addMouseListener(this);
        this.addMouseMotionListener(this);
        this.busMenu.add(this.bus_name);
        this.busMenu.add(this.bus_fill);
        this.busMenu.add(this.bus_clean);
        this.signal_style.add(this.signal_style_bold);
        this.signal_style_color.add(this.signal_style_color_black);
        this.signal_style_color.addSeparator();
        this.signal_style_color.add(this.signal_style_color_blue);
        this.signal_style_color.add(this.signal_style_color_green);
        this.signal_style_color.add(this.signal_style_color_orange);
        this.signal_style_color.add(this.signal_style_color_red);
        this.signal_style.add(this.signal_style_color);
        this.signalMenu.add(this.signal_style);
        this.signalMenu.add(this.signal_properties);
        this.signalMenu.add(this.signal_set_values);
        this.signalMenu.addSeparator();
        this.signalMenu.add(this.signal_traceDFT);
        this.signalMenu.addSeparator();
        this.signalMenu.add(this.signal_delete);
        this.popUpMenuInit();
    }

    public void reinit() {
        this.signals.clear();
        Signals.resetIdBank();
        this.elmt_to_edit = false;
        this.timeLapse = new int[5][4];
        this.nbrTimeLapse = 0;
        this.setTimeLapse = false;
        this.getTimeLapseWidth = false;
    }

    @Override
    public void paintComponent(Graphics g) {
        ArrayList<VertLines> verts = new ArrayList<VertLines>();
        metrics = g.getFontMetrics(myFont);
        this.updateLeftSpace();
        if (this.antialiasing) {
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        }
        g.setColor(Color.white);
        g.fillRect(0, 0, this.getWidth(), this.getHeight());
        if (this.displayBackLines) {
            g.setColor(new Color(230, 230, 230));
            int i = 1;
            while (i < this.signals.size()) {
                g.fillRect(0, i * (Signals.heightUnit + Signals.Yspace) + Signals.Yspace / 2, ChronoWindow.WIDTH, Signals.heightUnit + Signals.Yspace);
                i += 2;
            }
        }
        g.setColor(new Color(100, 100, 220));
        if (this.setTimeLapse) {
            g.fillRect(this.timeLapse[this.nbrTimeLapse][0], 0, this.timeLapse[this.nbrTimeLapse][3] - this.timeLapse[this.nbrTimeLapse][0], ChronoWindow.HEIGHT);
        }
        g.setColor(Color.black);
        int i = 0;
        while (i < this.signals.size()) {
            this.signals.get(i).draw(g, this, i, ChronoWindow.WIDTH);
            if (this.signals.get((int)i).displayRisingEdges) {
                verts.add(new VertLines(this.signals.get(i), this.signals.get((int)i).widthUnit + Signals.leftSpace, ChronoWindow.WIDTH - 15, i, this.signals.size()));
            }
            ++i;
        }
        i = 0;
        while (i < verts.size()) {
            ((VertLines)verts.get(i)).draw(g, this);
            ++i;
        }
        i = 0;
        while (i < this.arrows.size()) {
            this.arrows.get(i).draw(g);
            ++i;
        }
        Main.window.checkModifToSave();
    }

    public void add(Signals s) {
        this.changeClockDomain(s);
        this.signals.add(s);
        this.updateLeftSpace();
        this.modifToSave = true;
        this.repaint();
    }

    public void changeSelClockDomain(int id) {
        if (this.elmt_to_edit && this.signals.get((int)this.selected).dependsOnClk) {
            this.signals.get((int)this.selected).clockDomainId = id;
            this.changeClockDomain(this.signals.get(this.selected));
        }
    }

    public void changeClockDomain(Signals s) {
        int period = 20;
        if (s.id != s.clockDomainId && s.dependsOnClk) {
            int i = 0;
            while (i < this.signals.size()) {
                if (this.signals.get((int)i).clock && this.signals.get((int)i).id == s.clockDomainId) {
                    period = this.signals.get((int)i).widthUnit;
                }
                ++i;
            }
            s.widthUnit = (int)((float)period * s.ratio);
        }
    }

    public void updateClockDomain() {
        int i = 0;
        while (i < this.signals.size()) {
            this.changeClockDomain(this.signals.get(i));
            ++i;
        }
    }

    public void changeClockDomainName(int prevId, int newId) {
        int i = 0;
        while (i < this.signals.size()) {
            if (this.signals.get((int)i).clockDomainId == prevId) {
                this.signals.get((int)i).clockDomainId = newId;
                this.changeClockDomain(this.signals.get(i));
            }
            ++i;
        }
    }

    public void updateLeftSpace() {
        int lengthMax = 0;
        int i = 0;
        while (i < this.signals.size()) {
            if (metrics.stringWidth(this.signals.get((int)i).name) > lengthMax) {
                lengthMax = metrics.stringWidth(this.signals.get((int)i).name);
            }
            ++i;
        }
        Signals.leftSpace = Math.max(lengthMax + 13, 30);
    }

    public void moveTo(int offset) {
        if (this.elmt_to_edit && this.selected + offset >= 0 && this.selected + offset < this.signals.size()) {
            Signals temp = this.signals.get(this.selected);
            this.signals.remove(this.selected);
            this.signals.add(this.selected + offset, temp);
        }
    }

    public void removeSelected() {
        String warning = "";
        String toErase = "";
        if (this.assertionIndex > -1) {
            toErase = "arrow assertion";
        } else if (this.elmt_to_edit) {
            toErase = String.valueOf(this.signals.get((int)this.selected).name) + " signal";
        }
        int n = JOptionPane.showConfirmDialog(null, "Erase " + toErase + "?", "Confirmation", 0, 3);
        if (n == 0) {
            if (this.assertionIndex > -1) {
                this.arrows.remove(this.assertionIndex);
            } else if (this.elmt_to_edit) {
                int i = 0;
                while (i < this.signals.size()) {
                    if (i != this.selected && this.signals.get((int)i).clockDomainId == this.signals.get((int)this.selected).id) {
                        warning = String.valueOf(warning) + "- " + this.signals.get((int)i).name + "\n";
                    }
                    ++i;
                }
                if (warning == "" || !this.signals.get((int)this.selected).clock) {
                    this.signals.remove(this.selected);
                    this.selected = 0;
                    this.elmt_to_edit = false;
                } else {
                    JOptionPane.showMessageDialog(null, "These signals/bus are depending on " + this.signals.get((int)this.selected).name + ":\n" + warning, "Warning", 2);
                }
            }
        }
    }

    public void changePeriod(int p) {
        if (this.elmt_to_edit && this.signals.get((int)this.selected).clockDomainId == this.signals.get((int)this.selected).id) {
            int clkId = this.signals.get((int)this.selected).id;
            int i = 0;
            while (i < this.signals.size()) {
                if (this.signals.get((int)i).clockDomainId == clkId) {
                    this.signals.get((int)i).widthUnit = (int)((float)p * this.signals.get((int)i).ratio);
                }
                ++i;
            }
        }
    }

    public boolean checkIfSignalIndependent(int id) {
        boolean res = true;
        int i = 0;
        while (i < this.signals.size()) {
            if (this.signals.get((int)i).id != id && this.signals.get((int)i).clock && this.signals.get((int)i).clockDomainId == id && this.signals.get((int)i).dependsOnClk) {
                res = false;
            }
            ++i;
        }
        return res;
    }

    public void addTimeLapse() {
        this.timeLapse[this.nbrTimeLapse][0] = 0;
        this.timeLapse[this.nbrTimeLapse][1] = 0;
        this.timeLapse[this.nbrTimeLapse][2] = 0;
        this.timeLapse[this.nbrTimeLapse][3] = 0;
        this.getTimeLapseWidth = false;
        this.setTimeLapse = true;
    }

    public void removeTimeLapse() {
        this.timeLapse = new int[5][4];
        this.nbrTimeLapse = 0;
    }

    public void newAssertion() {
        this.arrows.add(new Arrow(this));
        this.placeAssertionFrom = true;
    }

    public int getPosFromId(int id) {
        int i = 0;
        while (i < this.signals.size()) {
            if (this.signals.get((int)i).id == id) {
                return i;
            }
            ++i;
        }
        return 0;
    }

    public void removeAssertions() {
        this.arrows.clear();
    }

    public void releaseSelection() {
        this.signals.get((int)this.selected).selected = false;
        if (this.assertionIndex >= 0) {
            this.arrows.get((int)this.assertionIndex).selected = false;
        }
        this.repaint();
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        if (e.getX() < Signals.leftSpace) {
            if (!this.doubleClic) {
                this.doubleClic = true;
                ActionListener taskPerformer = new ActionListener(){

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        ChronoPanel.access$0(ChronoPanel.this, false);
                    }
                };
                Timer t = new Timer(500, taskPerformer);
                t.setRepeats(false);
                t.start();
            } else {
                this.doubleClic = false;
                this.editSignalProperties();
            }
        }
    }

    @Override
    public void mouseEntered(MouseEvent e) {
    }

    @Override
    public void mouseExited(MouseEvent e) {
        if (this.selected >= 0 && this.selected < this.signals.size()) {
            this.signals.get((int)this.selected).selected = false;
        }
        this.moveSelection = false;
        this.repaint();
    }

    @Override
    public void mousePressed(MouseEvent e) {
        int nbr = (int)(((float)e.getY() - (float)Signals.Yspace / 2.0f) / ((float)Signals.heightUnit + (float)Signals.Yspace));
        if (nbr >= 0 && nbr < this.signals.size() && !this.setTimeLapse) {
            if (!this.placeAssertionFrom && !this.placeAssertionTo) {
                if (e.getX() >= Signals.leftSpace) {
                    this.modifToSave = true;
                    if (e.getButton() == 1) {
                        this.signals.get(nbr).setWave(e.getX(), this.signals.get((int)nbr).bus);
                    }
                    if (e.getButton() == 3) {
                        if (!this.signals.get((int)nbr).bus) {
                            this.signals.get(nbr).setWave(e.getX(), true);
                        }
                        if (this.signals.get((int)nbr).bus) {
                            this.selected_bus = nbr;
                            this.bus_offset = e.getX();
                            this.busMenu.show(this, e.getX(), e.getY());
                        }
                    }
                } else if (e.getX() < Signals.leftSpace) {
                    if (e.getButton() == 1) {
                        this.moveSelection = true;
                    }
                    if (e.getButton() == 3) {
                        this.modifToSave = true;
                        this.selected_signal = nbr;
                        this.signal_style_bold.setSelected(this.signals.get((int)nbr).bold);
                        this.signal_set_values.setEnabled(true);
                        this.signal_traceDFT.setEnabled(true);
                        if (this.signals.get((int)nbr).clock || this.signals.get((int)nbr).bus) {
                            this.signal_set_values.setEnabled(false);
                        }
                        if (this.signals.get((int)nbr).bus) {
                            this.signal_traceDFT.setEnabled(false);
                        }
                        this.signalMenu.show(this, e.getX(), e.getY());
                    }
                }
            } else if (this.placeAssertionFrom) {
                this.placeAssertionFrom = false;
                this.placeAssertionTo = true;
            } else if (this.placeAssertionTo) {
                this.placeAssertionTo = false;
                this.arrows.get(this.arrows.size() - 1).done();
            }
            this.repaint();
        }
        if (this.setTimeLapse) {
            this.getTimeLapseWidth = true;
        }
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        if (this.moveSelection) {
            this.moveSelection = false;
            this.setCursor(this.normalCursor);
            int nbr = (int)(((float)e.getY() - (float)Signals.Yspace) / ((float)Signals.heightUnit + (float)Signals.Yspace));
            if (nbr >= 0 && nbr < this.signals.size()) {
                this.moveTo(nbr - this.selected);
                this.repaint();
            }
        }
        if (this.getTimeLapseWidth) {
            this.getTimeLapseWidth = false;
            this.setTimeLapse = false;
            this.timeLapse[this.nbrTimeLapse][1] = this.timeLapse[this.nbrTimeLapse][0] + (this.timeLapse[this.nbrTimeLapse][3] - this.timeLapse[this.nbrTimeLapse][0]) / 4;
            this.timeLapse[this.nbrTimeLapse][2] = this.timeLapse[this.nbrTimeLapse][0] + 3 * (this.timeLapse[this.nbrTimeLapse][3] - this.timeLapse[this.nbrTimeLapse][0]) / 4;
            int[] arrn = this.timeLapse[this.nbrTimeLapse];
            arrn[0] = arrn[0] - Signals.leftSpace;
            int[] arrn2 = this.timeLapse[this.nbrTimeLapse];
            arrn2[1] = arrn2[1] - Signals.leftSpace;
            int[] arrn3 = this.timeLapse[this.nbrTimeLapse];
            arrn3[2] = arrn3[2] - Signals.leftSpace;
            int[] arrn4 = this.timeLapse[this.nbrTimeLapse];
            arrn4[3] = arrn4[3] - Signals.leftSpace;
            ++this.nbrTimeLapse;
            this.sortTimeLapseArray();
            this.repaint();
        }
    }

    @Override
    public void mouseDragged(MouseEvent e) {
        if (this.moveSelection) {
            this.modifToSave = true;
            this.setCursor(this.moveCursor);
            int nbr = (int)(((float)e.getY() - (float)Signals.Yspace) / ((float)Signals.heightUnit + (float)Signals.Yspace));
            if (nbr >= 0 && nbr < this.signals.size()) {
                this.moveTo(nbr - this.selected);
                this.selected = nbr;
                this.repaint();
            }
        }
        if (this.getTimeLapseWidth) {
            this.modifToSave = true;
            this.timeLapse[this.nbrTimeLapse][3] = e.getX();
            this.repaint();
        }
    }

    @Override
    public void mouseMoved(MouseEvent e) {
        this.setCursor(this.normalCursor);
        int nbr = (int)(((float)e.getY() - (float)Signals.Yspace / 2.0f) / ((float)Signals.heightUnit + (float)Signals.Yspace));
        if (nbr >= 0 && nbr < this.signals.size() && !this.setTimeLapse) {
            this.signals.get((int)this.selected).selected = false;
            this.signals.get((int)nbr).selected = true;
            this.elmt_to_edit = true;
            this.selected = nbr;
            if (e.getX() < Signals.leftSpace) {
                this.setCursor(this.handCursor);
            }
            if (this.placeAssertionFrom) {
                this.arrows.get(this.arrows.size() - 1).setStart(this.signals.get(nbr), e.getX());
            }
            if (this.placeAssertionTo) {
                this.arrows.get(this.arrows.size() - 1).setEnd(this.signals.get(nbr), e.getX());
            }
            this.repaint();
        } else if (this.selected >= 0 && this.selected < this.signals.size()) {
            this.signals.get((int)this.selected).selected = false;
            this.repaint();
        }
        if (this.setTimeLapse && !this.getTimeLapseWidth) {
            this.timeLapse[this.nbrTimeLapse][0] = e.getX();
            this.timeLapse[this.nbrTimeLapse][3] = e.getX() + 1;
        }
        int dMin = 8;
        this.assertionIndex = -1;
        int i = 0;
        while (i < this.arrows.size()) {
            this.arrows.get((int)i).selected = false;
            if (this.arrows.get(i).getDistance(e.getX(), e.getY()) < dMin) {
                dMin = this.arrows.get(i).getDistance(e.getX(), e.getY());
                this.assertionIndex = i;
            }
            ++i;
        }
        if (this.assertionIndex != -1) {
            this.arrows.get((int)this.assertionIndex).selected = true;
        }
    }

    public void popUpMenuInit() {
        this.bus_name.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent arg0) {
                DialogBox db = new DialogBox(null, "Set bus data name");
                db.showDialog();
                if (db.name != null) {
                    ChronoPanel.this.signals.get(ChronoPanel.this.selected_bus).setBusName(ChronoPanel.this.bus_offset, db.name);
                }
                ChronoPanel.this.repaint();
            }
        });
        this.bus_fill.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent arg0) {
                ChronoPanel.this.signals.get(ChronoPanel.this.selected_bus).setBusFill(ChronoPanel.this.bus_offset, false);
                ChronoPanel.this.repaint();
            }
        });
        this.bus_clean.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent arg0) {
                ChronoPanel.this.signals.get(ChronoPanel.this.selected_bus).setBusName(ChronoPanel.this.bus_offset, null);
                ChronoPanel.this.signals.get(ChronoPanel.this.selected_bus).setBusFill(ChronoPanel.this.bus_offset, true);
                ChronoPanel.this.repaint();
            }
        });
        this.signal_style_bold.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent event) {
                ChronoPanel.this.signals.get((int)ChronoPanel.this.selected_signal).bold = ChronoPanel.this.signal_style_bold.isSelected();
                ChronoPanel.this.signalMenu.setVisible(false);
                ChronoPanel.this.repaint();
            }
        });
        this.signal_style_color_red.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent event) {
                ChronoPanel.this.signals.get((int)ChronoPanel.this.selected_signal).color = new Color(180, 0, 0);
                ChronoPanel.this.repaint();
            }
        });
        this.signal_style_color_blue.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent event) {
                ChronoPanel.this.signals.get((int)ChronoPanel.this.selected_signal).color = new Color(0, 0, 180);
                ChronoPanel.this.repaint();
            }
        });
        this.signal_style_color_orange.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent event) {
                ChronoPanel.this.signals.get((int)ChronoPanel.this.selected_signal).color = new Color(255, 102, 50);
                ChronoPanel.this.repaint();
            }
        });
        this.signal_style_color_green.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent event) {
                ChronoPanel.this.signals.get((int)ChronoPanel.this.selected_signal).color = new Color(0, 180, 0);
                ChronoPanel.this.repaint();
            }
        });
        this.signal_style_color_black.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent event) {
                ChronoPanel.this.signals.get((int)ChronoPanel.this.selected_signal).color = Color.black;
                ChronoPanel.this.repaint();
            }
        });
        this.signal_properties.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent arg0) {
                ChronoPanel.this.editSignalProperties();
                ChronoPanel.this.repaint();
            }
        });
        this.signal_traceDFT.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent arg0) {
                new DFT.TraceDFT(ChronoPanel.this.signals.get(ChronoPanel.this.selected_signal), ChronoWindow.WIDTH);
                ChronoPanel.this.repaint();
            }
        });
        this.signal_set_values.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent arg0) {
                DialogBox db = new DialogBox(null, "Set Wave Values", ChronoPanel.this.signals.get(ChronoPanel.this.selected), true);
                db.showDialog();
                if (db.valid) {
                    int i = 0;
                    while (i < ChronoPanel.this.signals.get((int)ChronoPanel.this.selected).wave.length) {
                        ChronoPanel.this.signals.get((int)ChronoPanel.this.selected).wave[i] = db.waveSet[i];
                        ++i;
                    }
                }
                ChronoPanel.this.repaint();
            }
        });
        this.signal_delete.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent arg0) {
                ChronoPanel.this.removeSelected();
                ChronoPanel.this.repaint();
            }
        });
    }

    public void editSignalProperties() {
        if (this.elmt_to_edit) {
            DialogBox db = new DialogBox(null, "Properties", this.signals.get(this.selected));
            db.showDialog();
            if (db.valid) {
                this.modifToSave = true;
                if (db.name != null) {
                    this.signals.get((int)this.selected).name = db.name;
                }
                this.repaint();
                if (db.freq != -1) {
                    this.changePeriod(db.freq);
                }
                this.repaint();
                if (!this.signals.get((int)this.selected).clock && db.clockDomain != -1) {
                    this.changeSelClockDomain(db.clockDomain);
                }
                this.repaint();
                if (this.signals.get((int)this.selected).clock) {
                    this.signals.get((int)this.selected).displayRisingEdges = db.displayRisingEdges;
                    this.signals.get(this.selected).generate(db.beginOnRisingEdge);
                    if (db.clockDomain != -1 && db.clkDependency) {
                        if (this.checkIfSignalIndependent(this.signals.get((int)this.selected).id)) {
                            this.signals.get((int)this.selected).ratio = db.ratio;
                            this.signals.get((int)this.selected).dependsOnClk = true;
                            this.changeSelClockDomain(db.clockDomain);
                        } else {
                            JOptionPane.showMessageDialog(null, String.valueOf(this.signals.get((int)this.selected).name) + " can not depend on " + this.signals.get((int)db.clockDomain).name + " as other clocks depend on " + this.signals.get((int)this.selected).name, "Warning", 2);
                        }
                    } else {
                        this.signals.get((int)this.selected).ratio = 1.0f;
                        this.changeSelClockDomain(this.signals.get((int)this.selected).id);
                        this.signals.get((int)this.selected).dependsOnClk = false;
                        if (db.freq != -1) {
                            this.changePeriod(db.freq);
                        }
                    }
                    this.updateClockDomain();
                }
                this.signals.get((int)this.selected).clkToQdelay = db.clkToQdelay;
                this.repaint();
                if (!this.signals.get((int)this.selected).bus) {
                    if (!db.setUp) {
                        this.signals.get((int)this.selected).setUpTime = 0;
                    }
                    if (db.setUp) {
                        this.signals.get((int)this.selected).setUpTime = 8;
                    }
                    this.repaint();
                }
            }
        }
    }

    public void sortTimeLapseArray() {
        int[][] temp = new int[9][4];
        int[] rank = new int[this.nbrTimeLapse];
        int i = 0;
        while (i < this.nbrTimeLapse) {
            temp[i][0] = this.timeLapse[i][0];
            temp[i][1] = this.timeLapse[i][1];
            temp[i][2] = this.timeLapse[i][2];
            temp[i][3] = this.timeLapse[i][3];
            ++i;
        }
        i = 0;
        while (i < this.nbrTimeLapse) {
            rank[i] = i;
            int j = 0;
            while (j < i) {
                if (this.timeLapse[i][0] < this.timeLapse[j][0]) {
                    int[] arrn = rank;
                    int n = i;
                    arrn[n] = arrn[n] - 1;
                    int[] arrn2 = rank;
                    int n2 = j;
                    arrn2[n2] = arrn2[n2] + 1;
                }
                ++j;
            }
            ++i;
        }
        i = 0;
        while (i < this.nbrTimeLapse) {
            this.timeLapse[rank[i]][0] = temp[i][0];
            this.timeLapse[rank[i]][1] = temp[i][1];
            this.timeLapse[rank[i]][2] = temp[i][2];
            this.timeLapse[rank[i]][3] = temp[i][3];
            ++i;
        }
    }

    static /* synthetic */ void access$0(ChronoPanel chronoPanel, boolean bl) {
        chronoPanel.doubleClic = bl;
    }

}

