use of org.vcell.util.gui.DefaultScrollTableCellRenderer in project vcell by virtualcell.
the class BioModelEditorRightSidePanel method initialize.
private void initialize() {
addNewButton = new JButton("New Application");
deleteButton = new JButton("Delete");
textFieldSearch = new JTextField(10);
textFieldSearch.putClientProperty("JTextField.variant", "search");
table = new EditorScrollTable();
tableModel = createTableModel();
table.setModel(tableModel);
table.setDefaultRenderer(Structure.class, new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof Structure) {
setText(((Structure) value).getName());
}
return this;
}
});
addNewButton.addActionListener(eventHandler);
deleteButton.addActionListener(eventHandler);
deleteButton.setEnabled(false);
textFieldSearch.getDocument().addDocumentListener(eventHandler);
table.getSelectionModel().addListSelectionListener(eventHandler);
}
use of org.vcell.util.gui.DefaultScrollTableCellRenderer in project vcell by virtualcell.
the class ViewJobsPanel method initialize.
private void initialize() {
try {
setName("ViewSimulationJobsPanel");
// initialize the time button group and its components
getTimeGroup();
// ----------------------------------------------------------------------------------
// filters, buttons
JPanel top = new JPanel();
// table with results
JPanel bottom = new JPanel();
Border loweredEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
TitledBorder titleTop = BorderFactory.createTitledBorder(loweredEtchedBorder, " User Options ");
titleTop.setTitleJustification(TitledBorder.LEFT);
titleTop.setTitlePosition(TitledBorder.TOP);
TitledBorder titleBottom = BorderFactory.createTitledBorder(loweredEtchedBorder, " Query Results ");
titleBottom.setTitleJustification(TitledBorder.LEFT);
titleBottom.setTitlePosition(TitledBorder.TOP);
top.setBorder(titleTop);
bottom.setBorder(titleBottom);
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
// top, left, bottom, right
gbc.insets = new Insets(2, 2, 2, 3);
add(top, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 2, 2, 3);
add(bottom, gbc);
// --------------------------------------- top panel (filters, button) --------------
// filters
JPanel left = new JPanel();
TitledBorder titleLeft = BorderFactory.createTitledBorder(loweredEtchedBorder, " Status Filter ");
titleLeft.setTitleJustification(TitledBorder.LEFT);
titleLeft.setTitlePosition(TitledBorder.TOP);
left.setBorder(titleLeft);
JPanel center = new SeparatedJPanel();
// Dimension dim = new Dimension(200, 100);
// center.setMinimumSize(dim);
top.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 2, 1, 3);
top.add(left, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.insets = new Insets(3, 8, 2, 3);
top.add(getOrphanedButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 8, 2, 3);
top.add(getRefreshAllButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 2;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.gridheight = 2;
gbc.anchor = GridBagConstraints.NORTH;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 2, 2, 3);
top.add(center, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 3;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridheight = 2;
gbc.anchor = GridBagConstraints.NORTHEAST;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(2, 2, 2, 3);
top.add(getPropertiesPanel(), gbc);
// ------------------------------------ left panel (of top panel) -------------
left.setLayout(new GridBagLayout());
int gridy = 0;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 2, 0, 0);
left.add(getWaitingButton(), gbc);
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 3);
JLabel label = new JLabel(waitingIcon);
label.setText(" ");
left.add(label, gbc);
gbc.gridx = 2;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 15, 0, 0);
left.add(getQueuedButton(), gbc);
gbc.gridx = 3;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 10);
label = new JLabel(queuedIcon);
label.setText(" ");
left.add(label, gbc);
// -------------------------------------
gridy++;
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 2, 0, 0);
left.add(getDispatchedButton(), gbc);
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 3);
label = new JLabel(dispatchedIcon);
label.setText(" ");
left.add(label, gbc);
gbc.gridx = 2;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 15, 0, 0);
left.add(getRunningButton(), gbc);
gbc.gridx = 3;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 10);
label = new JLabel(runningIcon);
label.setText(" ");
left.add(label, gbc);
// -------------------------------------
gridy++;
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 2, 0, 0);
left.add(getCompletedButton(), gbc);
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 3);
label = new JLabel(completedIcon);
label.setText(" ");
left.add(label, gbc);
gbc.gridx = 2;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 15, 0, 0);
left.add(getFailedButton(), gbc);
gbc.gridx = 3;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 10);
label = new JLabel(failedIcon);
label.setText(" ");
left.add(label, gbc);
// -------------------------------------
gridy++;
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 2, 0, 0);
left.add(getStoppedButton(), gbc);
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 3);
label = new JLabel(stoppedIcon);
label.setText(" ");
left.add(label, gbc);
// ---------------------------------------- center panel (of top panel) ------------
center.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(4, 15, 4, 4);
center.add(new JLabel("Max # of results "), gbc);
textFieldJobsLimit = new JTextField();
textFieldJobsLimit.addActionListener(eventHandler);
// textFieldJobsLimit.getDocument().addDocumentListener(eventHandler);
textFieldJobsLimit.setText(maxRows + "");
Dimension d = textFieldJobsLimit.getPreferredSize();
d.width = 60;
textFieldJobsLimit.setPreferredSize(d);
textFieldJobsLimit.setMaximumSize(d);
textFieldJobsLimit.setMinimumSize(d);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(4, 0, 4, 4);
center.add(textFieldJobsLimit, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 11, 2, 4);
center.add(getSubmitDatePanel(), gbc);
getCompletedButton().setSelected(false);
getDispatchedButton().setSelected(true);
getFailedButton().setSelected(true);
getQueuedButton().setSelected(true);
getRunningButton().setSelected(true);
getStoppedButton().setSelected(true);
getWaitingButton().setSelected(true);
getOrphanedButton().setSelected(false);
getPastMonthRadio().setSelected(true);
// ----------------------------------------- bottom panel (the table) -------------------
table = new EditorScrollTable();
model = new SimulationJobsTableModel(table, this);
table.setModel(model);
table.getSelectionModel().addListSelectionListener(eventHandler);
table.getModel().addTableModelListener(eventHandler);
table.addMouseMotionListener(new // add toolTipText for each table cell
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)));
}
});
bottom.setLayout(new GridBagLayout());
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(700,350)); // apparently useless
bottom.add(table.getEnclosingScrollPane(), gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(4, 4, 4, 4);
bottom.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);
bottom.add(textFieldSearch, gbc);
// gbc = new GridBagConstraints();
// gbc.gridx = 4;
// gbc.gridy = gridy;
// gbc.fill = GridBagConstraints.HORIZONTAL;
// gbc.insets = new Insets(4, 4, 4, 10);
// bottom.add(getShowQuotaButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 4;
gbc.gridy = gridy;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 10);
bottom.add(countLabel, gbc);
// renderer for the status icon; the tooltip gives the text
DefaultScrollTableCellRenderer statusCellRenderer = 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);
setText((String) value);
if (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == model) {
selectedObject = model.getValueAt(row);
}
if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
SimpleJobStatus js = (SimpleJobStatus) selectedObject;
SchedulerStatus ss1 = js.jobStatus.getSchedulerStatus();
switch(ss1) {
case WAITING:
setIcon(waitingIcon);
break;
case QUEUED:
setIcon(queuedIcon);
break;
case DISPATCHED:
setIcon(dispatchedIcon);
break;
case RUNNING:
setIcon(runningIcon);
break;
case COMPLETED:
setIcon(completedIcon);
break;
case STOPPED:
setIcon(stoppedIcon);
break;
case FAILED:
setIcon(failedIcon);
break;
default:
setIcon(failedIcon);
break;
}
// setText("");
setToolTipText(ss1.getDescription());
setHorizontalTextPosition(SwingConstants.RIGHT);
}
}
return this;
}
};
// statusCellRenderer.setHorizontalAlignment(JLabel.RIGHT);
DefaultScrollTableCellRenderer dateTimeCellRenderer = 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);
setText((String) value);
if (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == model) {
selectedObject = model.getValueAt(row);
}
if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
SimpleJobStatus sjs = (SimpleJobStatus) selectedObject;
DateFormat df = new SimpleDateFormat("MM.dd.yyyy HH:MM:SS");
Date date = sjs.jobStatus.getSubmitDate();
String str = "";
if (date != null) {
str = df.format(date);
}
setToolTipText(str);
}
}
return this;
}
};
DefaultScrollTableCellRenderer hasDataCellRenderer = 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);
setText((String) value);
if (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == model) {
selectedObject = model.getValueAt(row);
}
if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
SimpleJobStatus sjs = (SimpleJobStatus) selectedObject;
if (sjs.jobStatus.hasData()) {
setIcon(dataYesIcon);
} else {
setIcon(dataNoIcon);
}
}
}
return this;
}
};
table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setCellRenderer(statusCellRenderer);
table.getColumnModel().getColumn(SimulationJobsTableModel.iColSubmitDate).setCellRenderer(dateTimeCellRenderer);
table.getColumnModel().getColumn(SimulationJobsTableModel.iColHasData).setCellRenderer(hasDataCellRenderer);
// table.getColumnModel().getColumn(SimulationJobsTableModel.iColDepiction).setMinWidth(400);
// table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setPreferredWidth(30);
// table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setMaxWidth(30);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
refreshInterface();
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of org.vcell.util.gui.DefaultScrollTableCellRenderer 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);
// we work with a "fake" model and cannot show proper molecule color
shapePanel.setShowMoleculeColor(false);
shapePanel.setShowNonTrivialOnly(false);
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, ssm, 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 org.vcell.util.gui.DefaultScrollTableCellRenderer in project vcell by virtualcell.
the class ParameterEstimationPanel method initialize.
@Override
protected void initialize() {
super.initialize();
setName("Parameter Estimation");
setLayout(new java.awt.BorderLayout());
referenceDataPanel = new ReferenceDataPanel();
runTaskPanel = new ParameterEstimationRunTaskPanel();
getparameterMappingPanel().setBorder(GuiConstants.TAB_PANEL_BORDER);
referenceDataPanel.setBorder(GuiConstants.TAB_PANEL_BORDER);
getDataMappingPanel().setBorder(GuiConstants.TAB_PANEL_BORDER);
runTaskPanel.setBorder(GuiConstants.TAB_PANEL_BORDER);
tabbedPane.addTab(ParameterEstimationPanelTabID.parameters.title, getparameterMappingPanel());
tabbedPane.addTab(ParameterEstimationPanelTabID.experimental_data_import.title, referenceDataPanel);
tabbedPane.addTab(ParameterEstimationPanelTabID.experimental_data_mapping.title, getDataMappingPanel());
tabbedPane.addTab(ParameterEstimationPanelTabID.run_task.title, runTaskPanel);
add(tabbedPane, BorderLayout.CENTER);
add(getButtonPanel(), BorderLayout.NORTH);
getNewAnalysisTaskButton().addActionListener(eventHandler);
getDeleteAnalysisTaskButton().addActionListener(eventHandler);
getCopyButton().addActionListener(eventHandler);
getAnalysisTaskComboBox().addActionListener(eventHandler);
getMapButton().addActionListener(eventHandler);
getEvaluateConfidenceIntervalButton().addActionListener(eventHandler);
getDataModelMappingTable().getSelectionModel().addListSelectionListener(eventHandler);
dataModelMappingTable.addMouseListener(eventHandler);
getDataModelMappingTable().setDefaultRenderer(SymbolTableEntry.class, new DefaultScrollTableCellRenderer() {
public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value == null) {
setText("unmapped");
return this;
}
SymbolTableEntry ste = (SymbolTableEntry) value;
if (ste instanceof Model.ReservedSymbol) {
setText(ste.getName());
} else if (ste instanceof SpeciesContext) {
setText("[" + ste.getName() + "]");
} else if (ste instanceof KineticsParameter) {
setText(ste.getNameScope().getName() + ":" + ste.getName());
} else if (ste instanceof ModelParameter) {
setText(ste.getName());
} else if (ste instanceof ReservedVariable) {
setText(ste.getName());
} else {
setText(ste.getNameScope().getAbsoluteScopePrefix() + ste.getName());
}
return this;
}
});
getDataModelMappingTable().setModel(getreferenceDataMappingSpecTableModel());
getDataModelMappingTable().createDefaultColumnsFromModel();
}
use of org.vcell.util.gui.DefaultScrollTableCellRenderer in project vcell by virtualcell.
the class BioModelParametersPanel method initialize.
private void initialize() {
addNewButton = new JButton("New Global Parameter");
addNewButton.addActionListener(eventHandler);
addNewButton2 = new JButton("New Application Parameter");
// addNewButton2.setIcon(downArrow);
addNewButton2.setHorizontalTextPosition(SwingConstants.LEFT);
addNewButton2.addActionListener(eventHandler);
deleteButton = new JButton("Delete");
deleteButton.setEnabled(false);
deleteButton.addActionListener(eventHandler);
changeUnitsButton = new JButton("Change Unit System");
changeUnitsButton.addActionListener(eventHandler);
textFieldSearch = new JTextField(10);
textFieldSearch.getDocument().addDocumentListener(eventHandler);
textFieldSearch.putClientProperty("JTextField.variant", "search");
parametersFunctionsTable = new EditorScrollTable();
parametersFunctionsTableModel = new BioModelParametersTableModel(parametersFunctionsTable);
parametersFunctionsTable.setModel(parametersFunctionsTableModel);
globalParametersCheckBox = new JCheckBox("Global");
globalParametersCheckBox.setSelected(true);
globalParametersCheckBox.addActionListener(eventHandler);
reactionsCheckBox = new JCheckBox("Reactions and Rules");
reactionsCheckBox.setSelected(true);
reactionsCheckBox.addActionListener(eventHandler);
applicationsCheckBox = new JCheckBox("Applications");
applicationsCheckBox.setSelected(true);
applicationsCheckBox.addActionListener(eventHandler);
applicationComboBox = new JComboBox<ApplicationSelection>();
applicationComboBox.setSelectedItem("All");
applicationComboBox.addActionListener(eventHandler);
applicationComboBox.setModel(applicationComboBoxModel);
applicationComboBox.setRenderer(new ApplicationComboBoxRenderer());
constantsCheckBox = new JCheckBox("Parameters");
constantsCheckBox.setSelected(true);
constantsCheckBox.addActionListener(eventHandler);
functionsCheckBox = new JCheckBox("Functions");
functionsCheckBox.setSelected(true);
functionsCheckBox.addActionListener(eventHandler);
predefinedSymbolsTable = new EditorScrollTable();
predefinedSymbolsTableModel = new PredefinedSymbolsTableModel(predefinedSymbolsTable);
predefinedSymbolsTable.setModel(predefinedSymbolsTableModel);
GuiUtils.flexResizeTableColumns(predefinedSymbolsTable);
modelUnitSystemTable = new EditorScrollTable();
modelUnitSystemTableModel = new ModelUnitSystemTableModel(modelUnitSystemTable);
modelUnitSystemTable.setModel(modelUnitSystemTableModel);
GuiUtils.flexResizeTableColumns(modelUnitSystemTable);
tabbedPane = new JTabbedPaneEnhanced();
tabbedPane.addChangeListener(eventHandler);
ParametersPanelTab[] parametersPanelTabs = new ParametersPanelTab[ParametersPanelTabID.values().length];
parametersPanelTabs[ParametersPanelTabID.parameters_functions.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.parameters_functions, getParametersFunctionsPanel(), null);
parametersPanelTabs[ParametersPanelTabID.predefined.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.predefined, getPredefinedSymbolsPanel(), null);
parametersPanelTabs[ParametersPanelTabID.modelUnitSystem.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.modelUnitSystem, getModelUnitSystemPanel(), null);
for (ParametersPanelTab tab : parametersPanelTabs) {
tab.component.setBorder(GuiConstants.TAB_PANEL_BORDER);
tabbedPane.addTab(tab.id.title, tab.icon, tab.component);
}
JPanel buttonPanel = new JPanel(new GridBagLayout());
int gridy = 0;
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(addNewButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(addNewButton2, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(deleteButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(changeUnitsButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.insets = new Insets(4, 50, 4, 4);
buttonPanel.add(new JLabel("Search"), gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 4);
buttonPanel.add(textFieldSearch, gbc);
setLayout(new BorderLayout());
add(tabbedPane, BorderLayout.CENTER);
add(buttonPanel, BorderLayout.SOUTH);
parametersFunctionsTable.getSelectionModel().addListSelectionListener(eventHandler);
parametersFunctionsTable.setDefaultRenderer(NameScope.class, new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof NameScope) {
NameScope nameScope = (NameScope) value;
String text = nameScope.getPathDescription();
setText(text);
}
return this;
}
});
DefaultScrollTableCellRenderer nameTableCellRenderer = new DefaultScrollTableCellRenderer() {
final Color lightBlueBackground = new Color(214, 234, 248);
int PADDING = 3;
@Override
public void setBounds(int x, int y, int width, int height) {
super.setBounds(x, y, width, height);
if (getIcon() != null) {
int textWidth = getFontMetrics(getFont()).stringWidth(getText());
Insets insets = getInsets();
// TODO: check that the text width is not bigger than the cell width and truncate the name
int iconTextGap = width - textWidth - getIcon().getIconWidth() - insets.left - insets.right - PADDING;
setIconTextGap(iconTextGap);
} else {
setIconTextGap(0);
}
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (table.getModel() instanceof BioModelParametersTableModel) {
BioModelParametersTableModel tableModel = (BioModelParametersTableModel) table.getModel();
Object selectedObject = tableModel.getValueAt(row);
setToolTipText(null);
if (selectedObject instanceof ModelParameter || selectedObject instanceof SpeciesContext) {
SymbolTableEntry ste = (SymbolTableEntry) selectedObject;
RateRule rr = null;
AssignmentRule ar = null;
for (SimulationContext simContext : bioModel.getSimulationContexts()) {
rr = simContext.getRateRule(ste);
ar = simContext.getAssignmentRule(ste);
if (rr != null || ar != null) {
break;
}
}
Icon icon = null;
if (rr != null) {
String text = "<html>The default value of this entity is being overriden by a Rate Rule in one or more applications</html>";
icon = VCellIcons.ruleRateIcon;
setToolTipText(text);
} else if (ar != null) {
String text = "<html>The default value of this entity is being overriden by an Assignment Rule in one or more applications</html>";
icon = VCellIcons.ruleAssignIcon;
setToolTipText(text);
}
setIcon(icon);
this.setHorizontalTextPosition(SwingConstants.LEFT);
if (isSelected) {
setBackground(lightBlueBackground);
setForeground(Color.BLACK);
}
}
}
return this;
}
};
parametersFunctionsTable.getColumnModel().getColumn(BioModelParametersTableModel.COLUMN_NAME).setCellRenderer(nameTableCellRenderer);
{
// make double click on units panel bring up editing box
JPanel p = getModelUnitSystemPanel();
VCAssert.assertValid(p);
EditorScrollTable est = GuiUtils.findFirstChild(p, EditorScrollTable.class);
VCAssert.assertValid(est);
MouseListener ml = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
changeUnitsButtonPressed();
}
}
};
est.addMouseListener(ml);
}
}
Aggregations