use of cbit.vcell.client.desktop.biomodel.BioModelEditorApplicationsTableModel in project vcell by virtualcell.
the class DefaultScrollTableCellRenderer method getTableCellRendererComponent.
/**
* Insert the method's description here.
* Creation date: (3/27/2001 1:07:02 PM)
* @return java.awt.Component
* @param table javax.swing.JTable
* @param value java.lang.Object
* @param isSelected boolean
* @param hasFocus boolean
* @param row int
* @param column int
*/
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
defaultToolTipText = null;
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
defaultToolTipText = getToolTipText();
setBorder(DEFAULT_GAP);
if (isSelected) {
setBackground(table.getSelectionBackground());
setForeground(table.getSelectionForeground());
} else {
if (table instanceof ScrollTable && ((ScrollTable) table).getHoverRow() == row) {
setBackground(hoverColor);
} else {
setBackground(row % 2 == 0 ? table.getBackground() : everyOtherRowColor);
}
if (table.getModel() instanceof SpatialProcessTableModel) /* && column == SpatialProcessTableModel.COLUMN_SpatialProcess_SPATIALOBJECTS */
{
boolean found = isMatchWithSelectedObject(table, row);
if (found == true) {
setBackground(Color.yellow);
}
} else if (table.getModel() instanceof SpatialObjectTableModel) /* && column == SpatialObjectTableModel.COLUMN_SpatialObject_NAME */
{
boolean found = isMatchWithSelectedProcess(table, row);
if (found == true) {
setBackground(Color.yellow);
}
}
setForeground(table.getForeground());
}
TableModel tableModel = table.getModel();
if (bEnableUneditableForeground && (!table.isEnabled() || !tableModel.isCellEditable(row, column))) {
if (!isSelected) {
setForeground(uneditableForeground);
if (tableModel instanceof NetworkConstraintsTableModel && column == NetworkConstraintsTableModel.iColValue) {
NetworkConstraintsTableModel tm = (NetworkConstraintsTableModel) tableModel;
String def = (String) tm.getValueAt(row, NetworkConstraintsTableModel.iColDefault);
String val = (String) value;
if (!val.equals(def)) {
value = "<html><b>" + value + "</b></html>";
setForeground(Color.red);
}
}
}
}
if (value instanceof Double) {
Double doubleValue = (Double) value;
setText(nicelyFormattedDouble(doubleValue));
} else if (value instanceof JComponent) {
JComponent jc = (JComponent) value;
if (hasFocus) {
jc.setBorder(focusHighlightBorder);
} else {
jc.setBorder(noFocusBorder);
}
return jc;
}
if (BioModelEditorRightSideTableModel.ADD_NEW_HERE_TEXT.equals(value)) {
setText(BioModelEditorRightSideTableModel.ADD_NEW_HERE_HTML);
} else if (value instanceof ModelProcessEquation && BioModelEditorRightSideTableModel.ADD_NEW_HERE_REACTION_TEXT.equals(((ModelProcessEquation) value).toString())) {
setText(BioModelEditorRightSideTableModel.ADD_NEW_REACTION_OR_RULE_HTML);
}
if (tableModel instanceof BioModelEditorApplicationsTableModel) {
// for the applications table we show the icons with the app type
Icon icon = null;
String toolTipSuffix = "";
BioModelEditorApplicationsTableModel bmeatm = (BioModelEditorApplicationsTableModel) tableModel;
SimulationContext simContext = (SimulationContext) (bmeatm.getValueAt(row));
if (simContext.isRuleBased()) {
if (simContext.getGeometry().getDimension() == 0) {
icon = VCellIcons.appRbmNonspIcon;
toolTipSuffix = "Rule Based / Non spatial";
}
} else if (simContext.isStoch()) {
if (simContext.getGeometry().getDimension() == 0) {
icon = VCellIcons.appStoNonspIcon;
toolTipSuffix = "Stochastic / Non spatial";
} else {
icon = VCellIcons.appStoSpatialIcon;
toolTipSuffix = "Stochastic / Spatial";
}
} else {
// deterministic
if (simContext.getGeometry().getDimension() == 0) {
icon = VCellIcons.appDetNonspIcon;
toolTipSuffix = "Deterministic / Non spatial";
} else {
icon = VCellIcons.appDetSpatialIcon;
toolTipSuffix = "Deterministic / Spatial";
}
}
String toolTipPrefix = "Application: ";
setToolTipText(toolTipPrefix + toolTipSuffix);
if (column == 0) {
setIcon(icon);
} else {
setIcon(null);
}
} else if (column == 2 && tableModel instanceof SpatialProcessTableModel) {
Icon icon = null;
SpatialProcess spatialProcess = (SpatialProcess) (((SpatialProcessTableModel) tableModel).getValueAt(row));
if (spatialProcess instanceof PointLocation) {
icon = VCellIcons.spatialPointIcon;
} else if (spatialProcess instanceof PointKinematics) {
icon = VCellIcons.spatialPointIcon;
} else if (spatialProcess instanceof SurfaceKinematics) {
icon = VCellIcons.spatialMembraneIcon;
} else {
icon = VCellIcons.spatialVolumeIcon;
}
setIcon(icon);
} else if (tableModel instanceof SortTableModel) {
// for most other tables we reserve the icon spot to display issues
DefaultScrollTableCellRenderer.issueRenderer(this, defaultToolTipText, table, row, column, (SortTableModel) tableModel);
}
return this;
}
Aggregations