Search in sources :

Example 61 with TitledBorder

use of javax.swing.border.TitledBorder in project vcell by virtualcell.

the class ResultDisplayPanel method getTablePanel.

private JPanel getTablePanel() {
    if (tablePanel == null) {
        final GridBagLayout gridBagLayout = new GridBagLayout();
        gridBagLayout.rowHeights = new int[] { 0, 0, 0, 7, 7 };
        tablePanel = new JPanel(gridBagLayout);
        // new Color(153, 186,243)
        tablePanel.setBorder(new TitledBorder(new LineBorder(new Color(153, 186, 243), 1), "Best Parameters"));
        JScrollPane tableScroll = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        tableScroll.setName("");
        tableScroll.setViewportView(getRestultTable());
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.ipady = 235;
        gridBagConstraints1.ipadx = 300;
        gridBagConstraints1.gridheight = 3;
        gridBagConstraints1.insets = new Insets(0, 5, 0, 5);
        gridBagConstraints1.gridx = 0;
        gridBagConstraints1.gridy = 0;
        // gridBagConstraints1.ipady = 0;
        // gridBagConstraints1.ipadx = 0;
        gridBagConstraints1.anchor = GridBagConstraints.WEST;
        tablePanel.add(tableScroll, gridBagConstraints1);
    }
    return tablePanel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) LineBorder(javax.swing.border.LineBorder) Color(java.awt.Color) TitledBorder(javax.swing.border.TitledBorder)

Example 62 with TitledBorder

use of javax.swing.border.TitledBorder in project vcell by virtualcell.

the class DefineROI_SummaryPanel method getInfoPanel.

