Search in sources :

Example 56 with MouseListener

use of java.awt.event.MouseListener in project vcell by virtualcell.

the class DialogUtils method getDBTreePanelSelection.

/**
 * Return VersionInfo from JPanels implementing SelectableTreeVersionJPanel
 * including MathModelDbTreePanel, BioModelDbTreePanel, GeometryTreePanel and ImageDbTreePanel
 *
 * @param requester						parent component for dialog
 * @param selectableTreeVersionJPanel	component having a JTree user can select to define a VersionInfo
 * @param okString						label for button user presses when selection complete
 * @param dialogTitle					string displayed at top of dialog
 * @return	VersionInfo					identifies a particular VCell document
 * @throws UserCancelException
 * @throws IllegalArgumentException
 */
public static VersionInfo getDBTreePanelSelection(Component requester, SelectableTreeVersionJPanel selectableTreeVersionJPanel, String okString, String dialogTitle) throws UserCancelException, IllegalArgumentException {
    if (!(selectableTreeVersionJPanel instanceof JPanel)) {
        throw new IllegalArgumentException("selectableTreeVersionJPanel must be of type JPanel");
    }
    final MouseListener[] mouseListener = new MouseListener[] { null };
    // final JTree[] listenToJTree = new JTree[] {null};
    try {
        JPanel defaultSizedJPanel = new JPanel();
        defaultSizedJPanel.setLayout(new BorderLayout());
        defaultSizedJPanel.add((JPanel) selectableTreeVersionJPanel, BorderLayout.CENTER);
        Dimension dim = new Dimension(300, 400);
        defaultSizedJPanel.setPreferredSize(dim);
        defaultSizedJPanel.setMinimumSize(dim);
        defaultSizedJPanel.setMaximumSize(dim);
        String result = DialogUtils.showOptionsDialog(requester, defaultSizedJPanel, JOptionPane.PLAIN_MESSAGE, new String[] { okString, getCancelText() }, okString, new DialogUtils.OKEnabler() {

            @Override
            public void setJOptionPane(JOptionPane joptionPane) {
                DialogUtils.setInternalNotCancelEnabled(joptionPane, selectableTreeVersionJPanel.getSelectedVersionInfo() != null, false);
                mouseListener[0] = new MouseAdapter() {

                    public void mousePressed(MouseEvent e) {
                        Component parentComponent = (Component) e.getSource();
                        while (parentComponent != selectableTreeVersionJPanel && parentComponent.getParent() != null) {
                            parentComponent = parentComponent.getParent();
                        }
                        if (parentComponent == selectableTreeVersionJPanel) {
                            if (selectableTreeVersionJPanel.getSelectedVersionInfo() != null) {
                                if (e.getClickCount() == 2) {
                                    // enable OK and click OK button
                                    DialogUtils.setInternalNotCancelEnabled(joptionPane, true, true);
                                } else {
                                    // enable OK button
                                    DialogUtils.setInternalNotCancelEnabled(joptionPane, true, false);
                                }
                            } else {
                                // disable OK button
                                DialogUtils.setInternalNotCancelEnabled(joptionPane, false, false);
                            }
                        }
                    }
                };
                selectableTreeVersionJPanel.addJTreeSelectionMouseListener(mouseListener[0]);
            }
        }, dialogTitle);
        if (result == null || !result.equals(okString)) {
            throw UserCancelException.CANCEL_GENERIC;
        }
        return selectableTreeVersionJPanel.getSelectedVersionInfo();
    } finally {
        selectableTreeVersionJPanel.removeJTreeSelectionMouseListener(mouseListener[0]);
    }
}
Also used : JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) Dimension(java.awt.Dimension) JOptionPane(javax.swing.JOptionPane) MouseListener(java.awt.event.MouseListener) BorderLayout(java.awt.BorderLayout) Component(java.awt.Component)

Example 57 with MouseListener

