Example usage for java.awt.event MouseEvent getPoint

List of usage examples for java.awt.event MouseEvent getPoint

Introduction

In this page you can find the example usage for java.awt.event MouseEvent getPoint.

Prototype

public Point getPoint() 

Source Link

Document

Returns the x,y position of the event relative to the source component.

Usage

From source file:org.rdv.viz.image.ImageViz.java

private void initTiltControls() {
    tiltControls = new JPanel();
    tiltControls.setLayout(new BorderLayout());

    JButton tiltUpButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-up.gif"));
    tiltUpButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            tiltUp();//from   w  w w  .  j  a  va  2 s .c  o  m
        }
    });
    tiltUpButton.setBorder(null);
    tiltControls.add(tiltUpButton, BorderLayout.NORTH);

    JButton tiltControlButton = new StrechIconButton(
            DataViewer.getIcon("icons/ptz/robotic_control-tiltbar-medium.gif"));
    tiltControlButton.setBorder(null);
    tiltControlButton.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            JButton button = (JButton) e.getComponent();
            int tilt = Math.round(100f * e.getPoint().y / button.getHeight());
            tilt(tilt);
        }
    });
    tiltControls.add(tiltControlButton, BorderLayout.CENTER);

    JButton tiltDownButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-down.gif"));
    tiltDownButton.setBorder(null);
    tiltDownButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            tiltDown();
        }
    });
    tiltControls.add(tiltDownButton, BorderLayout.SOUTH);
}

From source file:org.rdv.viz.image.ImageViz.java

private void initRoboticMouseClickListener() {
    roboticMouseClickListener = new MouseInputAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                Point imagePoint = imagePanel.panelToScaledImagePoint(e.getPoint());
                if (imagePoint != null) {
                    center(imagePoint);/*from   w  ww. j  a va  2  s.co m*/
                }
            }
        }
    };
}

From source file:org.openconcerto.erp.core.humanresources.payroll.element.FichePayeSQLElement.java

