Search in sources :

Example 1 with SpatialProcessTableModel

use of cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel in project vcell by virtualcell.

the class DefaultScrollTableCellRenderer method isMatchWithSelectedObject.

private boolean isMatchWithSelectedObject(JTable table, int row) {
    SpatialProcessTableModel tm = (SpatialProcessTableModel) table.getModel();
    SelectionManager selectionManager = tm.getSelectionManager();
    boolean found = false;
    if (selectionManager != null) {
        for (Object ob : selectionManager.getSelectedObjects()) {
            if (ob instanceof SpatialObject) {
                // a SpatialObject selected
                List<SpatialProcess> spList = ((SpatialObject) ob).getRelatedSpatialProcesses();
                for (SpatialProcess theirs : spList) {
                    SpatialProcess ours = tm.getValueAt(row);
                    if (ours == theirs) {
                        found = true;
                        break;
                    }
                }
            }
            if (found == true) {
                break;
            }
        }
    }
    return found;
}
Also used : SelectionManager(cbit.vcell.client.desktop.biomodel.SelectionManager) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) PointObject(cbit.vcell.mapping.spatial.PointObject) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject) SpatialProcessTableModel(cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject)

Example 2 with SpatialProcessTableModel

use of cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel 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)

Example 3 with SpatialProcessTableModel

use of cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel in project vcell by virtualcell.

the class DefaultScrollTableCellRenderer method issueRenderer.

public static void issueRenderer(JLabel renderer, String defaultToolTipText, JTable table, int row, int column, SortTableModel tableModel) {
    List<Issue> issueListError = tableModel.getIssues(row, column, Issue.Severity.ERROR);
    List<Issue> issueListWarning = tableModel.getIssues(row, column, Issue.Severity.WARNING);
    Icon icon = null;
    Point mousePosition = table.getMousePosition();
    // hue, saturation, brightness
    Color red = Color.getHSBColor(0f, 0.4f, 1.0f);
    if (issueListError.size() > 0) {
        if (column == 0) {
            icon = VCellIcons.issueErrorIcon;
            if (mousePosition != null && mousePosition.getX() > LEFT_ICON_MARGIN && mousePosition.getX() <= (icon.getIconWidth() + LEFT_ICON_MARGIN)) {
                String tt = Issue.getHtmlIssueMessage(issueListError);
                renderer.setToolTipText(tt);
            } else {
                renderer.setToolTipText(defaultToolTipText);
            }
            // Color.red
            renderer.setBorder(new MatteBorder(1, 1, 1, 0, red));
        } else if (column == table.getColumnCount() - 1) {
            renderer.setBorder(new MatteBorder(1, 0, 1, 1, red));
        } else {
            renderer.setBorder(new MatteBorder(1, 0, 1, 0, red));
        }
    } else if (issueListWarning.size() > 0) {
        if (column == 0) {
            icon = VCellIcons.issueWarningIcon;
            if (mousePosition != null && mousePosition.getX() > LEFT_ICON_MARGIN && mousePosition.getX() <= (icon.getIconWidth() + LEFT_ICON_MARGIN)) {
                renderer.setToolTipText(Issue.getHtmlIssueMessage(issueListWarning));
            } else {
                renderer.setToolTipText(defaultToolTipText);
            }
            renderer.setBorder(new MatteBorder(1, 1, 1, 0, Color.orange));
        } else if (column == table.getColumnCount() - 1) {
            renderer.setBorder(new MatteBorder(1, 0, 1, 1, Color.orange));
        } else {
            renderer.setBorder(new MatteBorder(1, 0, 1, 0, Color.orange));
        }
    } else {
        if (column == 0) {
            icon = VCellIcons.issueGoodIcon;
            // no tooltip for column 0 when we have no issues on that line
            renderer.setToolTipText(null);
        }
        if (column != 0 && defaultToolTipText != null && !defaultToolTipText.isEmpty()) {
            renderer.setToolTipText(defaultToolTipText);
        } else {
            renderer.setToolTipText(null);
        }
        renderer.setBorder(DEFAULT_GAP);
    }
    if (column == 0 && icon != null) {
        // for some tables we combine (concatenate) the issue icon with an entity icon
        if (tableModel instanceof SpatialProcessTableModel) {
            Icon icon2 = null;
            SpatialProcess spatialProcess = (SpatialProcess) (((SpatialProcessTableModel) tableModel).getValueAt(row));
            if (spatialProcess instanceof PointLocation) {
                icon2 = VCellIcons.spatialLocationIcon;
            } else if (spatialProcess instanceof PointKinematics) {
                icon2 = VCellIcons.spatialKinematicsIcon;
            } else if (spatialProcess instanceof SurfaceKinematics) {
                icon2 = VCellIcons.spatialKinematicsIcon;
            } else {
                icon2 = VCellIcons.spatialKinematicsIcon;
            }
            icon = VCellIcons.addIcon(icon, icon2);
        } else if (tableModel instanceof SpatialObjectTableModel) {
            Icon icon2 = null;
            SpatialObject spatialObject = (SpatialObject) (((SpatialObjectTableModel) tableModel).getValueAt(row));
            if (spatialObject instanceof PointObject) {
                icon2 = VCellIcons.spatialPointIcon;
            } else if (spatialObject instanceof SurfaceRegionObject) {
                icon2 = VCellIcons.spatialMembraneIcon;
            } else if (spatialObject instanceof VolumeRegionObject) {
                icon2 = VCellIcons.spatialVolumeIcon;
            } else {
                icon2 = VCellIcons.spatialVolumeIcon;
            }
            icon = VCellIcons.addIcon(icon, icon2);
        }
    }
    renderer.setIcon(icon);
}
Also used : VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) Issue(org.vcell.util.Issue) PointLocation(cbit.vcell.mapping.spatial.processes.PointLocation) SurfaceKinematics(cbit.vcell.mapping.spatial.processes.SurfaceKinematics) Color(java.awt.Color) Point(java.awt.Point) SpatialObjectTableModel(cbit.vcell.client.desktop.biomodel.SpatialObjectTableModel) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) MatteBorder(javax.swing.border.MatteBorder) PointObject(cbit.vcell.mapping.spatial.PointObject) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) PointKinematics(cbit.vcell.mapping.spatial.processes.PointKinematics) Icon(javax.swing.Icon) SpatialProcessTableModel(cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject)

