Search in sources :

Example 21 with SpatialObject

use of cbit.vcell.mapping.spatial.SpatialObject in project vcell by virtualcell.

the class SpatialObjectDisplayPanel method deleteButtonPressed.

@Override
protected void deleteButtonPressed() {
    int[] rows = table.getSelectedRows();
    ArrayList<SpatialObject> deleteList = new ArrayList<SpatialObject>();
    for (int r : rows) {
        if (r < tableModel.getRowCount()) {
            SpatialObject spatialObject = tableModel.getValueAt(r);
            if (spatialObject != null) {
                deleteList.add(spatialObject);
            }
        }
    }
    try {
        for (SpatialObject spatialObject : deleteList) {
            simulationContext.removeSpatialObject(spatialObject);
        }
    } catch (PropertyVetoException ex) {
        ex.printStackTrace();
        DialogUtils.showErrorDialog(this, ex.getMessage());
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ArrayList(java.util.ArrayList) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject)

Example 22 with SpatialObject

use of cbit.vcell.mapping.spatial.SpatialObject in project vcell by virtualcell.

the class SpatialObjectTableModel method propertyChange.

@Override
public void propertyChange(java.beans.PropertyChangeEvent evt) {
    super.propertyChange(evt);
    if (evt.getPropertyName().equals("spatialObjects")) {
        SpatialObject[] oldValue = (SpatialObject[]) evt.getOldValue();
        if (oldValue != null) {
            for (SpatialObject rr : oldValue) {
                rr.removePropertyChangeListener(this);
            }
        }
        SpatialObject[] newValue = (SpatialObject[]) evt.getNewValue();
        if (newValue != null) {
            for (SpatialObject rr : newValue) {
                rr.addPropertyChangeListener(this);
            }
        }
    }
    refreshData();
}
Also used : SpatialObject(cbit.vcell.mapping.spatial.SpatialObject)

Example 23 with SpatialObject

use of cbit.vcell.mapping.spatial.SpatialObject in project vcell by virtualcell.

the class SpatialObjectPropertyPanel method setSpatialObject.

/**
 * Set the SpeciesContextSpec to a new value.
 * @param newValue cbit.vcell.mapping.SpeciesContextSpec
 */
void setSpatialObject(SpatialObject newValue) {
    SpatialObject oldSpatialObject = this.spatialObject;
    this.spatialObject = newValue;
    getSpatialQuantityTableModel().setSpatialObject(this.spatialObject);
    for (JCheckBox checkbox : this.optionsCheckboxes) {
        checkbox.removeActionListener(actionListener);
    }
    optionsCheckboxes.clear();
    optionsPanel.removeAll();
    if (spatialObject != null) {
        for (QuantityCategory category : spatialObject.getQuantityCategories()) {
            JCheckBox checkbox = new JCheckBox();
            checkbox.addActionListener(actionListener);
            checkbox.setText(category.description);
            checkbox.setSelected(spatialObject.isQuantityCategoryEnabled(category));
            checkbox.setBackground(Color.lightGray.brighter());
            // TODO: disable features not supported yet
            if (spatialObject instanceof SurfaceRegionObject) {
                if (category.xmlName.contentEquals(QuantityCategory.SurfaceDistanceMap.xmlName)) {
                    checkbox.setEnabled(false);
                }
                if (category.xmlName.contentEquals(QuantityCategory.DirectionToSurface.xmlName)) {
                    checkbox.setEnabled(false);
                }
            }
            if (spatialObject instanceof VolumeRegionObject) {
                if (category.xmlName.contentEquals(QuantityCategory.Centroid.xmlName)) {
                    checkbox.setEnabled(false);
                }
            }
            optionsPanel.add(checkbox);
            System.out.println("adding checkbox for " + checkbox.getText());
            optionsCheckboxes.add(checkbox);
        }
    }
    optionsPanel.revalidate();
}
Also used : JCheckBox(javax.swing.JCheckBox) VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) QuantityCategory(cbit.vcell.mapping.spatial.SpatialObject.QuantityCategory) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject)

Example 24 with SpatialObject

use of cbit.vcell.mapping.spatial.SpatialObject in project vcell by virtualcell.

the class SpatialObjectPropertyPanel method onSelectedObjectsChange.

@Override
protected void onSelectedObjectsChange(Object[] selectedObjects) {
    SpatialObject spatialObject = null;
    if (selectedObjects != null && selectedObjects.length == 1 && selectedObjects[0] instanceof SpatialObject) {
        spatialObject = (SpatialObject) selectedObjects[0];
    }
    setSpatialObject(spatialObject);
}
Also used : SpatialObject(cbit.vcell.mapping.spatial.SpatialObject)

Example 25 with SpatialObject

use of cbit.vcell.mapping.spatial.SpatialObject 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

SpatialObject (cbit.vcell.mapping.spatial.SpatialObject)29 SpatialProcess (cbit.vcell.mapping.spatial.processes.SpatialProcess)18 SurfaceRegionObject (cbit.vcell.mapping.spatial.SurfaceRegionObject)9 VolumeRegionObject (cbit.vcell.mapping.spatial.VolumeRegionObject)9 BioEvent (cbit.vcell.mapping.BioEvent)8 SimulationContext (cbit.vcell.mapping.SimulationContext)8 PointObject (cbit.vcell.mapping.spatial.PointObject)8 AssignmentRule (cbit.vcell.mapping.AssignmentRule)7 RateRule (cbit.vcell.mapping.RateRule)7 ReactionStep (cbit.vcell.model.ReactionStep)7 Geometry (cbit.vcell.geometry.Geometry)6 SimulationContextParameter (cbit.vcell.mapping.SimulationContext.SimulationContextParameter)6 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)6 StructureMapping (cbit.vcell.mapping.StructureMapping)6 ArrayList (java.util.ArrayList)6 Element (org.jdom.Element)6 ReactionRule (cbit.vcell.model.ReactionRule)5 SpeciesContext (cbit.vcell.model.SpeciesContext)5 NetworkConstraints (org.vcell.model.rbm.NetworkConstraints)5 BioModel (cbit.vcell.biomodel.BioModel)4