public SQLComponent createComponent() {
    return new BaseSQLComponent(this) {

        private FichePayeModel model;
        private ElementComboBox comboSelProfil, selSalCombo;
        private EditFrame edit = null;
        private ElementComboBox selMois;
        private int dernMois, dernAnnee;
        private JTextField textAnnee;
        JDate dateDu, dateAu;/*  www. jav  a2s. co m*/
        private JScrollPane paneTreeLeft;
        private JPanel pDate;
        private JButton buttonValider, buttonGenCompta;

        public void addViews() {

            this.dernMois = 0;
            this.dernAnnee = 0;

            this.setLayout(new GridBagLayout());

            final GridBagConstraints c = new DefaultGridBagConstraints();

            // Tree elt Fiche de Paye On the left
            c.fill = GridBagConstraints.BOTH;
            c.weightx = 1;
            c.weighty = 1;
            c.gridheight = GridBagConstraints.REMAINDER;
            final RubriquePayeTree tree = new RubriquePayeTree();
            tree.expandRow(0);
            this.paneTreeLeft = new JScrollPane(tree);
            // this.add(this.paneTreeLeft, c);

            // Panel Fiche paye on the right
            // Salarie
            JPanel panelRight = new JPanel();
            panelRight.setLayout(new GridBagLayout());
            c.fill = GridBagConstraints.HORIZONTAL;
            c.weightx = 1;
            c.weighty = 0;
            c.gridheight = 1;
            c.gridwidth = 2;
            this.selSalCombo = new ElementComboBox();
            // c.gridx++;
            panelRight.add(this.selSalCombo, c);

            // Mois
            c.gridy++;
            // c.gridx++;
            c.fill = GridBagConstraints.HORIZONTAL;
            c.weightx = 1;
            c.weighty = 0;
            c.gridheight = 1;
            c.gridwidth = 3;
            JLabel labelMois = new JLabel("Fiche de paye du mois de");
            this.selMois = new ElementComboBox(true, 20);
            // this.selMois.setEditable(true);
            // /this.selMois.setEnabled(true);

            JLabel labelDu = new JLabel("Du");
            JLabel labelAu = new JLabel("Au");
            this.dateDu = new JDate();
            this.dateAu = new JDate();

            // JTextField textMois = new JTextField();
            JLabel labelAnnee = new JLabel("Anne");
            this.textAnnee = new JTextField();
            {
                this.pDate = new JPanel();
                this.pDate.setOpaque(false);
                this.pDate.add(labelMois);
                this.pDate.add(this.selMois);
                this.pDate.add(labelAnnee);
                this.pDate.add(this.textAnnee);
                this.pDate.add(labelDu);
                this.pDate.add(this.dateDu);
                this.pDate.add(labelAu);
                this.pDate.add(this.dateAu);
                panelRight.add(this.pDate, c);
            }
            c.gridx += 2;
            c.weightx = 1;
            c.gridwidth = 1;
            c.fill = GridBagConstraints.HORIZONTAL;
            panelRight.add(new JPanel(), c);

            // Action Button
            c.gridx++;
            c.fill = GridBagConstraints.HORIZONTAL;
            c.weightx = 0;
            c.weighty = 0;

            JPanel pButtons = new JPanel();
            pButtons.setOpaque(false);
            JButton buttonUp = new JNiceButton(IListFrame.class.getResource("fleche_haut.png"));
            JButton buttonDown = new JNiceButton(IListFrame.class.getResource("fleche_bas.png"));
            JButton buttonRemove = new JNiceButton(SQLComponent.class.getResource("delete.png"));
            {
                pButtons.add(buttonUp);
                pButtons.add(buttonDown);
                pButtons.add(buttonRemove);
            }
            panelRight.add(pButtons, c);

            // Table
            c.fill = GridBagConstraints.BOTH;
            c.weightx = 1;
            c.weighty = 1;
            c.gridx = 1;
            c.gridy++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            this.model = new FichePayeModel(1);
            final JTable table = new JTable(this.model);
            panelRight.add(new JScrollPane(table), c);
            FichePayeRenderer rend = new FichePayeRenderer();
            table.setDefaultRenderer(String.class, rend);
            table.setDefaultRenderer(Float.class, rend);

            // Import profil
            c.gridx = 1;
            c.gridy++;
            c.weightx = 0;
            c.weighty = 0;
            c.gridwidth = 1;
            c.fill = GridBagConstraints.HORIZONTAL;
            JLabel labelProfil = new JLabel("Importer depuis un profil prdfini");
            panelRight.add(labelProfil, c);
            c.gridwidth = 1;

            this.comboSelProfil = new ElementComboBox();
            // this.comboSelProfil = new ElementComboBox();
            this.comboSelProfil.setListIconVisible(false);
            c.gridx++;
            c.gridwidth = 1;

            // this.comboSelProfil.init(eltProfil.getTable().getField("NOM"), null);
            panelRight.add(this.comboSelProfil, c);

            JButton buttonImportProfil = new JButton("Importer");
            c.gridx++;
            panelRight.add(buttonImportProfil, c);

            // Total Periode
            JPanel panelTotal = new JPanel();
            panelTotal.setBorder(BorderFactory.createTitledBorder("Total priode"));
            panelTotal.setLayout(new GridBagLayout());
            GridBagConstraints cPanel = new DefaultGridBagConstraints();

            // Salaire brut
            JLabel labelBrut = new JLabel(getLabelFor("SAL_BRUT"));
            panelTotal.add(labelBrut, cPanel);
            JTextField textSalBrut = new JTextField(10);
            cPanel.gridx++;
            cPanel.weightx = 0;
            panelTotal.add(textSalBrut, cPanel);
            textSalBrut.setEditable(false);
            textSalBrut.setEnabled(false);

            // acompte
            cPanel.gridx++;
            JLabel labelAcompte = new JLabel(getLabelFor("ACOMPTE"));
            panelTotal.add(labelAcompte, cPanel);
            JTextField textAcompte = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textAcompte, cPanel);
            // textAcompte.setEditable(false);
            // textAcompte.setEnabled(false);

            // Conges Acquis
            cPanel.gridx++;
            JLabel labelCongesAcquis = new JLabel(getLabelFor("CONGES_ACQUIS"));
            panelTotal.add(labelCongesAcquis, cPanel);
            JTextField textCongesAcquis = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textCongesAcquis, cPanel);

            // cotisation salariale
            cPanel.gridx = 0;
            cPanel.gridy++;
            JLabel labelCotSal = new JLabel(getLabelFor("COT_SAL"));
            panelTotal.add(labelCotSal, cPanel);
            JTextField textCotSal = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textCotSal, cPanel);
            textCotSal.setEditable(false);
            textCotSal.setEnabled(false);

            // cotisation patronale
            cPanel.gridx++;
            JLabel labelCotPat = new JLabel(getLabelFor("COT_PAT"));
            panelTotal.add(labelCotPat, cPanel);
            JTextField textCotPat = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textCotPat, cPanel);
            textCotPat.setEditable(false);
            textCotPat.setEnabled(false);

            JLabel labelCSG = new JLabel(getLabelFor("CSG"));
            cPanel.gridx++;
            panelTotal.add(labelCSG, cPanel);
            JTextField textCSG = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textCSG, cPanel);
            textCSG.setEditable(false);
            textCSG.setEnabled(false);

            // net imposable
            cPanel.gridx = 0;
            cPanel.gridy++;
            JLabel labelNetImp = new JLabel(getLabelFor("NET_IMP"));
            panelTotal.add(labelNetImp, cPanel);
            JTextField textNetImp = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textNetImp, cPanel);
            textNetImp.setEditable(false);
            textNetImp.setEnabled(false);

            cPanel.gridx++;
            JLabel labelNetAPayer = new JLabel(getLabelFor("NET_A_PAYER"));
            panelTotal.add(labelNetAPayer, cPanel);
            JTextField textNetAPayer = new JTextField(10);
            cPanel.gridx++;
            panelTotal.add(textNetAPayer, cPanel);
            textNetAPayer.setEditable(false);
            textNetAPayer.setEnabled(false);

            c.gridx = 1;
            c.gridy++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            panelRight.add(panelTotal, c);

            // Cumuls

            c.gridx = 1;
            c.gridy++;
            c.gridwidth = 1;
            c.fill = GridBagConstraints.NONE;
            this.buttonValider = new JButton("Valider");
            // panelRight.add(buttonValider, c);

            c.gridx++;
            c.gridwidth = 1;
            this.buttonGenCompta = new JButton("Generer la comptabilit");
            // panelRight.add(buttonGenCompta, c);

            c.gridx = 0;
            c.gridy = 0;
            c.gridwidth = 1;
            c.gridheight = 1;
            c.fill = GridBagConstraints.BOTH;
            c.weightx = 1;
            c.weighty = 1;
            this.add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.paneTreeLeft, panelRight), c);

            // Listeners
            this.buttonGenCompta.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    int[] i = new int[1];
                    i[0] = getSelectedID();

                    SQLRow rowMois = getTable().getBase().getTable("MOIS").getRow(selMois.getSelectedId());

                    new GenerationMvtFichePaye(i, rowMois.getString("NOM"), textAnnee.getText());
                }
            });

            this.buttonValider.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.err.println("Validation de la fiche de paye");
                    validationFiche();
                }
            });

            buttonUp.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    int newRowSelected = model.upRow(table.getSelectedRow());
                    if (newRowSelected >= 0) {
                        table.setRowSelectionInterval(newRowSelected, newRowSelected);
                    }
                }
            });

            buttonDown.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    int newRowSelected = model.downRow(table.getSelectedRow());
                    if (newRowSelected >= 0) {
                        table.setRowSelectionInterval(newRowSelected, newRowSelected);
                    }
                }
            });

            buttonRemove.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    model.removeRow(table.getSelectedRow());
                }
            });

            tree.addMouseListener(new MouseAdapter() {

                public void mousePressed(MouseEvent mE) {

                    TreePath path = tree.getClosestPathForLocation(mE.getPoint().x, mE.getPoint().y);

                    final Object obj = path.getLastPathComponent();

                    if (obj == null) {
                        return;
                    }

                    if (mE.getClickCount() == 2 && mE.getButton() == MouseEvent.BUTTON1) {

                        if (obj instanceof VariableRowTreeNode) {
                            model.addRowAt(((VariableRowTreeNode) obj).getRow(), table.getSelectedRow());
                        }
                    } else {

                        if (mE.getButton() == 3) {

                            if (obj instanceof VariableRowTreeNode) {

                                final SQLRow row = ((VariableRowTreeNode) obj).getRow();

                                JPopupMenu menuDroit = new JPopupMenu();

                                menuDroit.add(new AbstractAction("Editer") {
                                    public void actionPerformed(ActionEvent e) {

                                        if (edit != null) {
                                            edit.dispose();
                                        }
                                        edit = new EditFrame(Configuration.getInstance().getDirectory()
                                                .getElement(row.getTable()), EditFrame.MODIFICATION);
                                        edit.selectionId(row.getID(), 0);
                                        edit.pack();
                                        edit.setVisible(true);
                                    }
                                });

                                menuDroit.add(new AbstractAction("Nouvelle rubrique") {
                                    public void actionPerformed(ActionEvent e) {

                                        if (edit != null) {
                                            edit.dispose();
                                        }
                                        edit = new EditFrame(Configuration.getInstance().getDirectory()
                                                .getElement(row.getTable()));
                                        edit.pack();
                                        edit.setVisible(true);
                                    }
                                });

                                menuDroit.show(mE.getComponent(), mE.getPoint().x, mE.getPoint().y);

                            }
                        }
                    }
                }
            });

            this.dateDu.addValueListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    if (!dateDu.isEmpty()) {
                        Date d = dateDu.getValue();

                        if (d != null) {
                            Calendar cal = Calendar.getInstance();
                            cal.setTime(d);
                            if (selMois.getSelectedId() > 1
                                    && cal.get(Calendar.MONTH) + 2 != selMois.getSelectedId()) {

                                cal.set(Calendar.DAY_OF_MONTH, 1);
                                cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
                                System.err.println("Du " + cal.getTime());
                                dateDu.setValue(cal.getTime());
                            }
                        }
                    }
                }
            });

            this.dateAu.addValueListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    if (!dateAu.isEmpty()) {
                        Date d = dateAu.getValue();
                        if (d != null) {
                            Calendar cal = Calendar.getInstance();
                            cal.setTime(d);
                            if (selMois.getSelectedId() > 1
                                    && cal.get(Calendar.MONTH) + 2 != selMois.getSelectedId()) {

                                // TODO checker l'annee
                                // TODO ajouter dans le isValidated du au compris dans le mois
                                // selectionne

                                // Calendar.getInstance().set(Calendar.DAY_OF_MONTH, maxDay);
                                cal.set(Calendar.DAY_OF_MONTH, 1);
                                cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
                                cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
                                System.err.println("Au " + cal.getTime());
                                dateAu.setValue(cal.getTime());
                            }
                        }
                    }
                }
            });

            this.addRequiredSQLObject(this.textAnnee, "ANNEE");
            this.addRequiredSQLObject(this.selMois, "ID_MOIS");
            this.addSQLObject(this.comboSelProfil, "ID_PROFIL_PAYE");

            this.addSQLObject(textCongesAcquis, "CONGES_ACQUIS");
            this.addSQLObject(textCotPat, "COT_PAT");
            this.addSQLObject(textCotSal, "COT_SAL");
            this.addSQLObject(textCSG, "CSG");
            this.addSQLObject(textNetAPayer, "NET_A_PAYER");
            this.addSQLObject(textNetImp, "NET_IMP");
            this.addSQLObject(textSalBrut, "SAL_BRUT");
            this.addSQLObject(textAcompte, "ACOMPTE");
            this.addSQLObject(this.selSalCombo, "ID_SALARIE");

            this.addRequiredSQLObject(this.dateDu, "DU");
            this.addRequiredSQLObject(this.dateAu, "AU");

            this.selSalCombo.setEditable(false);
            this.selSalCombo.setEnabled(false);
            this.selSalCombo.setButtonsVisible(false);
            // this.selSalCombo.setVisible(false);

            buttonImportProfil.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                    model.loadFromProfil(comboSelProfil.getSelectedId());
                }
            });
        }

        private boolean isDateValid() {

            String yearS = this.textAnnee.getText().trim();
            int annee = (yearS.length() == 0) ? 0 : Integer.parseInt(yearS);

            int mois = this.selMois.getSelectedId();
            // System.err.println("anne " + annee + " dernAnnee " + this.dernAnnee + " mois " +
            // mois + " dernMois " + this.dernMois);

            return ((this.dernAnnee == 0) ? true : annee > this.dernAnnee)
                    || ((this.dernMois == 0 || this.dernMois == 13) ? true : mois > this.dernMois);
        }

        @Override
        public synchronized ValidState getValidState() {
            // FIXME add fireValidChange()
            return super.getValidState().and(ValidState.createCached(isDateValid(), "Date invalide"));
        }

        public int insert(SQLRow order) {

            int id = super.insert(order);
            this.model.updateFields(id);
            return id;
        }

        @Override
        public void update() {
            super.update();
            this.model.updateFields(this.getSelectedID());
        }

        @Override
        public void select(SQLRowAccessor r) {

            // System.err.println("SELECT FICHE ID -> " + r.getID());
            super.select(r);

            if (r != null && r.getID() > 1) {
                this.model.setFicheID(r.getID());

                SQLTable tableSal = getTable().getBase().getTable("SALARIE");
                SQLRow rowSal = tableSal.getRow(r.getInt("ID_SALARIE"));

                this.dernMois = rowSal.getInt("DERNIER_MOIS");
                this.dernAnnee = rowSal.getInt("DERNIERE_ANNEE");

                this.selSalCombo.setVisible(((Boolean) r.getObject("VALIDE")).booleanValue());
                this.paneTreeLeft.setVisible(!((Boolean) r.getObject("VALIDE")).booleanValue());
                this.buttonValider.setVisible(!((Boolean) r.getObject("VALIDE")).booleanValue());
                setpDateEnabled(!((Boolean) r.getObject("VALIDE")).booleanValue());
            }
            this.selSalCombo.setEditable(false);
            this.selSalCombo.setEnabled(false);
            this.selMois.setButtonsVisible(false);
            this.selSalCombo.setButtonsVisible(false);
        }

        private void setpDateEnabled(boolean b) {

            // System.err.println("Set date enable --> " + b);
            this.selMois.setEditable(b);
            // this.selMois.setEnabled(b);

            this.textAnnee.setEditable(b);
            this.textAnnee.setEnabled(b);

            this.dateDu.setEditable(b);
            this.dateDu.setEnabled(b);

            this.dateAu.setEditable(b);
            this.dateAu.setEnabled(b);
        }

        private void validationFiche() {

            this.update();
            FichePayeSQLElement.validationFiche(this.getSelectedID());
        }

        protected SQLRowValues createDefaults() {

            System.err.println("**********Set Defaults on FichePaye.date");
            SQLRowValues rowVals = new SQLRowValues(getTable());
            Calendar cal = Calendar.getInstance();
            rowVals.put("ID_MOIS", cal.get(Calendar.MONTH) + 2);
            rowVals.put("ANNEE", cal.get(Calendar.YEAR));

            cal.set(Calendar.DAY_OF_MONTH, 1);
            rowVals.put("DU", new java.sql.Date(cal.getTime().getTime()));

            cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
            rowVals.put("AU", new java.sql.Date(cal.getTime().getTime()));
            return rowVals;
        }

    };
}