use of java.awt.event.MouseListener in project vcell by virtualcell.

the class AnnotationsPanel method getJTreeMIRIAM.

private JTree getJTreeMIRIAM() {
    if (jTreeMIRIAM == null) {
        try {
            DefaultTreeSelectionModel ivjLocalSelectionModel;
            ivjLocalSelectionModel = new DefaultTreeSelectionModel();
            ivjLocalSelectionModel.setSelectionMode(1);
            jTreeMIRIAM = new JTree();
            jTreeMIRIAM.setName("JTree1");
            jTreeMIRIAM.setToolTipText("");
            jTreeMIRIAM.setBounds(0, 0, 357, 405);
            jTreeMIRIAM.setMinimumSize(new java.awt.Dimension(100, 72));
            jTreeMIRIAM.setSelectionModel(ivjLocalSelectionModel);
            jTreeMIRIAM.setRowHeight(0);
            jTreeMIRIAM.setRootVisible(false);
            // Add cellRenderer
            DefaultTreeCellRenderer dtcr = new BioModelCellRenderer(null) {

                @Override
                public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
                    // default for LinkNode is in BioModelCellRenderer.java
                    JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
                    // TODO: here
                    component.setIcon(null);
                    return component;
                }
            };
            jTreeMIRIAM.setCellRenderer(dtcr);
            MouseListener mouseListener = new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    super.mouseClicked(e);
                // TreePath closestMousePath =jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
                // showPopup(e, closestMousePath);
                }

                @Override
                public void mouseReleased(MouseEvent e) {
                    super.mouseReleased(e);
                // TreePath closestMousePath =jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
                // showPopup(e,closestMousePath);
                }

                public void mousePressed(MouseEvent e) {
                    TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
                    jTreeMIRIAM.setSelectionPath(closestMousePath);
                    // showPopup(e,closestMousePath);
                    if (e.getClickCount() == 2) {
                        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTreeMIRIAM.getLastSelectedPathComponent();
                        if (node instanceof LinkNode) {
                            showBrowseToLink((LinkNode) node);
                        }
                    }
                }
            };
            jTreeMIRIAM.addMouseListener(mouseListener);
        } catch (java.lang.Throwable ivjExc) {
            ivjExc.printStackTrace(System.out);
        }
    }
    return jTreeMIRIAM;
}
Also used : MouseEvent(java.awt.event.MouseEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) JTree(javax.swing.JTree) Dimension(java.awt.Dimension) MouseListener(java.awt.event.MouseListener) DefaultTreeSelectionModel(javax.swing.tree.DefaultTreeSelectionModel) TreePath(javax.swing.tree.TreePath) BioModelCellRenderer(cbit.vcell.desktop.BioModelCellRenderer) LinkNode(cbit.vcell.xml.gui.MiriamTreeModel.LinkNode) BioPaxObject(org.vcell.pathway.BioPaxObject)

Example 58 with MouseListener

use of java.awt.event.MouseListener in project vcell by virtualcell.

the class MIRIAMAnnotationEditor method getJTreeMIRIAM.