Aggregations

SpatialProcessTableModel (cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel)3 SpatialProcess (cbit.vcell.mapping.spatial.processes.SpatialProcess)3 SpatialObjectTableModel (cbit.vcell.client.desktop.biomodel.SpatialObjectTableModel)2 PointObject (cbit.vcell.mapping.spatial.PointObject)2 SpatialObject (cbit.vcell.mapping.spatial.SpatialObject)2 SurfaceRegionObject (cbit.vcell.mapping.spatial.SurfaceRegionObject)2 VolumeRegionObject (cbit.vcell.mapping.spatial.VolumeRegionObject)2 PointKinematics (cbit.vcell.mapping.spatial.processes.PointKinematics)2 PointLocation (cbit.vcell.mapping.spatial.processes.PointLocation)2 SurfaceKinematics (cbit.vcell.mapping.spatial.processes.SurfaceKinematics)2 Icon (javax.swing.Icon)2 ModelProcessEquation (cbit.gui.ModelProcessEquation)1 BioModelEditorApplicationsTableModel (cbit.vcell.client.desktop.biomodel.BioModelEditorApplicationsTableModel)1 BioModelEditorRightSideTableModel (cbit.vcell.client.desktop.biomodel.BioModelEditorRightSideTableModel)1 SelectionManager (cbit.vcell.client.desktop.biomodel.SelectionManager)1 SimulationContext (cbit.vcell.mapping.SimulationContext)1 NetworkConstraintsTableModel (cbit.vcell.mapping.gui.NetworkConstraintsTableModel)1 Color (java.awt.Color)1 Point (java.awt.Point)1 JComponent (javax.swing.JComponent)1