public JPanel getInfoPanel() {
    if (infoPanel == null) {
        final GridBagLayout gridBagLayout = new GridBagLayout();
        gridBagLayout.rowHeights = new int[] { 0, 7, 7, 7 };
        gridBagLayout.columnWidths = new int[] { 7, 7, 7, 0, 0, 7, 7, 7, 0, 0, 7 };
        infoPanel = new JPanel(gridBagLayout);
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.anchor = GridBagConstraints.WEST;
        gridBagConstraints1.gridy = 0;
        gridBagConstraints1.gridx = 1;
        infoPanel.add(new JLabel("Image size after cropping: "), gridBagConstraints1);
        final JLabel eTimeLabel = new JLabel();
        eTimeLabel.setText("Image size X");
        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.anchor = GridBagConstraints.EAST;
        gridBagConstraints3.gridy = 0;
        gridBagConstraints3.gridx = 5;
        infoPanel.add(eTimeLabel, gridBagConstraints3);
        imgXTextField = new JTextField(12);
        final GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridx = 7;
        infoPanel.add(imgXTextField, gridBagConstraints);
        final JLabel sLabel2 = new JLabel();
        sLabel2.setText("um");
        final GridBagConstraints gridBagConstraints_8 = new GridBagConstraints();
        gridBagConstraints_8.gridy = 0;
        gridBagConstraints_8.gridx = 9;
        infoPanel.add(sLabel2, gridBagConstraints_8);
        final JLabel eTimeLabel_1 = new JLabel();
        eTimeLabel_1.setText("Image size Y");
        final GridBagConstraints gridBagConstraints_2 = new GridBagConstraints();
        gridBagConstraints_2.gridy = 1;
        gridBagConstraints_2.gridx = 5;
        infoPanel.add(eTimeLabel_1, gridBagConstraints_2);
        imgYTextField = new JTextField();
        imgYTextField.setColumns(12);
        final GridBagConstraints gridBagConstraints_4 = new GridBagConstraints();
        gridBagConstraints_4.gridy = 1;
        gridBagConstraints_4.gridx = 7;
        infoPanel.add(imgYTextField, gridBagConstraints_4);
        final JLabel sLabel2_1 = new JLabel();
        sLabel2_1.setText("um");
        final GridBagConstraints gridBagConstraints_3 = new GridBagConstraints();
        gridBagConstraints_3.gridy = 1;
        gridBagConstraints_3.gridx = 9;
        infoPanel.add(sLabel2_1, gridBagConstraints_3);
        final JLabel cellAreaRoiLabel = new JLabel();
        cellAreaRoiLabel.setText("Cell area ROI: ");
        final GridBagConstraints gridBagConstraints_5 = new GridBagConstraints();
        gridBagConstraints_5.anchor = GridBagConstraints.EAST;
        gridBagConstraints_5.gridy = 3;
        gridBagConstraints_5.gridx = 1;
        infoPanel.add(cellAreaRoiLabel, gridBagConstraints_5);
        cellROIDefined = new JCheckBox();
        cellROIDefined.setText("Defined");
        final GridBagConstraints gridBagConstraints_6 = new GridBagConstraints();
        gridBagConstraints_6.anchor = GridBagConstraints.WEST;
        gridBagConstraints_6.gridy = 3;
        gridBagConstraints_6.gridx = 5;
        infoPanel.add(cellROIDefined, gridBagConstraints_6);
        cellROIUndefined = new JCheckBox();
        cellROIUndefined.setText("Not Defined");
        final GridBagConstraints gridBagConstraints_7 = new GridBagConstraints();
        gridBagConstraints_7.anchor = GridBagConstraints.WEST;
        gridBagConstraints_7.gridy = 3;
        gridBagConstraints_7.gridx = 7;
        infoPanel.add(cellROIUndefined, gridBagConstraints_7);
        final JLabel bleachedRoiLabel = new JLabel();
        bleachedRoiLabel.setText("Bleached ROI: ");
        final GridBagConstraints gridBagConstraints_9 = new GridBagConstraints();
        gridBagConstraints_9.anchor = GridBagConstraints.EAST;
        gridBagConstraints_9.gridy = 4;
        gridBagConstraints_9.gridx = 1;
        infoPanel.add(bleachedRoiLabel, gridBagConstraints_9);
        bleachROIDefined = new JCheckBox();
        bleachROIDefined.setText("Defined");
        final GridBagConstraints gridBagConstraints_10 = new GridBagConstraints();
        gridBagConstraints_10.anchor = GridBagConstraints.WEST;
        gridBagConstraints_10.gridy = 4;
        gridBagConstraints_10.gridx = 5;
        infoPanel.add(bleachROIDefined, gridBagConstraints_10);
        bleachROIUndefined = new JCheckBox();
        bleachROIUndefined.setText("Not Defined");
        final GridBagConstraints gridBagConstraints_11 = new GridBagConstraints();
        gridBagConstraints_11.anchor = GridBagConstraints.WEST;
        gridBagConstraints_11.gridy = 4;
        gridBagConstraints_11.gridx = 7;
        infoPanel.add(bleachROIUndefined, gridBagConstraints_11);
        final JLabel backgroundRoiLabel = new JLabel();
        backgroundRoiLabel.setText("Background ROI: ");
        final GridBagConstraints gridBagConstraints_12 = new GridBagConstraints();
        gridBagConstraints_12.anchor = GridBagConstraints.EAST;
        gridBagConstraints_12.gridy = 5;
        gridBagConstraints_12.gridx = 1;
        infoPanel.add(backgroundRoiLabel, gridBagConstraints_12);
        bgROIDefined = new JCheckBox();
        bgROIDefined.setText("Defined");
        final GridBagConstraints gridBagConstraints_13 = new GridBagConstraints();
        gridBagConstraints_13.anchor = GridBagConstraints.WEST;
        gridBagConstraints_13.gridy = 5;
        gridBagConstraints_13.gridx = 5;
        infoPanel.add(bgROIDefined, gridBagConstraints_13);
        bgROIUndefined = new JCheckBox();
        bgROIUndefined.setText("Not Defined");
        final GridBagConstraints gridBagConstraints_14 = new GridBagConstraints();
        gridBagConstraints_14.anchor = GridBagConstraints.WEST;
        gridBagConstraints_14.gridy = 5;
        gridBagConstraints_14.gridx = 7;
        infoPanel.add(bgROIUndefined, gridBagConstraints_14);
        infoPanel.setBorder(new TitledBorder(new LineBorder(new Color(153, 186, 243), 1), "Image & ROI Info"));
    }
    return infoPanel;
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) LineBorder(javax.swing.border.LineBorder) Color(java.awt.Color) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) TitledBorder(javax.swing.border.TitledBorder)

