Search in sources :

Example 1 with BioModelEditorApplicationsTableModel

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;
}
Also used : SortTableModel(org.vcell.util.gui.sorttable.SortTableModel) PointLocation(cbit.vcell.mapping.spatial.processes.PointLocation) SurfaceKinematics(cbit.vcell.mapping.spatial.processes.SurfaceKinematics) JComponent(javax.swing.JComponent) NetworkConstraintsTableModel(cbit.vcell.mapping.gui.NetworkConstraintsTableModel) SpatialObjectTableModel(cbit.vcell.client.desktop.biomodel.SpatialObjectTableModel) SimulationContext(cbit.vcell.mapping.SimulationContext) BioModelEditorApplicationsTableModel(cbit.vcell.client.desktop.biomodel.BioModelEditorApplicationsTableModel) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) PointKinematics(cbit.vcell.mapping.spatial.processes.PointKinematics) ModelProcessEquation(cbit.gui.ModelProcessEquation) SpatialProcessTableModel(cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel) Icon(javax.swing.Icon) BioModelEditorRightSideTableModel(cbit.vcell.client.desktop.biomodel.BioModelEditorRightSideTableModel) BioModelEditorApplicationsTableModel(cbit.vcell.client.desktop.biomodel.BioModelEditorApplicationsTableModel) NetworkConstraintsTableModel(cbit.vcell.mapping.gui.NetworkConstraintsTableModel) SpatialProcessTableModel(cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel) TableModel(javax.swing.table.TableModel) SortTableModel(org.vcell.util.gui.sorttable.SortTableModel) SpatialObjectTableModel(cbit.vcell.client.desktop.biomodel.SpatialObjectTableModel)

Aggregations

ModelProcessEquation (cbit.gui.ModelProcessEquation)1 BioModelEditorApplicationsTableModel (cbit.vcell.client.desktop.biomodel.BioModelEditorApplicationsTableModel)1 BioModelEditorRightSideTableModel (cbit.vcell.client.desktop.biomodel.BioModelEditorRightSideTableModel)1 SpatialObjectTableModel (cbit.vcell.client.desktop.biomodel.SpatialObjectTableModel)1 SpatialProcessTableModel (cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel)1 SimulationContext (cbit.vcell.mapping.SimulationContext)1 NetworkConstraintsTableModel (cbit.vcell.mapping.gui.NetworkConstraintsTableModel)1 PointKinematics (cbit.vcell.mapping.spatial.processes.PointKinematics)1 PointLocation (cbit.vcell.mapping.spatial.processes.PointLocation)1 SpatialProcess (cbit.vcell.mapping.spatial.processes.SpatialProcess)1 SurfaceKinematics (cbit.vcell.mapping.spatial.processes.SurfaceKinematics)1 Icon (javax.swing.Icon)1 JComponent (javax.swing.JComponent)1 TableModel (javax.swing.table.TableModel)1 SortTableModel (org.vcell.util.gui.sorttable.SortTableModel)1