From source file:org.rdv.viz.image.ImageViz.java

private void initPanControls() {
    panControls = new JPanel();
    panControls.setLayout(new BorderLayout());

    JButton panLeftButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-left.gif"));
    panLeftButton.setBorder(null);/*from www  . ja  va 2s  .c o  m*/
    panLeftButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            panLeft();
        }
    });
    panControls.add(panLeftButton, BorderLayout.WEST);

    JButton panControlButton = new StrechIconButton(
            DataViewer.getIcon("icons/ptz/robotic_control-panbar-medium.gif"));
    panControlButton.setBorder(null);
    panControlButton.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            JButton button = (JButton) e.getComponent();
            int pan = Math.round(100f * e.getPoint().x / button.getWidth());
            pan(pan);
        }
    });
    panControls.add(panControlButton, BorderLayout.CENTER);

    JPanel bottomRightControls = new JPanel();
    bottomRightControls.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));

    JButton panRightButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-right.gif"));
    panRightButton.setBorder(null);
    panRightButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            panRight();
        }
    });
    bottomRightControls.add(panRightButton);

    JButton bottomHomeButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-home.gif"));
    bottomHomeButton.setBorder(null);
    bottomHomeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            home();
        }
    });
    bottomRightControls.add(bottomHomeButton);

    panControls.add(bottomRightControls, BorderLayout.EAST);
}