Example 63 with TitledBorder

use of javax.swing.border.TitledBorder in project vcell by virtualcell.

the class VFrap_OverlayEditorPanelJAI method getROIAssistBasePanel.

public JPanel getROIAssistBasePanel() {
    if (roiAssistBasePanel == null) {
        roiAssistBasePanel = new JPanel(new BorderLayout());
        JPanel buttonPanel = new JPanel(new BorderLayout());
        buttonPanel.add(getRoiAssistButton(), BorderLayout.WEST);
        roiAssistBasePanel.add(buttonPanel, BorderLayout.NORTH);
        roiAssistBasePanel.add(getROIAssistPanel(), BorderLayout.CENTER);
        // set border
        TitledBorder tb = new TitledBorder(new EtchedBorder(), "");
        roiAssistBasePanel.setBorder(tb);
    }
    return roiAssistBasePanel;
}
Also used : JPanel(javax.swing.JPanel) EtchedBorder(javax.swing.border.EtchedBorder) BorderLayout(java.awt.BorderLayout) TitledBorder(javax.swing.border.TitledBorder)

Example 64 with TitledBorder

use of javax.swing.border.TitledBorder in project vcell by virtualcell.

the class MolecularTypePropertiesPanel method initialize.

private void initialize() {
    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new GridBagLayout());
    // leftPanel.setBackground(Color.white);
    anchorPanel = new JAnchorPanel();
    anchorScrollPanel = new JScrollPane(anchorPanel);
    molecularTypeTree = new BioModelNodeEditableTree();
    molecularTypeTreeModel = new MolecularTypeTreeModel(molecularTypeTree);
    molecularTypeTree.setModel(molecularTypeTreeModel);
    molecularTypeTree.setEditable(true);
    molecularTypeTree.setCellRenderer(new RbmMolecularTypeTreeCellRenderer(molecularTypeTree, issueManager));
    molecularTypeTree.setCellEditor(new RbmMolecularTypeTreeCellEditor(molecularTypeTree));
    int rowHeight = molecularTypeTree.getRowHeight();
    if (rowHeight < 10) {
        rowHeight = 20;
    }
    molecularTypeTree.setRowHeight(rowHeight + 2);
    molecularTypeTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    ToolTipManager.sharedInstance().registerComponent(molecularTypeTree);
    molecularTypeTree.addTreeSelectionListener(eventHandler);
    molecularTypeTree.addTreeWillExpandListener(eventHandler);
    molecularTypeTree.addMouseListener(eventHandler);
    molecularTypeTree.setLargeModel(true);
    molecularTypeTree.setRootVisible(true);
    setLayout(new GridBagLayout());
    int gridy = 0;
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.weightx = 1.0;
    gbc.insets = new Insets(4, 4, 4, 4);
    titleLabel = new JLabel("Construct Solid Geometry");
    titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
    leftPanel.add(titleLabel, gbc);
    ButtonGroup bg = new ButtonGroup();
    bg.add(getAnchorAllButton());
    bg.add(getAnchorOnlyButton());
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    leftPanel.add(getAnchorAllButton(), gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    leftPanel.add(getAnchorOnlyButton(), gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.fill = GridBagConstraints.BOTH;
    leftPanel.add(anchorScrollPanel, gbc);
    // ------------------------------------------------------------------------------
    splitPaneHorizontal.setOneTouchExpandable(true);
    splitPaneHorizontal.setDividerLocation(120);
    splitPaneHorizontal.setResizeWeight(0.1);
    Border border = BorderFactory.createLineBorder(Color.gray);
    Border loweredEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
    TitledBorder annotationBorder = BorderFactory.createTitledBorder(loweredEtchedBorder, " Annotation and Pathway Links ");
    annotationBorder.setTitleJustification(TitledBorder.LEFT);
    annotationBorder.setTitlePosition(TitledBorder.TOP);
    annotationBorder.setTitleFont(getFont().deriveFont(Font.BOLD));
    shapePanel = new LargeShapePanel() {

        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            for (LargeShape stls : molecularTypeShapeList) {
                stls.paintSelf(g);
            }
        }

        @Override
        public DisplayMode getDisplayMode() {
            return DisplayMode.other;
        }

        @Override
        public RuleAnalysisChanged hasStateChanged(String reactionRuleName, MolecularComponentPattern molecularComponentPattern) {
            return RuleAnalysisChanged.UNCHANGED;
        }

        @Override
        public RuleAnalysisChanged hasStateChanged(MolecularComponentPattern molecularComponentPattern) {
            return RuleAnalysisChanged.UNCHANGED;
        }

        @Override
        public RuleAnalysisChanged hasBondChanged(String reactionRuleName, MolecularComponentPattern molecularComponentPattern) {
            return RuleAnalysisChanged.UNCHANGED;
        }

        @Override
        public RuleAnalysisChanged hasBondChanged(MolecularComponentPattern molecularComponentPattern) {
            return RuleAnalysisChanged.UNCHANGED;
        }

        @Override
        public RuleAnalysisChanged hasNoMatch(String reactionRuleName, MolecularTypePattern mtp) {
            return RuleAnalysisChanged.UNCHANGED;
        }

        @Override
        public RuleAnalysisChanged hasNoMatch(MolecularTypePattern molecularTypePattern) {
            return RuleAnalysisChanged.UNCHANGED;
        }

        @Override
        public boolean isViewSingleRow() {
            return true;
        }

        @Override
        public RuleParticipantSignature getSignature() {
            return null;
        }

        @Override
        public GroupingCriteria getCriteria() {
            return null;
        }
    };
    shapePanel.setBorder(border);
    shapePanel.setLayout(null);
    shapePanel.setBackground(Color.white);
    shapePanel.setEditable(true);
    shapePanel.setShowMoleculeColor(true);
    shapePanel.setShowNonTrivialOnly(true);
    shapePanel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            stopEditing();
            if (e.getButton() == 1) {
                // left click selects the object (we highlight it)
                Point whereClicked = e.getPoint();
                PointLocationInShapeContext locationContext = new PointLocationInShapeContext(whereClicked);
                manageMouseActivity(locationContext);
            } else if (e.getButton() == 3) {
                // right click invokes popup menu (only if the object is highlighted)
                Point whereClicked = e.getPoint();
                PointLocationInShapeContext locationContext = new PointLocationInShapeContext(whereClicked);
                manageMouseActivity(locationContext);
                if (locationContext.getDeepestShape() != null && !locationContext.getDeepestShape().isHighlighted()) {
                // TODO: (maybe) add code here to highlight the shape if it's not highlighted already but don't show the menu
                // return;
                }
                showPopupMenu(e, locationContext);
            }
        }

        private void manageMouseActivity(PointLocationInShapeContext locationContext) {
            Graphics g = shapePanel.getGraphics();
            for (MolecularTypeLargeShape mtls : molecularTypeShapeList) {
                mtls.turnHighlightOffRecursive(g);
            }
            for (MolecularTypeLargeShape mtls : molecularTypeShapeList) {
                if (mtls.contains(locationContext)) {
                    // check if mouse is inside shape
                    break;
                }
            }
            locationContext.highlightDeepestShape();
            locationContext.paintDeepestShape(g);
        }
    });
    shapePanel.addMouseMotionListener(new MouseMotionAdapter() {

        public void mouseMoved(MouseEvent e) {
            Point overWhat = e.getPoint();
            PointLocationInShapeContext locationContext = new PointLocationInShapeContext(overWhat);
            for (MolecularTypeLargeShape mtls : molecularTypeShapeList) {
                if (mtls.contains(locationContext)) {
                    break;
                }
            }
            HighlightableShapeInterface hsi = locationContext.getDeepestShape();
            if (hsi == null) {
                shapePanel.setToolTipText(null);
            } else {
                shapePanel.setToolTipText("Right click for " + hsi.getDisplayType() + " menus");
            }
            for (MolecularTypeLargeShape mtls : molecularTypeShapeList) {
                Rectangle r = mtls.getAnchorHotspot();
                if (r != null && r.contains(overWhat)) {
                    mtls.getMolecularType();
                    shapePanel.setToolTipText(mtls.getAnchorsHTML());
                    break;
                }
            }
        }
    });
    // -------------------------------------------------------------------------------------------
    // right bottom panel, contains just the annotation
    JPanel generalPanel = new JPanel();
    generalPanel.setBorder(annotationBorder);
    generalPanel.setLayout(new GridBagLayout());
    gridy = 0;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.LINE_START;
    JLabel pathwayLink = new JLabel("Linked Pathway Object(s): ");
    generalPanel.add(pathwayLink, gbc);
    linkedPOScrollPane = new JScrollPane();
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(4, 4, 4, 4);
    generalPanel.add(linkedPOScrollPane, gbc);
    gridy++;
    // annotationTextArea = new javax.swing.JTextArea("", 1, 30);
    // annotationTextArea.setLineWrap(true);
    // annotationTextArea.setWrapStyleWord(true);
    // annotationTextArea.setFont(new Font("monospaced", Font.PLAIN, 11));
    annotationTextArea = new JTextPane();
    annotationTextArea.setContentType("text/html");
    annotationTextArea.setEditable(false);
    javax.swing.JScrollPane jsp = new javax.swing.JScrollPane(annotationTextArea);
    gbc = new java.awt.GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 2;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = java.awt.GridBagConstraints.BOTH;
    gbc.insets = new Insets(4, 4, 4, 4);
    generalPanel.add(jsp, gbc);
    scrollPane = new JScrollPane(shapePanel);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    splitPaneHorizontal.setTopComponent(scrollPane);
    splitPaneHorizontal.setBottomComponent(generalPanel);
    // -----------------------------------------------------------------------------
    splitPane.setOneTouchExpandable(true);
    splitPane.setLeftComponent(leftPanel);
    splitPane.setRightComponent(splitPaneHorizontal);
    splitPane.setResizeWeight(0.0);
    splitPane.getLeftComponent().setMaximumSize(new Dimension(120, 200));
    splitPane.getLeftComponent().setPreferredSize(new Dimension(120, 200));
    // splitPane.setDividerLocation(0.0d);		// completely hides the left component
    // attempt to use the preferred size
    splitPane.setDividerLocation(-1);
    setName("MolecularTypePropertiesPanel");
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
    setBackground(Color.white);
    annotationTextArea.addFocusListener(eventHandler);
    annotationTextArea.addMouseListener(eventHandler);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) RuleParticipantSignature(cbit.vcell.model.RuleParticipantSignature) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Rectangle(java.awt.Rectangle) TitledBorder(javax.swing.border.TitledBorder) LargeShapePanel(cbit.vcell.graph.gui.LargeShapePanel) JTextPane(javax.swing.JTextPane) MolecularTypeLargeShape(cbit.vcell.graph.MolecularTypeLargeShape) BorderLayout(java.awt.BorderLayout) RuleAnalysisChanged(cbit.vcell.graph.ReactionCartoon.RuleAnalysisChanged) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) GroupingCriteria(cbit.vcell.model.GroupingCriteria) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) HighlightableShapeInterface(cbit.vcell.graph.HighlightableShapeInterface) Point(java.awt.Point) Dimension(java.awt.Dimension) PointLocationInShapeContext(cbit.vcell.graph.PointLocationInShapeContext) GridBagConstraints(java.awt.GridBagConstraints) Point(java.awt.Point) Graphics(java.awt.Graphics) JScrollPane(javax.swing.JScrollPane) MouseMotionAdapter(java.awt.event.MouseMotionAdapter) ButtonGroup(javax.swing.ButtonGroup) MolecularTypeLargeShape(cbit.vcell.graph.MolecularTypeLargeShape) SpeciesPatternLargeShape(cbit.vcell.graph.SpeciesPatternLargeShape) ComponentStateLargeShape(cbit.vcell.graph.MolecularComponentLargeShape.ComponentStateLargeShape) LargeShape(cbit.vcell.graph.LargeShape) MolecularComponentLargeShape(cbit.vcell.graph.MolecularComponentLargeShape) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder) EtchedBorder(javax.swing.border.EtchedBorder)

