use of cbit.vcell.graph.SpeciesPatternSmallShape in project vcell by virtualcell.
the class ViewObservablesMapPanel method initialize.
private void initialize() {
try {
// --------------------------------------- the split panels
setName("ViewGeneratedSpeciesPanel");
setLayout(new BorderLayout());
JPanel topPanel = new JPanel();
topPanel.setLayout(new GridBagLayout());
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new GridBagLayout());
JSplitPane splitPaneHorizontal = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPaneHorizontal.setDividerSize(10);
splitPaneHorizontal.setOneTouchExpandable(true);
splitPaneHorizontal.setDividerLocation(260);
splitPaneHorizontal.setResizeWeight(0.5);
splitPaneHorizontal.setTopComponent(topPanel);
splitPaneHorizontal.setBottomComponent(bottomPanel);
add(splitPaneHorizontal, BorderLayout.CENTER);
// ---------------------------------------- species shape panel
shapePanelSpecies = new 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;
}
};
shapePanelSpecies.setLayout(new GridBagLayout());
shapePanelSpecies.setBackground(Color.white);
// not really editable but we don't want the brown contours here
shapePanelSpecies.setEditable(true);
shapePanelSpecies.setShowMoleculeColor(true);
shapePanelSpecies.setShowNonTrivialOnly(true);
Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
JScrollPane scrollPaneSpecies = new JScrollPane(shapePanelSpecies);
scrollPaneSpecies.setBorder(loweredBevelBorder);
scrollPaneSpecies.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPaneSpecies.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
JPanel optionsPanelSpecies = new JPanel();
optionsPanelSpecies.setLayout(new GridBagLayout());
getZoomSmallerButtonSpecies().setEnabled(true);
getZoomLargerButtonSpecies().setEnabled(true);
shapePanelSpecies.zoomSmaller();
shapePanelSpecies.zoomSmaller();
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.insets = new Insets(0, 0, 0, 10);
gbc.anchor = GridBagConstraints.WEST;
optionsPanelSpecies.add(getZoomLargerButtonSpecies(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.insets = new Insets(2, 0, 4, 10);
gbc.anchor = GridBagConstraints.WEST;
optionsPanelSpecies.add(getZoomSmallerButtonSpecies(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
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);
optionsPanelSpecies.add(new JLabel(""), gbc);
JPanel containerOfScrollPanelSpecies = new JPanel();
containerOfScrollPanelSpecies.setLayout(new BorderLayout());
containerOfScrollPanelSpecies.add(optionsPanelSpecies, BorderLayout.WEST);
containerOfScrollPanelSpecies.add(scrollPaneSpecies, BorderLayout.CENTER);
Dimension dimS = new Dimension(500, 125);
// dimension of shape panel
containerOfScrollPanelSpecies.setPreferredSize(dimS);
containerOfScrollPanelSpecies.setMinimumSize(dimS);
containerOfScrollPanelSpecies.setMaximumSize(dimS);
shapePanelObservable = 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;
}
};
//
DefaultScrollTableCellRenderer rbmSpeciesPatternCellRenderer = 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 (table.getModel() instanceof GeneratedSpeciesTableModel2) {
Object selectedObject = null;
if (table.getModel() == speciesTableModel) {
selectedObject = speciesTableModel.getValueAt(row);
}
if (selectedObject != null) {
if (selectedObject instanceof GeneratedSpeciesTableRow && value instanceof String) {
SpeciesPattern sp = ((GeneratedSpeciesTableRow) selectedObject).getSpecies().getSpeciesPattern();
String text = "<html>";
text += RbmTableRenderer.toHtml(sp, isSelected);
text += "</html>";
setText(text);
}
}
}
return this;
}
};
// shapePanelObservable.setLayout(null);
shapePanelObservable.setLayout(new GridBagLayout());
shapePanelObservable.setBackground(Color.white);
shapePanelObservable.setEditable(true);
shapePanelObservable.setShowMoleculeColor(true);
shapePanelObservable.setShowNonTrivialOnly(true);
JScrollPane scrollPaneObservable = new JScrollPane(shapePanelObservable);
scrollPaneObservable.setBorder(loweredBevelBorder);
scrollPaneObservable.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPaneObservable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
JPanel optionsPanelObservable = new JPanel();
optionsPanelObservable.setLayout(new GridBagLayout());
getZoomSmallerButtonObservable().setEnabled(true);
getZoomLargerButtonObservable().setEnabled(true);
shapePanelObservable.zoomSmaller();
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.insets = new Insets(0, 0, 0, 10);
gbc.anchor = GridBagConstraints.WEST;
optionsPanelObservable.add(getZoomLargerButtonObservable(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.insets = new Insets(2, 0, 4, 10);
gbc.anchor = GridBagConstraints.WEST;
optionsPanelObservable.add(getZoomSmallerButtonObservable(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
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);
optionsPanelObservable.add(new JLabel(""), gbc);
JPanel containerOfScrollPanelObservable = new JPanel();
containerOfScrollPanelObservable.setLayout(new BorderLayout());
containerOfScrollPanelObservable.add(optionsPanelObservable, BorderLayout.WEST);
containerOfScrollPanelObservable.add(scrollPaneObservable, BorderLayout.CENTER);
Dimension dimO = new Dimension(500, 100);
// dimension of shape panel
containerOfScrollPanelObservable.setPreferredSize(dimO);
containerOfScrollPanelObservable.setMinimumSize(dimO);
containerOfScrollPanelObservable.setMaximumSize(dimO);
// -------------- connection between tables, table models, selection models, renderers, event handlers
speciesTable = new EditorScrollTable();
speciesTableModel = new GeneratedSpeciesTableModel2(speciesTable, owner);
speciesTable.setModel(speciesTableModel);
speciesTable.getSelectionModel().addListSelectionListener(eventHandlerS);
speciesTable.getModel().addTableModelListener(eventHandlerS);
observablesTable = new EditorScrollTable();
observablesTableModel = new ObservablesGroupTableModel(observablesTable, owner, speciesTableModel);
observablesTable.setModel(observablesTableModel);
observablesTable.getSelectionModel().addListSelectionListener(eventHandlerO);
observablesTable.getModel().addTableModelListener(eventHandlerO);
speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColDefinition).setCellRenderer(rbmSpeciesPatternCellRenderer);
DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
rightRenderer.setHorizontalAlignment(JLabel.RIGHT);
// speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColMultiplier).setCellRenderer(rightRenderer); // right align
// left column wide enough for title
speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColMultiplier).setMaxWidth(70);
speciesTable.addMouseMotionListener(new // add toolTipText for each table cell
MouseMotionAdapter() {
public void mouseMoved(MouseEvent e) {
Point p = e.getPoint();
int row = speciesTable.rowAtPoint(p);
int column = speciesTable.columnAtPoint(p);
speciesTable.setToolTipText(String.valueOf(speciesTable.getValueAt(row, column)));
}
});
// ---------------------------------------------- top panel
int gridy = 0;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridwidth = 8;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
observablesTable.setPreferredScrollableViewportSize(new Dimension(400, 200));
topPanel.add(observablesTable.getEnclosingScrollPane(), gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.insets = new Insets(4, 4, 4, 4);
topPanel.add(new JLabel("Search "), gbc);
textFieldSearchObservables = new JTextField(70);
textFieldSearchObservables.addActionListener(eventHandlerO);
textFieldSearchObservables.getDocument().addDocumentListener(eventHandlerO);
textFieldSearchObservables.putClientProperty("JTextField.variant", "search");
gbc = new java.awt.GridBagConstraints();
gbc.weightx = 1.0;
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.gridwidth = 3;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 0, 4, 4);
topPanel.add(textFieldSearchObservables, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 4;
gbc.gridy = gridy;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 10);
topPanel.add(totalObservablesLabel, gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
// gbc.weightx = 1.0;
gbc.gridwidth = 8;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
topPanel.add(containerOfScrollPanelObservable, gbc);
// -------------------------------------------- bottom panel
gridy = 0;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridwidth = 8;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
speciesTable.setPreferredScrollableViewportSize(new Dimension(400, 200));
bottomPanel.add(speciesTable.getEnclosingScrollPane(), gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.insets = new Insets(4, 4, 4, 4);
bottomPanel.add(new JLabel("Search "), gbc);
textFieldSearchSpecies = new JTextField(70);
textFieldSearchSpecies.addActionListener(eventHandlerS);
textFieldSearchSpecies.getDocument().addDocumentListener(eventHandlerS);
textFieldSearchSpecies.putClientProperty("JTextField.variant", "search");
gbc = new java.awt.GridBagConstraints();
gbc.weightx = 1.0;
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.gridwidth = 3;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 0, 4, 4);
bottomPanel.add(textFieldSearchSpecies, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 4;
gbc.gridy = gridy;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 10);
bottomPanel.add(totalSpeciesLabel, gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
// gbc.weightx = 1.0;
gbc.gridwidth = 8;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
bottomPanel.add(containerOfScrollPanelSpecies, gbc);
// rendering the small shapes of the flattened species in the Depiction column of this viewer table)
// TODO: this renderer is almost identical with the one in BioModelEditorModelPanel (which paints the small shapes
// of a species context in the Depiction column of the species table)
DefaultScrollTableCellRenderer rbmSpeciesShapeDepictionCellRenderer = new DefaultScrollTableCellRenderer() {
SpeciesPatternSmallShape spss = null;
@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 VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == speciesTableModel) {
selectedObject = speciesTableModel.getValueAt(row);
}
if (selectedObject != null) {
if (selectedObject instanceof GeneratedSpeciesTableRow) {
SpeciesContext sc = ((GeneratedSpeciesTableRow) selectedObject).getSpecies();
// sp cannot be null
SpeciesPattern sp = sc.getSpeciesPattern();
Graphics panelContext = table.getGraphics();
spss = new SpeciesPatternSmallShape(4, 2, sp, panelContext, sc, isSelected, issueManager);
}
} else {
spss = null;
}
}
setText("");
return this;
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (spss != null) {
spss.paintSelf(g);
}
}
};
speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColDepiction).setCellRenderer(rbmSpeciesShapeDepictionCellRenderer);
speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColDepiction).setPreferredWidth(400);
speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColDepiction).setMinWidth(400);
speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColDefinition).setPreferredWidth(30);
speciesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
DefaultScrollTableCellRenderer rbmObservableShapeDepictionCellRenderer = new DefaultScrollTableCellRenderer() {
List<SpeciesPatternSmallShape> spssList = new ArrayList<SpeciesPatternSmallShape>();
SpeciesPatternSmallShape spss = null;
@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 VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == observablesTableModel) {
selectedObject = observablesTableModel.getValueAt(row);
}
if (selectedObject != null && selectedObject instanceof ObservablesGroupTableRow) {
ObservablesGroupTableRow ogtr = ((ObservablesGroupTableRow) selectedObject);
String obsName = ogtr.getObservableGroupObject().getObservableGroupName();
RbmObservable observable = ogtr.getObservable(obsName);
Graphics panelContext = table.getGraphics();
int xPos = 4;
spssList.clear();
for (int i = 0; i < observable.getSpeciesPatternList().size(); i++) {
SpeciesPattern sp = observable.getSpeciesPatternList().get(i);
spss = new SpeciesPatternSmallShape(xPos, 2, sp, panelContext, observable, isSelected, issueManager);
xPos += spss.getWidth() + 6;
spssList.add(spss);
}
} else {
spssList.clear();
}
}
setText("");
return this;
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
for (SpeciesPatternSmallShape spss : spssList) {
if (spss == null) {
continue;
}
spss.paintSelf(g);
}
}
};
observablesTable.getColumnModel().getColumn(ObservablesGroupTableModel.iColDepiction).setCellRenderer(rbmObservableShapeDepictionCellRenderer);
observablesTable.getColumnModel().getColumn(ObservablesGroupTableModel.iColDepiction).setPreferredWidth(150);
observablesTable.getColumnModel().getColumn(ObservablesGroupTableModel.iColDepiction).setMinWidth(150);
observablesTable.getColumnModel().getColumn(ObservablesGroupTableModel.iColDefinition).setPreferredWidth(80);
observablesTable.getColumnModel().getColumn(ObservablesGroupTableModel.iColExpression).setPreferredWidth(100);
observablesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of cbit.vcell.graph.SpeciesPatternSmallShape in project vcell by virtualcell.
the class OutputSpeciesResultsPanel method initialize.
private void initialize() {
try {
setName("ViewGeneratedSpeciesPanel");
setLayout(new GridBagLayout());
shapePanel = new 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;
}
};
Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
shapePanel.setLayout(new GridBagLayout());
shapePanel.setBackground(Color.white);
// not really editable but we don't want the brown contours here
shapePanel.setEditable(true);
shapePanel.setShowMoleculeColor(true);
shapePanel.setShowNonTrivialOnly(true);
JScrollPane scrollPane = new JScrollPane(shapePanel);
scrollPane.setBorder(loweredBevelBorder);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
JPanel optionsPanel = new JPanel();
optionsPanel.setLayout(new GridBagLayout());
getZoomSmallerButton().setEnabled(true);
getZoomLargerButton().setEnabled(false);
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.insets = new Insets(0, 0, 0, 10);
gbc.anchor = GridBagConstraints.WEST;
optionsPanel.add(getZoomLargerButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.insets = new Insets(2, 0, 4, 10);
gbc.anchor = GridBagConstraints.WEST;
optionsPanel.add(getZoomSmallerButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
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);
JPanel containerOfScrollPanel = new JPanel();
containerOfScrollPanel.setLayout(new BorderLayout());
containerOfScrollPanel.add(optionsPanel, BorderLayout.WEST);
containerOfScrollPanel.add(scrollPane, BorderLayout.CENTER);
Dimension dim = new Dimension(500, 135);
// dimension of shape panel
containerOfScrollPanel.setPreferredSize(dim);
containerOfScrollPanel.setMinimumSize(dim);
containerOfScrollPanel.setMaximumSize(dim);
// ------------------------------------------------------------------------
table = new EditorScrollTable();
tableModel = new OutputSpeciesResultsTableModel();
table.setModel(tableModel);
table.getSelectionModel().addListSelectionListener(eventHandler);
table.getModel().addTableModelListener(eventHandler);
DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
rightRenderer.setHorizontalAlignment(JLabel.RIGHT);
int gridy = 0;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridwidth = 8;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
table.setPreferredScrollableViewportSize(new Dimension(400, 200));
add(table.getEnclosingScrollPane(), gbc);
// add toolTipText for each table cell
table.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseMoved(MouseEvent e) {
Point p = e.getPoint();
int row = table.rowAtPoint(p);
int column = table.columnAtPoint(p);
table.setToolTipText(String.valueOf(table.getValueAt(row, column)));
}
});
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.insets = new Insets(4, 4, 4, 4);
add(new JLabel("Search "), gbc);
textFieldSearch = new JTextField(70);
textFieldSearch.addActionListener(eventHandler);
textFieldSearch.getDocument().addDocumentListener(eventHandler);
textFieldSearch.putClientProperty("JTextField.variant", "search");
gbc = new java.awt.GridBagConstraints();
gbc.weightx = 1.0;
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.gridwidth = 3;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 0, 4, 4);
add(textFieldSearch, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 4;
gbc.gridy = gridy;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 10);
add(totalSpeciesLabel, gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
// gbc.weightx = 1.0;
gbc.gridwidth = 8;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
add(containerOfScrollPanel, gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 4);
add(getSpeciesFileLocationPanel(), gbc);
// // button to copy to clipboard the content of the JTextField.
// // TODO: do not delete! this is how it's done
// JButton buttonCopy = new JButton("Copy");
// buttonCopy.setToolTipText("Copy to clipboard the species file path");
// buttonCopy.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent le) {
// if(speciesFileLocationTextField.getSelectionStart() == speciesFileLocationTextField.getSelectionEnd()) {
// speciesFileLocationTextField.setSelectionStart(0);
// speciesFileLocationTextField.setSelectionEnd(speciesFileLocationTextField.getText().length());
// }
// speciesFileLocationTextField.copy();
// speciesFileLocationTextField.setSelectionStart(0);
// speciesFileLocationTextField.setSelectionEnd(0);
// }
// });
// gbc = new GridBagConstraints();
// gbc.gridx = 4;
// gbc.gridy = gridy;
// gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
// gbc.insets = new Insets(4,4,4,4);
// add(buttonCopy, gbc);
// rendering the small shapes of the flattened species in the Depiction column of this viewer table)
DefaultScrollTableCellRenderer rbmSpeciesShapeDepictionCellRenderer = new DefaultScrollTableCellRenderer() {
SpeciesPatternSmallShape spss = null;
@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 VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == tableModel) {
selectedObject = tableModel.getValueAt(row);
}
if (selectedObject != null) {
if (selectedObject instanceof GeneratedSpeciesTableRow) {
SpeciesContext sc = ((GeneratedSpeciesTableRow) selectedObject).species;
if (sc == null || sc.getSpeciesPattern() == null) {
spss = null;
} else {
SpeciesPattern sp = sc.getSpeciesPattern();
Graphics panelContext = table.getGraphics();
spss = new SpeciesPatternSmallShape(4, 2, sp, panelContext, sc, isSelected, issueManager);
}
}
} else {
spss = null;
}
}
setText("");
return this;
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (spss != null) {
spss.paintSelf(g);
}
}
};
table.getColumnModel().getColumn(OutputSpeciesResultsTableModel.iColDepiction).setCellRenderer(rbmSpeciesShapeDepictionCellRenderer);
table.getColumnModel().getColumn(OutputSpeciesResultsTableModel.iColDepiction).setPreferredWidth(400);
table.getColumnModel().getColumn(OutputSpeciesResultsTableModel.iColDepiction).setMinWidth(400);
table.getColumnModel().getColumn(OutputSpeciesResultsTableModel.iColDefinition).setPreferredWidth(30);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of cbit.vcell.graph.SpeciesPatternSmallShape in project vcell by virtualcell.
the class ObservablePropertiesPanel method manageComponentPatternFromShape.
public void manageComponentPatternFromShape(final RbmElementAbstract selectedObject, PointLocationInShapeContext locationContext, ShowWhat showWhat) {
final MolecularComponentPattern mcp = (MolecularComponentPattern) selectedObject;
final MolecularComponent mc = mcp.getMolecularComponent();
popupFromShapeMenu.removeAll();
// ------------------------------------------------------------------- State
if (showWhat == ShowWhat.ShowState && mc.getComponentStateDefinitions().size() != 0) {
String prefix = "State: ";
String csdCurrentName = "";
final Map<String, String> itemMap = new LinkedHashMap<String, String>();
if (mcp.getComponentStatePattern() == null || mcp.getComponentStatePattern().isAny()) {
csdCurrentName = "<html>" + prefix + "<b>" + ComponentStatePattern.strAny + "</b></html>";
} else {
csdCurrentName = "<html>" + prefix + ComponentStatePattern.strAny + "</html>";
}
itemMap.put(csdCurrentName, ComponentStatePattern.strAny);
for (final ComponentStateDefinition csd : mc.getComponentStateDefinitions()) {
csdCurrentName = "";
if (mcp.getComponentStatePattern() != null && !mcp.getComponentStatePattern().isAny()) {
ComponentStateDefinition csdCurrent = mcp.getComponentStatePattern().getComponentStateDefinition();
csdCurrentName = csdCurrent.getName();
}
String name = csd.getName();
if (name.equals(csdCurrentName)) {
// currently selected menu item is shown in bold
name = "<html>" + prefix + "<b>" + name + "</b></html>";
} else {
name = "<html>" + prefix + name + "</html>";
}
itemMap.put(name, csd.getName());
}
for (String name : itemMap.keySet()) {
JMenuItem menuItem = new JMenuItem(name);
popupFromShapeMenu.add(menuItem);
menuItem.setIcon(VCellIcons.rbmComponentStateIcon);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String key = e.getActionCommand();
String name = itemMap.get(key);
if (name.equals(ComponentStatePattern.strAny)) {
ComponentStatePattern csp = new ComponentStatePattern();
mcp.setComponentStatePattern(csp);
} else {
ComponentStateDefinition csd = mcp.getMolecularComponent().getComponentStateDefinition(name);
if (csd == null) {
throw new RuntimeException("Missing ComponentStateDefinition " + name + " for Component " + mcp.getMolecularComponent().getName());
}
ComponentStatePattern csp = new ComponentStatePattern(csd);
mcp.setComponentStatePattern(csp);
}
}
});
}
}
if (showWhat == ShowWhat.ShowState) {
return;
}
// ------------------------------------------------------------------------------------------- Bonds
final MolecularTypePattern mtp = locationContext.getMolecularTypePattern();
final SpeciesPattern sp = locationContext.getSpeciesPattern();
JMenu editBondMenu = new JMenu();
final String specifiedString = mcp.getBondType() == BondType.Specified ? "<html><b>" + "Site bond specified" + "</b></html>" : "<html>" + "Site bond specified" + "</html>";
editBondMenu.setText(specifiedString);
editBondMenu.setToolTipText("Specified");
editBondMenu.removeAll();
final Map<String, Bond> itemMap = new LinkedHashMap<String, Bond>();
// String noneString = "<html>Bond: <b>" + BondType.None.symbol + "</b> " + BondType.None.name() + "</html>";
// String existsString = "<html>Bond: <b>" + BondType.Exists.symbol + "</b> " + BondType.Exists.name() + "</html>";
// String possibleString = "<html>Bond: <b>" + BondType.Possible.symbol + "</b> " + BondType.Possible.name() + "</html>";
String noneString = mcp.getBondType() == BondType.None ? "<html><b>" + "Site is unbound" + "</b></html>" : "<html>" + "Site is unbound" + "</html>";
// Site is bound
String existsString = mcp.getBondType() == BondType.Exists ? "<html><b>" + "Site has external bond" + "</b></html>" : "<html>" + "Site has external bond" + "</html>";
String possibleString = mcp.getBondType() == BondType.Possible ? "<html><b>" + "Site may be bound" + "</b></html>" : "<html>" + "Site may be bound" + "</html>";
itemMap.put(noneString, null);
itemMap.put(existsString, null);
itemMap.put(possibleString, null);
if (mtp != null && sp != null) {
List<Bond> bondPartnerChoices = sp.getAllBondPartnerChoices(mtp, mc);
for (Bond b : bondPartnerChoices) {
// if(b.equals(mcp.getBond())) {
// continue; // if the mcp has a bond already we don't offer it
// }
int index = 0;
if (mcp.getBondType() == BondType.Specified) {
index = mcp.getBondId();
} else {
index = sp.nextBondId();
}
// itemMap.put(b.toHtmlStringLong(mtp, mc, sp, index), b);
itemMap.put(b.toHtmlStringLong(sp, mtp, mc, index), b);
// itemMap.put(b.toHtmlStringLong(sp, index), b);
}
}
int index = 0;
Graphics gc = splitPaneHorizontal.getGraphics();
for (String name : itemMap.keySet()) {
JMenuItem menuItem = new JMenuItem(name);
if (index == 0) {
menuItem.setIcon(VCellIcons.rbmBondNoneIcon);
menuItem.setToolTipText("None");
popupFromShapeMenu.add(menuItem);
} else if (index == 1) {
menuItem.setIcon(VCellIcons.rbmBondExistsIcon);
menuItem.setToolTipText("Exists");
popupFromShapeMenu.add(menuItem);
} else if (index == 2) {
menuItem.setIcon(VCellIcons.rbmBondPossibleIcon);
menuItem.setToolTipText("Possible");
popupFromShapeMenu.add(menuItem);
} else if (index > 2) {
Bond b = itemMap.get(name);
// clone of the sp, with only the bond of interest
SpeciesPattern spBond = new SpeciesPattern(bioModel.getModel(), sp);
spBond.resetBonds();
spBond.resetStates();
MolecularTypePattern mtpFrom = spBond.getMolecularTypePattern(mtp.getMolecularType().getName(), mtp.getIndex());
MolecularComponentPattern mcpFrom = mtpFrom.getMolecularComponentPattern(mc);
MolecularTypePattern mtpTo = spBond.getMolecularTypePattern(b.molecularTypePattern.getMolecularType().getName(), b.molecularTypePattern.getIndex());
MolecularComponentPattern mcpTo = mtpTo.getMolecularComponentPattern(b.molecularComponentPattern.getMolecularComponent());
spBond.setBond(mtpTo, mcpTo, mtpFrom, mcpFrom);
Icon icon = new SpeciesPatternSmallShape(3, 4, spBond, gc, observable, false, issueManager);
((SpeciesPatternSmallShape) icon).setDisplayRequirements(DisplayRequirements.highlightBonds);
menuItem.setIcon(icon);
editBondMenu.add(menuItem);
// } else {
// if(index == 0) {
// menuItem.setForeground(Color.blue);
// }
// popupFromShapeMenu.add(menuItem);
}
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String name = e.getActionCommand();
BondType btBefore = mcp.getBondType();
if (name.equals(noneString)) {
if (btBefore == BondType.Specified) {
// specified -> not specified
// change the partner to possible
mcp.getBond().molecularComponentPattern.setBondType(BondType.Possible);
mcp.getBond().molecularComponentPattern.setBond(null);
}
mcp.setBondType(BondType.None);
mcp.setBond(null);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
observableTreeModel.populateTree();
}
});
} else if (name.equals(existsString)) {
if (btBefore == BondType.Specified) {
// specified -> exists
// change the partner to possible
mcp.getBond().molecularComponentPattern.setBondType(BondType.Possible);
mcp.getBond().molecularComponentPattern.setBond(null);
}
mcp.setBondType(BondType.Exists);
mcp.setBond(null);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
observableTreeModel.populateTree();
}
});
} else if (name.equals(possibleString)) {
if (btBefore == BondType.Specified) {
// specified -> possible
// change the partner to possible
mcp.getBond().molecularComponentPattern.setBondType(BondType.Possible);
mcp.getBond().molecularComponentPattern.setBond(null);
}
mcp.setBondType(BondType.Possible);
mcp.setBond(null);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
observableTreeModel.populateTree();
}
});
} else {
if (btBefore != BondType.Specified) {
// if we go from a non-specified to a specified we need to find the next available
// bond id, so that we can choose the color for displaying the bond
// a bad bond id, like -1, will crash badly when trying to choose the color
int bondId = sp.nextBondId();
mcp.setBondId(bondId);
} else {
// specified -> specified
// change the old partner to possible, continue using the bond id
mcp.getBond().molecularComponentPattern.setBondType(BondType.Possible);
mcp.getBond().molecularComponentPattern.setBond(null);
}
mcp.setBondType(BondType.Specified);
Bond b = itemMap.get(name);
mcp.setBond(b);
mcp.getBond().molecularComponentPattern.setBondId(mcp.getBondId());
sp.resolveBonds();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
observableTreeModel.populateTree();
}
});
}
}
});
index++;
}
popupFromShapeMenu.add(editBondMenu);
}
use of cbit.vcell.graph.SpeciesPatternSmallShape in project vcell by virtualcell.
the class SpeciesPropertiesPanel method manageComponentPatternFromShape.
public void manageComponentPatternFromShape(final RbmElementAbstract selectedObject, PointLocationInShapeContext locationContext, ShowWhat showWhat) {
popupFromShapeMenu.removeAll();
final MolecularComponentPattern mcp = (MolecularComponentPattern) selectedObject;
final MolecularComponent mc = mcp.getMolecularComponent();
// ------------------------------------------------------------------- State
if (showWhat == ShowWhat.ShowState && mc.getComponentStateDefinitions().size() != 0) {
String prefix = "State: ";
final Map<String, String> itemMap = new LinkedHashMap<String, String>();
// itemList.add(ComponentStatePattern.strAny); // any is not an option for state
String csdCurrentName;
for (final ComponentStateDefinition csd : mc.getComponentStateDefinitions()) {
csdCurrentName = "";
if (mcp.getComponentStatePattern() != null && !mcp.getComponentStatePattern().isAny()) {
ComponentStateDefinition csdCurrent = mcp.getComponentStatePattern().getComponentStateDefinition();
csdCurrentName = csdCurrent.getName();
}
String name = csd.getName();
if (name.equals(csdCurrentName)) {
// currently selected menu item is shown in bold
name = "<html>" + prefix + "<b>" + name + "</b></html>";
} else {
name = "<html>" + prefix + name + "</html>";
}
itemMap.put(name, csd.getName());
}
for (String name : itemMap.keySet()) {
JMenuItem menuItem = new JMenuItem(name);
popupFromShapeMenu.add(menuItem);
menuItem.setIcon(VCellIcons.rbmComponentStateIcon);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String key = e.getActionCommand();
String name = itemMap.get(key);
if (name.equals(ComponentStatePattern.strAny)) {
ComponentStatePattern csp = new ComponentStatePattern();
mcp.setComponentStatePattern(csp);
} else {
ComponentStateDefinition csd = mcp.getMolecularComponent().getComponentStateDefinition(name);
if (csd == null) {
throw new RuntimeException("Missing ComponentStateDefinition " + name + " for Component " + mcp.getMolecularComponent().getName());
}
ComponentStatePattern csp = new ComponentStatePattern(csd);
mcp.setComponentStatePattern(csp);
}
}
});
}
}
if (showWhat == ShowWhat.ShowState) {
return;
}
// ---------------------------------------------------------------------------- Bonds
final MolecularTypePattern mtp = locationContext.getMolecularTypePattern();
final SpeciesPattern sp = locationContext.getSpeciesPattern();
JMenu editBondMenu = new JMenu();
final String specifiedString = mcp.getBondType() == BondType.Specified ? "<html><b>" + "Site bond specified" + "</b></html>" : "<html>" + "Site bond specified" + "</html>";
editBondMenu.setText(specifiedString);
editBondMenu.setToolTipText("Specified");
editBondMenu.removeAll();
final Map<String, Bond> itemMap = new LinkedHashMap<String, Bond>();
String noneString = mcp.getBondType() == BondType.None ? "<html><b>" + "Site is unbound" + "</b></html>" : "<html>" + "Site is unbound" + "</html>";
itemMap.put(noneString, null);
// itemMap.put(possibleString, null); // not a valid option for species
if (mtp != null && sp != null) {
List<Bond> bondPartnerChoices = sp.getAllBondPartnerChoices(mtp, mc);
for (Bond b : bondPartnerChoices) {
// if(b.equals(mcp.getBond())) {
// continue; // if the mcp has a bond already we don't offer it
// }
int index = 0;
if (mcp.getBondType() == BondType.Specified) {
index = mcp.getBondId();
} else {
index = sp.nextBondId();
}
itemMap.put(b.toHtmlStringLong(sp, mtp, mc, index), b);
// itemMap.put(b.toHtmlStringLong(sp, index), b);
}
}
int index = 0;
Graphics gc = shapePanel.getGraphics();
for (String name : itemMap.keySet()) {
JMenuItem menuItem = new JMenuItem(name);
if (index == 0) {
menuItem.setIcon(VCellIcons.rbmBondNoneIcon);
menuItem.setToolTipText("None");
popupFromShapeMenu.add(menuItem);
} else {
Bond b = itemMap.get(name);
// clone of the sp, with only the bond of interest
SpeciesPattern spBond = new SpeciesPattern(bioModel.getModel(), sp);
spBond.resetBonds();
spBond.resetStates();
MolecularTypePattern mtpFrom = spBond.getMolecularTypePattern(mtp.getMolecularType().getName(), mtp.getIndex());
MolecularComponentPattern mcpFrom = mtpFrom.getMolecularComponentPattern(mc);
MolecularTypePattern mtpTo = spBond.getMolecularTypePattern(b.molecularTypePattern.getMolecularType().getName(), b.molecularTypePattern.getIndex());
MolecularComponentPattern mcpTo = mtpTo.getMolecularComponentPattern(b.molecularComponentPattern.getMolecularComponent());
spBond.setBond(mtpTo, mcpTo, mtpFrom, mcpFrom);
Icon icon = new SpeciesPatternSmallShape(3, 4, spBond, gc, fieldSpeciesContext, false, issueManager);
((SpeciesPatternSmallShape) icon).setDisplayRequirements(DisplayRequirements.highlightBonds);
menuItem.setIcon(icon);
editBondMenu.add(menuItem);
}
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String name = e.getActionCommand();
BondType btBefore = mcp.getBondType();
if (name.equals(noneString)) {
if (btBefore == BondType.Specified) {
// specified -> not specified
// change the partner to none since this is the only option
mcp.getBond().molecularComponentPattern.setBondType(BondType.None);
mcp.getBond().molecularComponentPattern.setBond(null);
}
mcp.setBondType(BondType.None);
mcp.setBond(null);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
speciesPropertiesTreeModel.populateTree();
}
});
} else {
if (btBefore != BondType.Specified) {
// if we go from a non-specified to a specified we need to find the next available
// bond id, so that we can choose the color for displaying the bond
// a bad bond id, like -1, will crash badly when trying to choose the color
int bondId = sp.nextBondId();
mcp.setBondId(bondId);
} else {
// specified -> specified
// change the old partner to none since it's the only available option, continue using the bond id
mcp.getBond().molecularComponentPattern.setBondType(BondType.None);
mcp.getBond().molecularComponentPattern.setBond(null);
}
mcp.setBondType(BondType.Specified);
Bond b = itemMap.get(name);
mcp.setBond(b);
mcp.getBond().molecularComponentPattern.setBondId(mcp.getBondId());
sp.resolveBonds();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
speciesPropertiesTreeModel.populateTree();
}
});
}
}
});
index++;
}
popupFromShapeMenu.add(editBondMenu);
}
use of cbit.vcell.graph.SpeciesPatternSmallShape in project vcell by virtualcell.
the class InitialConditionsPanel method initialize.
/**
* Initialize the class.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initialize() {
try {
// user code begin {1}
// user code end
setName("InitialConditionsPanel");
setLayout(new BorderLayout());
add(getRadioButtonAndCheckboxPanel(), BorderLayout.NORTH);
add(getScrollPaneTable().getEnclosingScrollPane(), BorderLayout.CENTER);
getScrollPaneTable().getSelectionModel().addListSelectionListener(ivjEventHandler);
getJMenuItemPaste().addActionListener(ivjEventHandler);
getJMenuItemCopy().addActionListener(ivjEventHandler);
getJMenuItemCopyAll().addActionListener(ivjEventHandler);
getJMenuItemPasteAll().addActionListener(ivjEventHandler);
getAmountRadioButton().addActionListener(ivjEventHandler);
getConcentrationRadioButton().addActionListener(ivjEventHandler);
getRandomizeInitCondnCheckbox().addActionListener(ivjEventHandler);
DefaultTableCellRenderer renderer = new DefaultScrollTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setIcon(null);
defaultToolTipText = null;
if (value instanceof Species) {
setText(((Species) value).getCommonName());
defaultToolTipText = getText();
setToolTipText(defaultToolTipText);
} else if (value instanceof SpeciesContext) {
setText(((SpeciesContext) value).getName());
defaultToolTipText = getText();
setToolTipText(defaultToolTipText);
} else if (value instanceof Structure) {
setText(((Structure) value).getName());
defaultToolTipText = getText();
setToolTipText(defaultToolTipText);
} else if (value instanceof ScopedExpression) {
SpeciesContextSpec scSpec = tableModel.getValueAt(row);
VCUnitDefinition unit = null;
if (table.getColumnName(column).equals(SpeciesContextSpecsTableModel.ColumnType.COLUMN_INITIAL.label)) {
SpeciesContextSpecParameter initialConditionParameter = scSpec.getInitialConditionParameter();
unit = initialConditionParameter.getUnitDefinition();
} else if (table.getColumnName(column).equals(SpeciesContextSpecsTableModel.ColumnType.COLUMN_DIFFUSION.label)) {
SpeciesContextSpecParameter diffusionParameter = scSpec.getDiffusionParameter();
unit = diffusionParameter.getUnitDefinition();
}
if (unit != null) {
setHorizontalTextPosition(JLabel.LEFT);
setIcon(new TextIcon("[" + unit.getSymbolUnicode() + "]", DefaultScrollTableCellRenderer.uneditableForeground));
}
int rgb = 0x00ffffff & DefaultScrollTableCellRenderer.uneditableForeground.getRGB();
defaultToolTipText = "<html>" + StringEscapeUtils.escapeHtml4(getText()) + " <font color=#" + Integer.toHexString(rgb) + "> [" + unit.getSymbolUnicode() + "] </font></html>";
setToolTipText(defaultToolTipText);
if (unit != null) {
setText(defaultToolTipText);
}
}
TableModel tableModel = table.getModel();
if (tableModel instanceof SortTableModel) {
DefaultScrollTableCellRenderer.issueRenderer(this, defaultToolTipText, table, row, column, (SortTableModel) tableModel);
setHorizontalTextPosition(JLabel.TRAILING);
}
return this;
}
};
DefaultTableCellRenderer rbmSpeciesShapeDepictionCellRenderer = new DefaultScrollTableCellRenderer() {
SpeciesPatternSmallShape spss = null;
@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 VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == tableModel) {
selectedObject = tableModel.getValueAt(row);
}
if (selectedObject != null) {
if (selectedObject instanceof SpeciesContextSpec) {
SpeciesContextSpec scs = (SpeciesContextSpec) selectedObject;
SpeciesContext sc = scs.getSpeciesContext();
// sp may be null for "plain" species contexts
SpeciesPattern sp = sc.getSpeciesPattern();
Graphics panelContext = table.getGraphics();
spss = new SpeciesPatternSmallShape(4, 2, sp, shapeManager, panelContext, sc, isSelected, issueManager);
}
} else {
spss = null;
}
}
setText("");
return this;
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (spss != null) {
spss.paintSelf(g);
}
}
};
getScrollPaneTable().setDefaultRenderer(SpeciesContext.class, renderer);
getScrollPaneTable().setDefaultRenderer(Structure.class, renderer);
getScrollPaneTable().setDefaultRenderer(SpeciesPattern.class, rbmSpeciesShapeDepictionCellRenderer);
getScrollPaneTable().setDefaultRenderer(Species.class, renderer);
getScrollPaneTable().setDefaultRenderer(ScopedExpression.class, renderer);
getScrollPaneTable().setDefaultRenderer(Boolean.class, new ScrollTableBooleanCellRenderer());
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
Aggregations