private JTree getJTreeMIRIAM() {
    if (jTreeMIRIAM == null) {
        try {
            DefaultTreeSelectionModel ivjLocalSelectionModel;
            ivjLocalSelectionModel = new DefaultTreeSelectionModel();
            ivjLocalSelectionModel.setSelectionMode(1);
            jTreeMIRIAM = new JTree();
            jTreeMIRIAM.setName("JTree1");
            jTreeMIRIAM.setToolTipText("");
            jTreeMIRIAM.setBounds(0, 0, 357, 405);
            jTreeMIRIAM.setMinimumSize(new java.awt.Dimension(100, 72));
            jTreeMIRIAM.setSelectionModel(ivjLocalSelectionModel);
            jTreeMIRIAM.setRowHeight(0);
            // Add cellRenderer
            DefaultTreeCellRenderer dtcr = new BioModelCellRenderer(null) {

                @Override
                public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
                    // System.out.println(MIRIAMAnnotationEditor.this.getClass().getName()+".getJTreeMiriam():BioModelCellRenderer  "+value.getClass()+" "+
                    // (value instanceof cbit.vcell.desktop.BioModelNode?
                    // ((cbit.vcell.desktop.BioModelNode)value).getUserObject().getClass():""));
                    JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
                    if (value instanceof BioModelNode && ((BioModelNode) value).getUserObject() instanceof Annotation) {
                        component.setToolTipText("(Double-click to edit notes)");
                        Annotation annotation = (Annotation) ((BioModelNode) value).getUserObject();
                        if (annotation.toString() == null || annotation.toString().length() == 0) {
                            component.setText("(Double-click to edit notes)");
                        }
                    }
                    return component;
                }
            };
            jTreeMIRIAM.setCellRenderer(dtcr);
            MouseListener mouseListener = new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    // TODO Auto-generated method stub
                    super.mouseClicked(e);
                    TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
                    showPopup(e, closestMousePath);
                }

                @Override
                public void mouseReleased(MouseEvent e) {
                    // TODO Auto-generated method stub
                    super.mouseReleased(e);
                    TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
                    showPopup(e, closestMousePath);
                }

                public void mousePressed(MouseEvent e) {
                    TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
                    jTreeMIRIAM.setSelectionPath(closestMousePath);
                    showPopup(e, closestMousePath);
                    if (e.getClickCount() == 2) {
                        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTreeMIRIAM.getLastSelectedPathComponent();
                        if (node instanceof LinkNode) {
                            showBrowseToLink((LinkNode) node);
                        } else if (isNodeFreeHandTextEditable(node)) {
                            showEditFreehandText(node);
                        }
                    }
                }
            };
            jTreeMIRIAM.addMouseListener(mouseListener);
        } catch (java.lang.Throwable ivjExc) {
            ivjExc.printStackTrace(System.out);
        }
    }
    return jTreeMIRIAM;
}
Also used : MouseEvent(java.awt.event.MouseEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) BioModelNode(cbit.vcell.desktop.BioModelNode) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) Annotation(cbit.vcell.desktop.Annotation) JTree(javax.swing.JTree) Dimension(java.awt.Dimension) MouseListener(java.awt.event.MouseListener) DefaultTreeSelectionModel(javax.swing.tree.DefaultTreeSelectionModel) TreePath(javax.swing.tree.TreePath) BioModelCellRenderer(cbit.vcell.desktop.BioModelCellRenderer) LinkNode(cbit.vcell.xml.gui.MiriamTreeModel.LinkNode)

Example 59 with MouseListener

use of java.awt.event.MouseListener in project vcell by virtualcell.

the class BioModelParametersPanel method initialize.