From source file:org.rdv.viz.image.ImageViz.java

private void initIrisControls() {
    irisControls = new JPanel();
    irisControls.setLayout(new BorderLayout());

    JButton closeIrisButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-close.gif"));
    closeIrisButton.setBorder(null);//from   www . j  av  a 2s.  c  o m
    closeIrisButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            irisClose();
        }
    });
    irisControls.add(closeIrisButton, BorderLayout.WEST);

    JButton irisControlButton = new StrechIconButton(
            DataViewer.getIcon("icons/ptz/robotic_control-irisbar-medium.gif"));
    irisControlButton.setBorder(null);
    irisControlButton.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            JButton button = (JButton) e.getComponent();
            int iris = Math.round(100f * e.getPoint().x / button.getWidth());
            iris(iris);
        }
    });
    irisControls.add(irisControlButton, BorderLayout.CENTER);

    JPanel irisControlsRight = new JPanel();
    irisControlsRight.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));

    JButton openIrisButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-open.gif"));
    openIrisButton.setBorder(null);
    openIrisButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            irisOpen();
        }
    });
    irisControlsRight.add(openIrisButton);

    JButton autoIrisButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-auto.gif"));
    autoIrisButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            irisAuto();
        }
    });
    autoIrisButton.setBorder(null);
    irisControlsRight.add(autoIrisButton);

    irisControls.add(irisControlsRight, BorderLayout.EAST);
}

