Search in sources :

Example 1 with BioModelCellRenderer

use of cbit.vcell.desktop.BioModelCellRenderer 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 2 with BioModelCellRenderer

use of cbit.vcell.desktop.BioModelCellRenderer in project vcell by virtualcell.

the class ApplicationPropertiesPanel method initialize.

/**
 * Initialize the class.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initialize() {
    try {
        setName(this.getClass().getName());
        setLayout(new GridBagLayout());
        nameTextField = new JTextField();
        nameTextField.addActionListener(eventHandler);
        nameTextField.addFocusListener(eventHandler);
        annotationTextArea = new javax.swing.JTextArea("", 1, 30);
        annotationTextArea.setLineWrap(true);
        annotationTextArea.setWrapStyleWord(true);
        annotationTextArea.addFocusListener(eventHandler);
        annotationTextArea.addMouseListener(eventHandler);
        tree = new JTree();
        treeModel = new ApplicationPropertiesTreeModel();
        tree.setModel(treeModel);
        ToolTipManager.sharedInstance().registerComponent(tree);
        tree.setCellRenderer(new BioModelCellRenderer(null));
        tree.setRootVisible(false);
        int gridy = 0;
        GridBagConstraints gbc = new java.awt.GridBagConstraints();
        gbc = new java.awt.GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.insets = new Insets(4, 4, 4, 4);
        gbc.anchor = GridBagConstraints.LINE_END;
        JLabel label = new JLabel("Application Name");
        add(label, gbc);
        gbc.gridx = 1;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        gbc.insets = new Insets(4, 4, 4, 4);
        gbc.anchor = GridBagConstraints.LINE_START;
        add(nameTextField, gbc);
        gridy++;
        gbc = new java.awt.GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.insets = new Insets(4, 4, 4, 4);
        gbc.anchor = GridBagConstraints.FIRST_LINE_END;
        add(new JLabel("Annotation"), gbc);
        gbc = new java.awt.GridBagConstraints();
        gbc.weightx = 1.0;
        gbc.weighty = 0.3;
        gbc.gridx = 1;
        gbc.gridy = gridy;
        gbc.anchor = GridBagConstraints.LINE_START;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        gbc.insets = new Insets(4, 4, 4, 4);
        add(new javax.swing.JScrollPane(annotationTextArea), gbc);
        gridy++;
        gbc = new java.awt.GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.insets = new Insets(4, 4, 4, 4);
        gbc.anchor = GridBagConstraints.FIRST_LINE_END;
        add(new JLabel("Summary"), gbc);
        gbc = new java.awt.GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = gridy;
        gbc.weighty = 1.0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(4, 4, 4, 4);
        add(new JScrollPane(tree), gbc);
    } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
    }
// user code begin {2}
// user code end
}
Also used : JScrollPane(javax.swing.JScrollPane) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) GridBagConstraints(java.awt.GridBagConstraints) JScrollPane(javax.swing.JScrollPane) JTree(javax.swing.JTree) BioModelCellRenderer(cbit.vcell.desktop.BioModelCellRenderer) JTextArea(javax.swing.JTextArea)

Aggregations

BioModelCellRenderer (cbit.vcell.desktop.BioModelCellRenderer)2 JLabel (javax.swing.JLabel)2 JTree (javax.swing.JTree)2 Annotation (cbit.vcell.desktop.Annotation)1 BioModelNode (cbit.vcell.desktop.BioModelNode)1 LinkNode (cbit.vcell.xml.gui.MiriamTreeModel.LinkNode)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 MouseListener (java.awt.event.MouseListener)1 JScrollPane (javax.swing.JScrollPane)1 JTextArea (javax.swing.JTextArea)1 JTextField (javax.swing.JTextField)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 DefaultTreeCellRenderer (javax.swing.tree.DefaultTreeCellRenderer)1 DefaultTreeSelectionModel (javax.swing.tree.DefaultTreeSelectionModel)1 TreePath (javax.swing.tree.TreePath)1