private void initialize() {
    addNewButton = new JButton("New Global Parameter");
    addNewButton.addActionListener(eventHandler);
    addNewButton2 = new JButton("New Application Parameter");
    // addNewButton2.setIcon(downArrow);
    addNewButton2.setHorizontalTextPosition(SwingConstants.LEFT);
    addNewButton2.addActionListener(eventHandler);
    deleteButton = new JButton("Delete");
    deleteButton.setEnabled(false);
    deleteButton.addActionListener(eventHandler);
    changeUnitsButton = new JButton("Change Unit System");
    changeUnitsButton.addActionListener(eventHandler);
    textFieldSearch = new JTextField(10);
    textFieldSearch.getDocument().addDocumentListener(eventHandler);
    textFieldSearch.putClientProperty("JTextField.variant", "search");
    parametersFunctionsTable = new EditorScrollTable();
    parametersFunctionsTableModel = new BioModelParametersTableModel(parametersFunctionsTable);
    parametersFunctionsTable.setModel(parametersFunctionsTableModel);
    globalParametersCheckBox = new JCheckBox("Global");
    globalParametersCheckBox.setSelected(true);
    globalParametersCheckBox.addActionListener(eventHandler);
    reactionsCheckBox = new JCheckBox("Reactions and Rules");
    reactionsCheckBox.setSelected(true);
    reactionsCheckBox.addActionListener(eventHandler);
    applicationsCheckBox = new JCheckBox("Applications");
    applicationsCheckBox.setSelected(true);
    applicationsCheckBox.addActionListener(eventHandler);
    applicationComboBox = new JComboBox<ApplicationSelection>();
    applicationComboBox.setSelectedItem("All");
    applicationComboBox.addActionListener(eventHandler);
    applicationComboBox.setModel(applicationComboBoxModel);
    applicationComboBox.setRenderer(new ApplicationComboBoxRenderer());
    constantsCheckBox = new JCheckBox("Parameters");
    constantsCheckBox.setSelected(true);
    constantsCheckBox.addActionListener(eventHandler);
    functionsCheckBox = new JCheckBox("Functions");
    functionsCheckBox.setSelected(true);
    functionsCheckBox.addActionListener(eventHandler);
    predefinedSymbolsTable = new EditorScrollTable();
    predefinedSymbolsTableModel = new PredefinedSymbolsTableModel(predefinedSymbolsTable);
    predefinedSymbolsTable.setModel(predefinedSymbolsTableModel);
    GuiUtils.flexResizeTableColumns(predefinedSymbolsTable);
    modelUnitSystemTable = new EditorScrollTable();
    modelUnitSystemTableModel = new ModelUnitSystemTableModel(modelUnitSystemTable);
    modelUnitSystemTable.setModel(modelUnitSystemTableModel);
    GuiUtils.flexResizeTableColumns(modelUnitSystemTable);
    tabbedPane = new JTabbedPaneEnhanced();
    tabbedPane.addChangeListener(eventHandler);
    ParametersPanelTab[] parametersPanelTabs = new ParametersPanelTab[ParametersPanelTabID.values().length];
    parametersPanelTabs[ParametersPanelTabID.parameters_functions.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.parameters_functions, getParametersFunctionsPanel(), null);
    parametersPanelTabs[ParametersPanelTabID.predefined.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.predefined, getPredefinedSymbolsPanel(), null);
    parametersPanelTabs[ParametersPanelTabID.modelUnitSystem.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.modelUnitSystem, getModelUnitSystemPanel(), null);
    for (ParametersPanelTab tab : parametersPanelTabs) {
        tab.component.setBorder(GuiConstants.TAB_PANEL_BORDER);
        tabbedPane.addTab(tab.id.title, tab.icon, tab.component);
    }
    JPanel buttonPanel = new JPanel(new GridBagLayout());
    int gridy = 0;
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(addNewButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(addNewButton2, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(deleteButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(changeUnitsButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    gbc.insets = new Insets(4, 50, 4, 4);
    buttonPanel.add(new JLabel("Search"), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.gridy = gridy;
    gbc.weightx = 1.0;
    gbc.gridwidth = 2;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(4, 4, 4, 4);
    buttonPanel.add(textFieldSearch, gbc);
    setLayout(new BorderLayout());
    add(tabbedPane, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
    parametersFunctionsTable.getSelectionModel().addListSelectionListener(eventHandler);
    parametersFunctionsTable.setDefaultRenderer(NameScope.class, new DefaultScrollTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (value instanceof NameScope) {
                NameScope nameScope = (NameScope) value;
                String text = nameScope.getPathDescription();
                setText(text);
            }
            return this;
        }
    });
    DefaultScrollTableCellRenderer nameTableCellRenderer = new DefaultScrollTableCellRenderer() {

        final Color lightBlueBackground = new Color(214, 234, 248);

        int PADDING = 3;

        @Override
        public void setBounds(int x, int y, int width, int height) {
            super.setBounds(x, y, width, height);
            if (getIcon() != null) {
                int textWidth = getFontMetrics(getFont()).stringWidth(getText());
                Insets insets = getInsets();
                // TODO: check that the text width is not bigger than the cell width and truncate the name
                int iconTextGap = width - textWidth - getIcon().getIconWidth() - insets.left - insets.right - PADDING;
                setIconTextGap(iconTextGap);
            } else {
                setIconTextGap(0);
            }
        }

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (table.getModel() instanceof BioModelParametersTableModel) {
                BioModelParametersTableModel tableModel = (BioModelParametersTableModel) table.getModel();
                Object selectedObject = tableModel.getValueAt(row);
                setToolTipText(null);
                if (selectedObject instanceof ModelParameter || selectedObject instanceof SpeciesContext) {
                    SymbolTableEntry ste = (SymbolTableEntry) selectedObject;
                    RateRule rr = null;
                    AssignmentRule ar = null;
                    for (SimulationContext simContext : bioModel.getSimulationContexts()) {
                        rr = simContext.getRateRule(ste);
                        ar = simContext.getAssignmentRule(ste);
                        if (rr != null || ar != null) {
                            break;
                        }
                    }
                    Icon icon = null;
                    if (rr != null) {
                        String text = "<html>The default value of this entity is being overriden by a Rate Rule in one or more applications</html>";
                        icon = VCellIcons.ruleRateIcon;
                        setToolTipText(text);
                    } else if (ar != null) {
                        String text = "<html>The default value of this entity is being overriden by an Assignment Rule in one or more applications</html>";
                        icon = VCellIcons.ruleAssignIcon;
                        setToolTipText(text);
                    }
                    setIcon(icon);
                    this.setHorizontalTextPosition(SwingConstants.LEFT);
                    if (isSelected) {
                        setBackground(lightBlueBackground);
                        setForeground(Color.BLACK);
                    }
                }
            }
            return this;
        }
    };
    parametersFunctionsTable.getColumnModel().getColumn(BioModelParametersTableModel.COLUMN_NAME).setCellRenderer(nameTableCellRenderer);
    {
        // make double click on units panel bring up editing box
        JPanel p = getModelUnitSystemPanel();
        VCAssert.assertValid(p);
        EditorScrollTable est = GuiUtils.findFirstChild(p, EditorScrollTable.class);
        VCAssert.assertValid(est);
        MouseListener ml = new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    changeUnitsButtonPressed();
                }
            }
        };
        est.addMouseListener(ml);
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) SpeciesContext(cbit.vcell.model.SpeciesContext) JTextField(javax.swing.JTextField) JTabbedPaneEnhanced(org.vcell.util.gui.JTabbedPaneEnhanced) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) EditableSymbolTableEntry(cbit.vcell.model.EditableSymbolTableEntry) MouseListener(java.awt.event.MouseListener) BorderLayout(java.awt.BorderLayout) RateRule(cbit.vcell.mapping.RateRule) Component(java.awt.Component) JComponent(javax.swing.JComponent) MouseEvent(java.awt.event.MouseEvent) NameScope(cbit.vcell.parser.NameScope) AssignmentRule(cbit.vcell.mapping.AssignmentRule) Color(java.awt.Color) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) SimulationContext(cbit.vcell.mapping.SimulationContext) JCheckBox(javax.swing.JCheckBox) ModelParameter(cbit.vcell.model.Model.ModelParameter) JTable(javax.swing.JTable) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) EditorScrollTable(org.vcell.util.gui.EditorScrollTable) Icon(javax.swing.Icon) DownArrowIcon(org.vcell.util.gui.DownArrowIcon)