From source file:org.rdv.viz.image.ImageViz.java

private void initZoomControls() {
    zoomControls = new JPanel();
    zoomControls.setLayout(new BorderLayout());

    JButton zoomOutButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-minus.gif"));
    zoomOutButton.setBorder(null);/*from   www. jav a2s  .c om*/
    zoomOutButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            zoomOut();
        }
    });
    zoomControls.add(zoomOutButton, BorderLayout.WEST);

    JButton zoomControlButton = new StrechIconButton(
            DataViewer.getIcon("icons/ptz/robotic_control-zoombar-medium.gif"));
    zoomControlButton.setBorder(null);
    zoomControlButton.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            JButton button = (JButton) e.getComponent();
            int zoom = Math.round(100f * e.getPoint().x / button.getWidth());
            zoom(zoom);
        }
    });
    zoomControls.add(zoomControlButton, BorderLayout.CENTER);

    JPanel topRightControls = new JPanel();
    topRightControls.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));

    JButton zoomInButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-plus.gif"));
    zoomInButton.setBorder(null);
    zoomInButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            zoomIn();
        }
    });
    topRightControls.add(zoomInButton);

    JButton topHomeButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-home.gif"));
    topHomeButton.setBorder(null);
    topHomeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            home();
        }
    });
    topRightControls.add(topHomeButton);

    zoomControls.add(topRightControls, BorderLayout.EAST);
}

