use of cbit.vcell.graph.HighlightableShapeInterface 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);
}
use of cbit.vcell.graph.HighlightableShapeInterface 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);
}
use of cbit.vcell.graph.HighlightableShapeInterface in project vcell by virtualcell.
the class SpeciesPropertiesPanel method initialize.
/**
* Initialize the class.
*/
private void initialize() {
try {
Border border = BorderFactory.createLineBorder(Color.gray);
shapePanel = new // glyph (shape) panel
LargeShapePanel() {
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (spls != null) {
spls.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.setZoomFactor(-1);
shapePanel.setEditable(true);
shapePanel.setShowMoleculeColor(true);
shapePanel.setShowNonTrivialOnly(true);
// Dimension ms = new Dimension(350, 80);
// shapePanel.setMinimumSize(ms);
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();
spls.turnHighlightOffRecursive(g);
if (spls.contains(locationContext)) {
// check if mouse is inside shape
System.out.println("left click inside shape " + locationContext.getDeepestShape().toString());
}
locationContext.highlightDeepestShape();
locationContext.paintDeepestShape(g);
}
});
shapePanel.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseMoved(MouseEvent e) {
Point overWhat = e.getPoint();
PointLocationInShapeContext locationContext = new PointLocationInShapeContext(overWhat);
spls.contains(locationContext);
HighlightableShapeInterface hsi = locationContext.getDeepestShape();
if (hsi == null) {
shapePanel.setToolTipText(null);
} else {
shapePanel.setToolTipText("Right click for " + hsi.getDisplayType() + " menus");
}
for (MolecularTypeLargeShape mtls : spls.getMolecularTypeLargeShapes()) {
Rectangle r = mtls.getAnchorHotspot();
if (r != null && r.contains(overWhat)) {
mtls.getMolecularType();
shapePanel.setToolTipText(mtls.getAnchorsHTML());
break;
}
}
}
});
// ----------------------------------------------------------------------------------
leftPanel = new JPanel();
GridBagLayout mgr = new GridBagLayout();
mgr.rowHeights = new int[] { 100, 100 };
leftPanel.setLayout(mgr);
leftPanel.setBackground(Color.white);
speciesPropertiesTree = new BioModelNodeEditableTree();
speciesPropertiesTreeModel = new SpeciesPropertiesTreeModel(speciesPropertiesTree);
speciesPropertiesTree.setModel(speciesPropertiesTreeModel);
JPanel generalPanel = new JPanel();
generalPanel.setLayout(new GridBagLayout());
Dimension size = new Dimension(100, 150);
generalPanel.setMinimumSize(size);
nameTextField = new JTextField();
nameTextField.setEditable(false);
nameTextField.addActionListener(eventHandler);
int gridy = 0;
GridBagConstraints gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
JLabel label = new JLabel("Species Name");
generalPanel.add(label, gbc);
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_START;
generalPanel.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;
generalPanel.add(new JLabel("Linked Pathway Object(s)"), gbc);
linkedPOScrollPane = new JScrollPane();
gbc = new java.awt.GridBagConstraints();
gbc.weightx = 1.0;
gbc.weighty = 0.1;
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);
generalPanel.add(linkedPOScrollPane, gbc);
gridy++;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(9, 8, 4, 6);
gbc.anchor = GridBagConstraints.FIRST_LINE_END;
generalPanel.add(new JLabel("Annotation "), gbc);
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 = 1;
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);
GridBagConstraints gbc1 = new GridBagConstraints();
gbc1.gridx = 0;
gbc1.gridy = 0;
gbc1.gridwidth = 1;
gbc1.weightx = 1;
gbc1.weighty = 1;
gbc1.fill = GridBagConstraints.BOTH;
leftPanel.add(generalPanel, gbc1);
scrollPane = new JScrollPane(shapePanel);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
// -----------------------------------------------------------
JPanel optionsPanel = new JPanel();
optionsPanel.setLayout(new GridBagLayout());
getZoomSmallerButton().setEnabled(true);
getZoomLargerButton().setEnabled(true);
GridBagConstraints gbc2 = new GridBagConstraints();
gbc2.gridx = 0;
gbc2.gridy = 0;
gbc2.insets = new Insets(4, 4, 0, 10);
gbc2.anchor = GridBagConstraints.WEST;
optionsPanel.add(getZoomLargerButton(), gbc2);
gbc2 = new GridBagConstraints();
gbc2.gridx = 0;
gbc2.gridy = 1;
gbc2.insets = new Insets(4, 4, 4, 10);
gbc2.anchor = GridBagConstraints.WEST;
optionsPanel.add(getZoomSmallerButton(), gbc2);
gbc2 = new GridBagConstraints();
gbc2.gridx = 0;
gbc2.gridy = 2;
gbc2.weightx = 1;
// fake cell used for filling all the vertical empty space
gbc2.weighty = 1;
gbc2.anchor = GridBagConstraints.WEST;
gbc2.insets = new Insets(4, 4, 4, 10);
optionsPanel.add(new JLabel(""), gbc2);
JPanel containerOfScrollPanel = new JPanel();
containerOfScrollPanel.setLayout(new BorderLayout());
containerOfScrollPanel.add(optionsPanel, BorderLayout.WEST);
containerOfScrollPanel.add(scrollPane, BorderLayout.CENTER);
// gbc1 = new GridBagConstraints();
gbc1.gridx = 0;
gbc1.gridy = 1;
gbc1.weightx = 1;
gbc1.weighty = 0.1;
gbc1.fill = GridBagConstraints.BOTH;
leftPanel.add(containerOfScrollPanel, gbc1);
setName("SpeciesEditorPanel");
setLayout(new BorderLayout());
setBackground(Color.white);
add(leftPanel, BorderLayout.CENTER);
initConnections();
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of cbit.vcell.graph.HighlightableShapeInterface in project vcell by virtualcell.
the class ReactionRuleEditorPropertiesPanel method initialize.
private void initialize() {
try {
shapePanel = new RulesShapePanel() {
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
reactantShape.paintSelf(g);
productShape.paintSelf(g);
}
};
shapePanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
if (getViewSingleRowButton().isSelected()) {
return;
}
if (e.getButton() == 1) {
// left click selects the object (we highlight it)
Point whereClicked = e.getPoint();
PointLocationInShapeContext locationContext = new PointLocationInShapeContext(whereClicked);
reactantShape.setPointLocationInShapeContext(locationContext);
productShape.setPointLocationInShapeContext(locationContext);
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);
reactantShape.setPointLocationInShapeContext(locationContext);
productShape.setPointLocationInShapeContext(locationContext);
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();
reactantShape.turnHighlightOffRecursive(g);
productShape.turnHighlightOffRecursive(g);
boolean found = false;
if (reactantShape.contains(locationContext)) {
found = true;
}
if (!found) {
if (productShape.contains(locationContext)) {
// we just need to initialize the location context with the proper shapes under the cursor by calling "contains"
;
}
}
locationContext.highlightDeepestShape();
// if(locationContext.getDeepestShape() == null) {
// // nothing selected means all the reactant bar or all the product bar is selected
int xExtent = SpeciesPatternLargeShape.calculateXExtent(shapePanel);
Rectangle2D reactantRectangle = new Rectangle2D.Double(xOffsetInitial - xExtent, yOffsetReactantInitial - 3, 3000, 80 - 2 + GraphConstants.ReactionRuleDisplay_ReservedSpaceForNameOnYAxis);
Rectangle2D productRectangle = new Rectangle2D.Double(xOffsetInitial - xExtent, yOffsetProductInitial - 3, 3000, 80 - 2 + GraphConstants.ReactionRuleDisplay_ReservedSpaceForNameOnYAxis);
if (locationContext.isInside(reactantRectangle)) {
reactantShape.paintSelf(g, true);
} else if (locationContext.isInside(productRectangle)) {
productShape.paintSelf(g, true);
// } else {
//
// }
// } else {
// locationContext.paintDeepestShape(g);
}
}
});
shapePanel.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseMoved(MouseEvent e) {
if (getViewSingleRowButton().isSelected()) {
shapePanel.setToolTipText("Single Row is view-only. To edit, unselect the 'Single Row Viewer' check box.");
return;
}
Point overWhat = e.getPoint();
PointLocationInShapeContext locationContext = new PointLocationInShapeContext(overWhat);
boolean inReactant = reactantShape.contains(locationContext);
boolean inProduct = productShape.contains(locationContext);
HighlightableShapeInterface hsi = locationContext.getDeepestShape();
if (hsi == null) {
shapePanel.setToolTipText(null);
} else {
shapePanel.setToolTipText("Right click for " + hsi.getDisplayType() + " menus");
}
List<SpeciesPatternLargeShape> spsList = null;
if (inReactant) {
spsList = reactantShape.getSpeciesPatternShapeList();
} else if (inProduct) {
spsList = productShape.getSpeciesPatternShapeList();
}
if (spsList != null) {
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;
}
}
}
}
}
});
shapePanel.setLayout(new GridBagLayout());
shapePanel.setBackground(Color.white);
shapePanel.zoomSmaller();
shapePanel.zoomSmaller();
getZoomSmallerButton().setEnabled(true);
getZoomLargerButton().setEnabled(true);
scrollPane = new JScrollPane(shapePanel);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
isReversibleCheckBox = new JCheckBox("Reversible");
isReversibleCheckBox.setHorizontalTextPosition(SwingConstants.LEFT);
isReversibleCheckBox.addActionListener(eventHandler);
isReversibleCheckBox.setEnabled(true);
JPanel optionsPanel = new JPanel();
optionsPanel.setPreferredSize(new Dimension(156, 200));
optionsPanel.setLayout(new GridBagLayout());
int gridy = 0;
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(6, 1, 2, 2);
gbc.anchor = GridBagConstraints.WEST;
optionsPanel.add(isReversibleCheckBox, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.insets = new Insets(0, 0, 0, 0);
// empty cell to take all available horizontal space and push the next 2 buttons to the right
gbc.weightx = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.HORIZONTAL;
optionsPanel.add(new JLabel(""), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 2;
gbc.gridy = gridy;
gbc.insets = new Insets(6, 2, 2, 2);
gbc.anchor = GridBagConstraints.EAST;
optionsPanel.add(getZoomLargerButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 3;
gbc.gridy = gridy;
gbc.insets = new Insets(6, 2, 2, 4);
gbc.anchor = GridBagConstraints.EAST;
optionsPanel.add(getZoomSmallerButton(), gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.gridwidth = 4;
// top, left bottom, right
gbc.insets = new Insets(4, 4, 2, 4);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.NORTHWEST;
optionsPanel.add(getAddReactantButton(), gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.gridwidth = 4;
gbc.insets = new Insets(2, 4, 4, 4);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.NORTHWEST;
optionsPanel.add(getAddProductButton(), gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.gridwidth = 4;
gbc.weightx = 1;
// fake cell used for filling all the vertical empty space
gbc.weighty = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets(4, 4, 4, 10);
optionsPanel.add(new JLabel(""), gbc);
// -----------------------------------------------------------
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.gridwidth = 4;
gbc.insets = new Insets(2, 4, 0, 4);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.SOUTHWEST;
optionsPanel.add(getViewSingleRowButton(), gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.gridwidth = 4;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.SOUTHWEST;
optionsPanel.add(getShowMoleculeColorButton(), gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.gridwidth = 4;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.SOUTHWEST;
optionsPanel.add(getShowNonTrivialButton(), gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.gridwidth = 3;
gbc.insets = new Insets(0, 4, 4, 4);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.SOUTHWEST;
optionsPanel.add(getShowDifferencesButton(), gbc);
// set initial buttons' state
getViewSingleRowButton().setSelected(false);
getShowMoleculeColorButton().setSelected(true);
getShowNonTrivialButton().setSelected(true);
getShowDifferencesButton().setSelected(false);
shapePanel.setViewSingleRow(getViewSingleRowButton().isSelected());
shapePanel.setShowMoleculeColor(getShowMoleculeColorButton().isSelected());
shapePanel.setShowNonTrivialOnly(getShowNonTrivialButton().isSelected());
shapePanel.setShowDifferencesOnly(getShowDifferencesButton().isSelected());
// ----------------------------------------------------------
containerOfScrollPanel = new JPanel();
containerOfScrollPanel.setLayout(new BorderLayout());
containerOfScrollPanel.add(optionsPanel, BorderLayout.WEST);
containerOfScrollPanel.add(scrollPane, BorderLayout.CENTER);
reactantTree = new BioModelNodeEditableTree();
reactantTreeModel = new ReactionRulePropertiesTreeModel(reactantTree, ReactionRuleParticipantType.Reactant);
reactantTree.setModel(reactantTreeModel);
productTree = new BioModelNodeEditableTree();
productTreeModel = new ReactionRulePropertiesTreeModel(productTree, ReactionRuleParticipantType.Product);
productTree.setModel(productTreeModel);
setLayout(new BorderLayout());
add(containerOfScrollPanel, BorderLayout.CENTER);
setBackground(Color.white);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
Aggregations