Example 60 with MouseListener

use of java.awt.event.MouseListener in project vcell by virtualcell.

the class EditorPalette method addTemplate.

/**
 * @param name
 * @param icon
 * @param cell
 */
public void addTemplate(final String name, ImageIcon icon, mxCell cell) {
    mxRectangle bounds = (mxGeometry) cell.getGeometry().clone();
    final mxGraphTransferable t = new mxGraphTransferable(new Object[] { cell }, bounds);
    // Scales the image if it's too large for the library
    if (icon != null) {
        if (icon.getIconWidth() > 32 || icon.getIconHeight() > 32) {
            icon = new ImageIcon(icon.getImage().getScaledInstance(32, 32, 0));
        }
    }
    final JLabel entry = new JLabel(icon);
    entry.setPreferredSize(new Dimension(50, 50));
    entry.setBackground(EditorPalette.this.getBackground().brighter());
    entry.setFont(new Font(entry.getFont().getFamily(), 0, 10));
    entry.setVerticalTextPosition(JLabel.BOTTOM);
    entry.setHorizontalTextPosition(JLabel.CENTER);
    entry.setIconTextGap(0);
    entry.setToolTipText(name);
    entry.setText(name);
    entry.addMouseListener(new MouseListener() {

        /*
			 * (non-Javadoc)
			 * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
			 */
        public void mousePressed(MouseEvent e) {
            setSelectionEntry(entry, t);
        }

        /*
			 * (non-Javadoc)
			 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
			 */
        public void mouseClicked(MouseEvent e) {
        }

        /*
			 * (non-Javadoc)
			 * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
			 */
        public void mouseEntered(MouseEvent e) {
        }

        /*
			 * (non-Javadoc)
			 * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
			 */
        public void mouseExited(MouseEvent e) {
        }

        /*
			 * (non-Javadoc)
			 * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
			 */
        public void mouseReleased(MouseEvent e) {
        }
    });
    // Install the handler for dragging nodes into a graph
    DragGestureListener dragGestureListener = new DragGestureListener() {

        /**
         */
        public void dragGestureRecognized(DragGestureEvent e) {
            e.startDrag(null, mxSwingConstants.EMPTY_IMAGE, new Point(), t, null);
        }
    };
    DragSource dragSource = new DragSource();
    dragSource.createDefaultDragGestureRecognizer(entry, DnDConstants.ACTION_COPY, dragGestureListener);
    add(entry);
}
Also used : ImageIcon(javax.swing.ImageIcon) MouseEvent(java.awt.event.MouseEvent) DragGestureEvent(java.awt.dnd.DragGestureEvent) DragGestureListener(java.awt.dnd.DragGestureListener) com.mxgraph.model.mxGeometry(com.mxgraph.model.mxGeometry) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Point(java.awt.Point) com.mxgraph.util.mxPoint(com.mxgraph.util.mxPoint) DragSource(java.awt.dnd.DragSource) Font(java.awt.Font) com.mxgraph.util.mxRectangle(com.mxgraph.util.mxRectangle) MouseListener(java.awt.event.MouseListener) com.mxgraph.swing.util.mxGraphTransferable(com.mxgraph.swing.util.mxGraphTransferable)

Aggregations

MouseListener (java.awt.event.MouseListener)104 MouseEvent (java.awt.event.MouseEvent)67 Dimension (java.awt.Dimension)21 JLabel (javax.swing.JLabel)20 MouseAdapter (java.awt.event.MouseAdapter)19 JPanel (javax.swing.JPanel)16 Component (java.awt.Component)14 JComponent (javax.swing.JComponent)14 ActionEvent (java.awt.event.ActionEvent)13 ActionListener (java.awt.event.ActionListener)11 MouseMotionListener (java.awt.event.MouseMotionListener)11 JButton (javax.swing.JButton)11 JScrollPane (javax.swing.JScrollPane)11 Insets (java.awt.Insets)8 BorderLayout (java.awt.BorderLayout)7 Color (java.awt.Color)7 Point (java.awt.Point)7 File (java.io.File)7 ImageIcon (javax.swing.ImageIcon)6 JCheckBox (javax.swing.JCheckBox)6