From source file:org.rdv.viz.image.ImageViz.java

private void initFocusControls() {
    focusControls = new JPanel();
    focusControls.setLayout(new BorderLayout());

    JButton nearFocusButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-near.gif"));
    nearFocusButton.setBorder(null);//from w  w  w  .jav  a2  s.c  o m
    nearFocusButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            focusNear();
        }
    });
    focusControls.add(nearFocusButton, BorderLayout.WEST);

    JButton focusControlButton = new StrechIconButton(
            DataViewer.getIcon("icons/ptz/robotic_control-focusbar-medium.gif"));
    focusControlButton.setBorder(null);
    focusControlButton.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            JButton button = (JButton) e.getComponent();
            int focus = Math.round(100f * e.getPoint().x / button.getWidth());
            focus(focus);
        }
    });

    focusControls.add(focusControlButton, BorderLayout.CENTER);

    JPanel focusControlsRight = new JPanel();
    focusControlsRight.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));

    JButton farFocusButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-far.gif"));
    farFocusButton.setBorder(null);
    farFocusButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            focusFar();
        }
    });
    focusControlsRight.add(farFocusButton);

    JButton autoFocusButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-auto.gif"));
    autoFocusButton.setBorder(null);
    autoFocusButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            focusAuto();
        }
    });
    focusControlsRight.add(autoFocusButton);

    focusControls.add(focusControlsRight, BorderLayout.EAST);
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.SpectraPanel.java