Example 65 with TitledBorder

use of javax.swing.border.TitledBorder in project vcell by virtualcell.

the class ObservablePropertiesPanel method initialize.

private void initialize() {
    observableTree = new BioModelNodeEditableTree();
    observableTreeModel = new ObservableTreeModel(observableTree);
    observableTree.setModel(observableTreeModel);
    setLayout(new GridBagLayout());
    // --------------------------------------------------------------------------------------------------------
    splitPaneHorizontal.setOneTouchExpandable(true);
    splitPaneHorizontal.setDividerLocation(120);
    splitPaneHorizontal.setResizeWeight(0.1);
    Border border = BorderFactory.createLineBorder(Color.gray);
    Border loweredEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
    TitledBorder annotationBorder = BorderFactory.createTitledBorder(loweredEtchedBorder, " Annotation ");
    annotationBorder.setTitleJustification(TitledBorder.LEFT);
    annotationBorder.setTitlePosition(TitledBorder.TOP);
    annotationBorder.setTitleFont(getFont().deriveFont(Font.BOLD));
    shapePanel = new LargeShapePanel() {

        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            for (SpeciesPatternLargeShape sps : spsList) {
                if (sps == null) {
                    continue;
                }
                sps.paintSelf(g);
            }
        }

        @Override
        public DisplayMode getDisplayMode() {
            return DisplayMode.other;
        }

        @Override
        public RuleAnalysisChanged hasStateChanged(String reactionRuleName, MolecularComponentPattern molecularComponentPattern) {
            return RuleAnalysisChanged.UNCHANGED;
        }

        @Override
        public RuleAnalysisChanged hasStateChanged(MolecularComponentPattern molecularComponentPattern) {
            return RuleAnalysisChanged.UNCHANGED;
        }

        @Override
        public RuleAnalysisChanged hasBondChanged(String reactionRuleName, MolecularComponentPattern molecularComponentPattern) {
            return RuleAnalysisChanged.UNCHANGED;
        }

        @Override
        public RuleAnalysisChanged hasBondChanged(MolecularComponentPattern molecularComponentPattern) {
            return RuleAnalysisChanged.UNCHANGED;
        }

        @Override
        public RuleAnalysisChanged hasNoMatch(String reactionRuleName, MolecularTypePattern mtp) {
            return RuleAnalysisChanged.UNCHANGED;
        }

        @Override
        public RuleAnalysisChanged hasNoMatch(MolecularTypePattern molecularTypePattern) {
            return RuleAnalysisChanged.UNCHANGED;
        }

        @Override
        public RuleParticipantSignature getSignature() {
            return null;
        }

        @Override
        public GroupingCriteria getCriteria() {
            return null;
        }

        @Override
        public boolean isViewSingleRow() {
            return true;
        }
    };
    shapePanel.setBorder(border);
    shapePanel.setBackground(Color.white);
    shapePanel.setLayout(null);
    shapePanel.setZoomFactor(-1);
    shapePanel.setEditable(true);
    shapePanel.setShowMoleculeColor(true);
    shapePanel.setShowNonTrivialOnly(true);
    shapePanel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            if (e.getButton() == 1) {
                // left click selects the object (we highlight it)
                Point whereClicked = e.getPoint();
                PointLocationInShapeContext locationContext = new PointLocationInShapeContext(whereClicked);
                manageMouseActivity(locationContext);
            } else if (e.getButton() == 3) {
                // right click invokes popup menu (only if the object is highlighted)
                Point whereClicked = e.getPoint();
                PointLocationInShapeContext locationContext = new PointLocationInShapeContext(whereClicked);
                manageMouseActivity(locationContext);
                if (locationContext.getDeepestShape() != null && !locationContext.getDeepestShape().isHighlighted()) {
                // TODO: (maybe) add code here to highlight the shape if it's not highlighted already but don't show the menu
                // return;
                }
                showPopupMenu(e, locationContext);
            }
        }

        private void manageMouseActivity(PointLocationInShapeContext locationContext) {
            Graphics g = shapePanel.getGraphics();
            for (SpeciesPatternLargeShape sps : spsList) {
                sps.turnHighlightOffRecursive(g);
            }
            for (SpeciesPatternLargeShape sps : spsList) {
                if (sps.contains(locationContext)) {
                    // check if mouse is inside shape
                    break;
                }
            }
            locationContext.highlightDeepestShape();
            locationContext.paintDeepestShape(g);
        }
    });
    // shapePanel.addMouseListener(eventHandler);		// alternately use this
    shapePanel.addMouseMotionListener(new MouseMotionAdapter() {

        public void mouseMoved(MouseEvent e) {
            Point overWhat = e.getPoint();
            PointLocationInShapeContext locationContext = new PointLocationInShapeContext(overWhat);
            for (SpeciesPatternLargeShape sps : spsList) {
                if (sps.contains(locationContext)) {
                    break;
                }
            }
            HighlightableShapeInterface hsi = locationContext.getDeepestShape();
            if (hsi == null) {
                shapePanel.setToolTipText(null);
            } else {
                shapePanel.setToolTipText("Right click for " + hsi.getDisplayType() + " menus");
            }
            for (SpeciesPatternLargeShape sps : spsList) {
                for (MolecularTypeLargeShape mtls : sps.getMolecularTypeLargeShapes()) {
                    Rectangle r = mtls.getAnchorHotspot();
                    if (r != null && r.contains(overWhat)) {
                        mtls.getMolecularType();
                        shapePanel.setToolTipText(mtls.getAnchorsHTML());
                        break;
                    }
                }
            }
        }
    });
    JPanel optionsPanel = new JPanel();
    // gray options panel
    optionsPanel.setPreferredSize(new Dimension(140, 200));
    optionsPanel.setLayout(new GridBagLayout());
    getZoomSmallerButton().setEnabled(true);
    getZoomLargerButton().setEnabled(true);
    int gridy = 0;
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 3;
    // top, left bottom, right
    gbc.insets = new Insets(4, 4, 2, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    optionsPanel.add(getAddSpeciesButton(), gbc);
    ButtonGroup bg = new ButtonGroup();
    bg.add(getSequenceMultimolecularButton());
    bg.add(getSequencePolimerEqualButton());
    bg.add(getSequencePolimerGreaterButton());
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(8, 4, 2, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    optionsPanel.add(getSequenceMultimolecularButton(), gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(4, 10, 2, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    JLabel label = new JLabel("Polymer of");
    label.setToolTipText("Compact notation available below for single-Molecule polymers");
    optionsPanel.add(label, gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(2, 4, 1, 2);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    optionsPanel.add(getSequencePolimerEqualButton(), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(2, 4, 1, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    optionsPanel.add(getLengthEqualTextField(), gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(1, 4, 4, 2);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    optionsPanel.add(getSequencePolimerGreaterButton(), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(1, 4, 4, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    optionsPanel.add(getLengthGreaterTextField(), gbc);
    // --- zoom buttons in their own panel, for alignment ---
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc2 = new GridBagConstraints();
    gbc2.gridx = 0;
    gbc2.gridy = 0;
    gbc2.insets = new Insets(1, 1, 1, 1);
    gbc2.anchor = GridBagConstraints.WEST;
    buttonPanel.add(getZoomLargerButton(), gbc2);
    gbc2 = new GridBagConstraints();
    gbc2.gridx = 1;
    gbc2.gridy = 0;
    gbc2.insets = new Insets(1, 1, 1, 1);
    gbc2.anchor = GridBagConstraints.WEST;
    buttonPanel.add(getZoomSmallerButton(), gbc2);
    // ---------------------------------------------------
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(1, 4, 4, 2);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    // zoom buttons panel
    optionsPanel.add(buttonPanel, gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 3;
    gbc.weightx = 1;
    // fake cell used for filling all the vertical empty space
    gbc.weighty = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 1, 2, 10);
    optionsPanel.add(new JLabel(""), gbc);
    // -----------------------------------------------------------------------------------------
    // right bottom panel, contains just the annotation
    JPanel generalPanel = new JPanel();
    generalPanel.setBorder(annotationBorder);
    generalPanel.setLayout(new GridBagLayout());
    gridy = 0;
    annotationTextArea = new javax.swing.JTextArea("", 1, 30);
    annotationTextArea.setLineWrap(true);
    annotationTextArea.setWrapStyleWord(true);
    annotationTextArea.setFont(new Font("monospaced", Font.PLAIN, 11));
    annotationTextArea.setEditable(false);
    javax.swing.JScrollPane jsp = new javax.swing.JScrollPane(annotationTextArea);
    gbc = new java.awt.GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 0.1;
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = java.awt.GridBagConstraints.BOTH;
    gbc.insets = new Insets(4, 4, 4, 4);
    generalPanel.add(jsp, gbc);
    // where we display the shapes
    scrollPane = new JScrollPane(shapePanel);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    JPanel containerOfScrollPanel = new JPanel();
    containerOfScrollPanel.setLayout(new BorderLayout());
    containerOfScrollPanel.add(optionsPanel, BorderLayout.WEST);
    containerOfScrollPanel.add(scrollPane, BorderLayout.CENTER);
    splitPaneHorizontal.setTopComponent(containerOfScrollPanel);
    splitPaneHorizontal.setBottomComponent(generalPanel);
    splitPaneHorizontal.setResizeWeight(0.9d);
    splitPaneHorizontal.setDividerLocation(0.8d);
    setName("ObservablePropertiesPanel");
    setLayout(new BorderLayout());
    add(splitPaneHorizontal, BorderLayout.CENTER);
    setBackground(Color.white);
    annotationTextArea.addFocusListener(eventHandler);
    annotationTextArea.addMouseListener(eventHandler);
}
Also used : JPanel(javax.swing.JPanel) RuleParticipantSignature(cbit.vcell.model.RuleParticipantSignature) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Rectangle(java.awt.Rectangle) TitledBorder(javax.swing.border.TitledBorder) SpeciesPatternLargeShape(cbit.vcell.graph.SpeciesPatternLargeShape) Font(java.awt.Font) LargeShapePanel(cbit.vcell.graph.gui.LargeShapePanel) MolecularTypeLargeShape(cbit.vcell.graph.MolecularTypeLargeShape) BorderLayout(java.awt.BorderLayout) RuleAnalysisChanged(cbit.vcell.graph.ReactionCartoon.RuleAnalysisChanged) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) GroupingCriteria(cbit.vcell.model.GroupingCriteria) MouseAdapter(java.awt.event.MouseAdapter) HighlightableShapeInterface(cbit.vcell.graph.HighlightableShapeInterface) JLabel(javax.swing.JLabel) Point(java.awt.Point) Dimension(java.awt.Dimension) PointLocationInShapeContext(cbit.vcell.graph.PointLocationInShapeContext) GridBagConstraints(java.awt.GridBagConstraints) Point(java.awt.Point) Graphics(java.awt.Graphics) JScrollPane(javax.swing.JScrollPane) MouseMotionAdapter(java.awt.event.MouseMotionAdapter) ButtonGroup(javax.swing.ButtonGroup) JTextArea(javax.swing.JTextArea) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder) EtchedBorder(javax.swing.border.EtchedBorder)

Aggregations

TitledBorder (javax.swing.border.TitledBorder)143 JPanel (javax.swing.JPanel)94 GridBagConstraints (java.awt.GridBagConstraints)59 GridBagLayout (java.awt.GridBagLayout)50 JLabel (javax.swing.JLabel)50 BorderLayout (java.awt.BorderLayout)45 Insets (java.awt.Insets)43 JScrollPane (javax.swing.JScrollPane)34 Dimension (java.awt.Dimension)30 JButton (javax.swing.JButton)29 EtchedBorder (javax.swing.border.EtchedBorder)28 ActionEvent (java.awt.event.ActionEvent)25 EmptyBorder (javax.swing.border.EmptyBorder)25 Border (javax.swing.border.Border)23 ActionListener (java.awt.event.ActionListener)21 JCheckBox (javax.swing.JCheckBox)19 GridLayout (java.awt.GridLayout)18 JTextField (javax.swing.JTextField)16 Color (java.awt.Color)15 Box (javax.swing.Box)12