public void mouseReleased(MouseEvent e) {
    if (MouseUtils.isPopupTrigger(e)) {
        // clear all
        if (zoom_rectangle != null) {
            Graphics2D g2 = (Graphics2D) getGraphics();
            g2.setXORMode(java.awt.Color.gray);
            g2.draw(zoom_rectangle);//from w w w  . jav  a  2s .co  m
            g2.dispose();
        }
        mouse_start_point = null;
        zoom_rectangle = null;

        // open popup
        current_peak = findPeakAt(e.getPoint());
        enforceSelection(current_peak);
        createPopupMenu(current_peak != null).show(theChartPanel, e.getX(), e.getY());
    } else {
        if (zoom_rectangle != null && mouse_start_point != null) {
            if (Math.abs(e.getX() - mouse_start_point.getX()) > 10) {
                //if( e.getX() < mouse_start_point.getX() ) {
                // unzoom all
                //    onZoomNone();
                //}
                //else {        

                // zoom area           
                double start_x = Math.min(e.getX(), mouse_start_point.getX());
                double end_x = Math.max(e.getX(), mouse_start_point.getX());

                Rectangle2D data_area = theChartPanel.getScreenDataArea((int) start_x,
                        (int) mouse_start_point.getY());

                double new_lower_bound = screenToDataCoordX(start_x);
                double new_upper_bound = screenToDataCoordX(Math.min(end_x, data_area.getMaxX()));
                thePlot.getDomainAxis().setRange(new Range(new_lower_bound, new_upper_bound));
            } else {
                // clear rectangle
                Graphics2D g2 = (Graphics2D) getGraphics();
                g2.setXORMode(java.awt.Color.gray);
                g2.draw(zoom_rectangle);
                g2.dispose();
            }
        }

        // restore zooming
        if (!was_moving && is_moving)
            onActivateZooming();

        zoom_rectangle = null;
        mouse_start_point = null;
    }
}

From source file:org.openconcerto.erp.panel.ITreeSelection.java

public void mousePressed(MouseEvent e) {

    TreePath path = this.getSelectionPath();
    if (path != null) {
        Object o = path.getLastPathComponent();

        int id = 1;

        if (e.getButton() == MouseEvent.BUTTON3) {

            final int idSelect = getSelectedID();

            // Ajouter, supprimer, modifier un lment dans l'arbre

            JPopupMenu menu = new JPopupMenu();
            menu.add(new AbstractAction("Ajouter un lment") {
                public void actionPerformed(ActionEvent e) {
                    addElement(idSelect);
                }/*  w w  w.j  av a2 s  .co m*/
            });

            if (idSelect > 1) {
                menu.add(new AbstractAction("Modifier") {
                    public void actionPerformed(ActionEvent e) {
                        modifyElement(idSelect);
                    }
                });

                menu.add(new AbstractAction("Supprimer") {
                    public void actionPerformed(ActionEvent e) {
                        removeElement(idSelect);
                    }
                });
            }
            menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
        }
    }
}

From source file:com.vgi.mafscaling.LogView.java

private void createLogViewPanel() {
    logViewPanel = new JPanel();
    GridBagLayout gbl_logViewPanel = new GridBagLayout();
    gbl_logViewPanel.columnWidths = new int[] { 0 };
    gbl_logViewPanel.rowHeights = new int[] { 0, 0 };
    gbl_logViewPanel.columnWeights = new double[] { 1.0 };
    gbl_logViewPanel.rowWeights = new double[] { 1.0, 0.0 };
    logViewPanel.setLayout(gbl_logViewPanel);
    try {/*from  ww w. ja v  a2  s.  com*/
        logDataTable = new DBTable();
        logDataTable.copyColumnHeaderNames = true;
        logDataTable.defaultClickCountToStartEditor = 2;
        logDataTable.doNotUseDatabaseSort = true;
        logDataTable.listenKeyPressEventsWholeWindow = true;
        logDataTable.createControlPanel(DBTable.READ_NAVIGATION);
        logDataTable.enableExcelCopyPaste();
        logDataTable.setSortEnabled(false);
        logDataTable.setSkin(new TableSkin());
        logDataTable.refresh(new String[1][25]);
        logDataTable.setComparator(new DoubleComparator());
        logDataTable.getTable().setCellSelectionEnabled(true);
        logDataTable.getTable().setColumnSelectionAllowed(true);
        logDataTable.getTable().setRowSelectionAllowed(true);
        logDataTable.getTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        JTextField rowTextField = ((JTextField) logDataTable.getControlPanel().getComponent(3));
        rowTextField.setPreferredSize(null);
        rowTextField.setColumns(5);

        GridBagConstraints gbc_logDataTable = new GridBagConstraints();
        gbc_logDataTable.insets = insets0;
        gbc_logDataTable.anchor = GridBagConstraints.PAGE_START;
        gbc_logDataTable.fill = GridBagConstraints.BOTH;
        gbc_logDataTable.gridx = 0;
        gbc_logDataTable.gridy = 0;
        logViewPanel.add(logDataTable, gbc_logDataTable);
        listModel = new DefaultListModel<JLabel>();

        selectionCombo.removeAllItems();
        String name;
        JTableHeader tableHeader = logDataTable.getTableHeader();
        for (int i = 0; i < logDataTable.getColumnCount(); ++i) {
            Column col = logDataTable.getColumn(i);
            col.setNullable(true);
            col.setHeaderRenderer(new CheckboxHeaderRenderer(i + 1, tableHeader));
            name = col.getHeaderValue().toString();
            selectionCombo.addItem(name);
            listModel.addElement(new JLabel(name, new CheckBoxIcon(), JLabel.LEFT));
        }

        JList<JLabel> menuList = new JList<JLabel>(listModel);
        menuList.setOpaque(false);
        menuList.setCellRenderer(new ImageListCellRenderer());
        menuList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        menuList.setLayoutOrientation(JList.VERTICAL);
        menuList.setFixedCellHeight(25);
        menuList.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                try {
                    if (e.getClickCount() == 1 && colors.size() > 0) {
                        JList<?> list = (JList<?>) e.getSource();
                        int index = list.locationToIndex(e.getPoint());
                        if (index >= 0) {
                            int colIdx = logDataTable.getCurrentIndexForOriginalColumn(index);
                            Column col = logDataTable.getColumn(colIdx);
                            if (col.getHeaderRenderer() instanceof CheckboxHeaderRenderer) {
                                CheckboxHeaderRenderer renderer = (CheckboxHeaderRenderer) col
                                        .getHeaderRenderer();
                                JLabel label = (JLabel) list.getModel().getElementAt(index);
                                CheckBoxIcon checkIcon = (CheckBoxIcon) label.getIcon();
                                checkIcon.setChecked(!checkIcon.isChecked());
                                if (checkIcon.isChecked()) {
                                    checkIcon.setColor(colors.pop());
                                    JTable table = logDataTable.getTable();
                                    TableModel model = table.getModel();
                                    addXYSeries(model, index, col.getHeaderValue().toString(),
                                            checkIcon.getColor());
                                } else {
                                    colors.push(checkIcon.getColor());
                                    checkIcon.setColor(renderer.getDefaultColor());
                                    removeXYSeries(index);
                                }
                                list.repaint();
                            }
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        });

        headerScrollPane = new JScrollPane(menuList);
        GridBagConstraints gbc_headersTree = new GridBagConstraints();
        gbc_headersTree.insets = insets0;
        gbc_headersTree.anchor = GridBagConstraints.PAGE_START;
        gbc_headersTree.fill = GridBagConstraints.BOTH;
        gbc_headersTree.gridx = 0;
        gbc_headersTree.gridy = 1;

        logViewPanel.add(headerScrollPane, gbc_headersTree);
        headerScrollPane.setVisible(false);

    } catch (Exception e) {
        e.printStackTrace();
        logger.error(e);
    }
}