use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class GeometryFilamentCurvePanel method setGeometry2.
/**
* Set the Geometry2 to a new value.
* @param newValue cbit.vcell.geometry.Geometry
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void setGeometry2(cbit.vcell.geometry.Geometry newValue) {
if (ivjGeometry2 != newValue) {
try {
cbit.vcell.geometry.Geometry oldValue = getGeometry2();
ivjGeometry2 = newValue;
connPtoP9SetSource();
connEtoM2(ivjGeometry2);
firePropertyChange("geometry", oldValue, newValue);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
;
// user code begin {3}
// user code end
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class VCellBasicCellRenderer method getTreeCellRendererComponent.
/**
* Insert the method's description here.
* Creation date: (7/27/2000 6:41:57 PM)
* @return java.awt.Component
*/
public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
//
if (!leaf && expanded) {
setIcon(fieldFolderOpenIcon);
} else if (!leaf && !expanded) {
setIcon(fieldFolderClosedIcon);
}
try {
if (value instanceof BioModelNode) {
BioModelNode node = (BioModelNode) value;
boolean bLoaded = false;
//
// Check if node is a SolverResultSetInfo
//
Object userObject = node.getUserObject();
if (userObject instanceof SimulationInfo) {
//
// Check if node is a SimulationInfo
//
setComponentProperties(component, (SimulationInfo) userObject);
int maxErrorLevel = getMaxErrorLevel(node);
if (maxErrorLevel == BioModelNode.ERROR_POSSIBLE) {
setIcon(fieldSimulationWarningIcon);
component.setToolTipText("Simulation contains possibly invalid results");
} else if (maxErrorLevel == BioModelNode.ERROR_CONFIRMED) {
setIcon(fieldSimulationErrorIcon);
component.setToolTipText("Simulation contains invalid results");
}
} else if (userObject instanceof String && node.getChildCount() == 0) {
component.setToolTipText(null);
component.setText((String) userObject);
} else if (userObject instanceof BioModelInfo) {
//
// Check if node is a BioModelInfo
//
setComponentProperties(component, (BioModelInfo) userObject);
bLoaded = isLoaded((BioModelInfo) userObject);
int maxErrorLevel = getMaxErrorLevel(node);
if (maxErrorLevel == BioModelNode.ERROR_POSSIBLE) {
setIcon(fieldBioModelWarningIcon);
component.setToolTipText("BioModel version: Has possibly invalid simulation results");
} else if (maxErrorLevel == BioModelNode.ERROR_CONFIRMED) {
setIcon(fieldBioModelErrorIcon);
component.setToolTipText("BioModel version: Has invalid simulation results");
}
} else if (userObject instanceof String && node.getChildCount() > 0 && ((BioModelNode) node.getChildAt(0)).getUserObject() instanceof BioModelInfo) {
//
// Check if node is a BioModelName (String), with children (at least one version of biomodel), and if the child is a
// BioModelInfo node
//
String label = (String) userObject;
component.setToolTipText("BioModel");
component.setText(label);
//
// check if child is loaded
//
int maxErrorLevel = BioModelNode.ERROR_NONE;
for (int i = 0; i < node.getChildCount(); i++) {
maxErrorLevel = Math.max(maxErrorLevel, getMaxErrorLevel((BioModelNode) node.getChildAt(i)));
}
if (maxErrorLevel == BioModelNode.ERROR_POSSIBLE) {
if (!leaf && expanded) {
setIcon(fieldFolderOpenWarningIcon);
} else if (!leaf && !expanded) {
setIcon(fieldFolderClosedWarningIcon);
}
component.setToolTipText("BioModel: one or more versions may have invalid simulation results");
} else if (maxErrorLevel == BioModelNode.ERROR_CONFIRMED) {
if (!leaf && expanded) {
setIcon(fieldFolderOpenErrorIcon);
} else if (!leaf && !expanded) {
setIcon(fieldFolderClosedErrorIcon);
}
component.setToolTipText("BioModel: one or more versions have invalid simulation results");
}
//
for (int i = 0; i < node.getChildCount(); i++) {
BioModelInfo bioModelInfo = (BioModelInfo) ((BioModelNode) node.getChildAt(i)).getUserObject();
if (isLoaded(bioModelInfo)) {
bLoaded = true;
}
}
} else if (userObject instanceof User && node.getChildCount() > 0 && (((BioModelNode) node.getChildAt(0)).getUserObject() instanceof String) && ((BioModelNode) (node.getChildAt(0).getChildAt(0))).getUserObject() instanceof BioModelInfo) {
//
// Check if node is a User, with at least one child which is a string (BioModel name)
// and if the child's child is a BioModelInfo node
//
String label = ((User) userObject).getName();
component.setToolTipText("User Name");
component.setText(label);
if (isLoaded((User) userObject)) {
bLoaded = true;
}
} else if (userObject instanceof MathModelInfo) {
//
// Check if node is a MathModelInfo node
//
setComponentProperties(component, (MathModelInfo) userObject);
bLoaded = isLoaded((MathModelInfo) userObject);
} else if (userObject instanceof String && node.getChildCount() > 0 && ((BioModelNode) node.getChildAt(0)).getUserObject() instanceof MathModelInfo) {
//
// Check if node is a MathModel name (String), with children (at least one version of mathmodel), and
// if the child is a MathModelInfo node
//
String label = (String) userObject;
component.setToolTipText("Mathematical Model");
component.setText(label);
//
for (int i = 0; i < node.getChildCount(); i++) {
MathModelInfo mathModelInfo = (MathModelInfo) ((BioModelNode) node.getChildAt(i)).getUserObject();
if (isLoaded(mathModelInfo)) {
bLoaded = true;
}
}
} else if (userObject instanceof User && node.getChildCount() > 0 && (((BioModelNode) node.getChildAt(0)).getUserObject() instanceof String) && ((BioModelNode) (node.getChildAt(0).getChildAt(0))).getUserObject() instanceof MathModelInfo) {
//
// Check if node is a User, with at least one child which is a string (Mathmodel name)
// and if the child's child is a MathModelInfo node
//
String label = ((User) userObject).getName();
component.setToolTipText("User Name");
component.setText(label);
if (isLoaded((User) userObject)) {
bLoaded = true;
}
} else if (userObject instanceof cbit.vcell.geometry.GeometryInfo) {
//
// Check if node is a GeometryInfo
//
setComponentProperties(component, (GeometryInfo) userObject);
bLoaded = isLoaded((GeometryInfo) userObject);
} else if (userObject instanceof String && node.getChildCount() > 0 && ((BioModelNode) node.getChildAt(0)).getUserObject() instanceof GeometryInfo) {
//
// Check if node is a Geometry name (String), with children (at least one version of Geometry), and
// if the child is a GeometryInfo node
//
String label = (String) userObject;
component.setToolTipText("Geometry");
component.setText(label);
//
for (int i = 0; i < node.getChildCount(); i++) {
GeometryInfo geometryInfo = (GeometryInfo) ((BioModelNode) node.getChildAt(i)).getUserObject();
if (isLoaded(geometryInfo)) {
bLoaded = true;
}
}
} else if (userObject instanceof User && node.getChildCount() > 0 && (((BioModelNode) node.getChildAt(0)).getUserObject() instanceof String) && ((BioModelNode) (node.getChildAt(0).getChildAt(0))).getUserObject() instanceof GeometryInfo) {
//
// Check if node is a User, with at least one child which is a string (Geometry name)
// and if the child's child is a GeometryInfo node
//
String label = ((User) userObject).getName();
component.setToolTipText("User Name");
component.setText(label);
if (isLoaded((User) userObject)) {
bLoaded = true;
}
} else if (userObject instanceof String && node.getChildCount() > 0) {
component.setToolTipText(null);
component.setText((String) userObject);
// }else if (node.getUserObject() instanceof MathInfo) {
// setComponentProperties(component,(MathInfo)node.getUserObject());
} else if (userObject instanceof VCImageInfo) {
setComponentProperties(component, (VCImageInfo) userObject);
} else if (userObject instanceof Extent) {
setComponentProperties(component, (Extent) userObject);
} else if (userObject instanceof Annotation) {
setComponentProperties(component, (Annotation) userObject);
} else if (userObject instanceof MathModel) {
setComponentProperties(component, (MathModel) userObject);
} else if (userObject instanceof BioModel) {
setComponentProperties(component, (BioModel) userObject);
} else if (userObject instanceof SimulationContext) {
setComponentProperties(component, (SimulationContext) userObject);
bLoaded = isLoaded((SimulationContext) userObject);
} else if (userObject instanceof Simulation) {
setComponentProperties(component, (Simulation) userObject);
} else if (userObject instanceof MathDescription) {
setComponentProperties(component, (MathDescription) userObject);
} else if (userObject instanceof Geometry) {
setComponentProperties(component, (Geometry) userObject);
} else if (userObject instanceof User) {
setComponentProperties(component, (User) userObject);
} else {
setComponentProperties(component, userObject);
}
if (selectedFont == null && component.getFont() != null) {
selectedFont = component.getFont().deriveFont(Font.BOLD);
}
if (unselectedFont == null && component.getFont() != null) {
unselectedFont = component.getFont().deriveFont(Font.PLAIN);
}
if (bLoaded) {
component.setFont(selectedFont);
} else {
component.setFont(unselectedFont);
}
}
} catch (Throwable e) {
e.printStackTrace(System.out);
}
//
return component;
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class BioModelCellRenderer method getTreeCellRendererComponent.
/**
* Insert the method's description here.
* Creation date: (7/27/2000 6:41:57 PM)
* @return java.awt.Component
*/
public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
//
try {
if (value instanceof DateNode) {
DateNode dateNode = (DateNode) value;
AnnotationQualifier qualifier = dateNode.getDateQualifier();
String colorString = (sel) ? "white" : "black";
component.setText("<html>" + qualifier.getDescription() + " <font color=\"" + colorString + "\">" + dateNode.getDate().getDateString() + "</font></html>");
} else if (value instanceof LinkNode) {
LinkNode ln = (LinkNode) value;
String link = ln.getLink();
String text = ln.getText();
String qualifier = ln.getMiriamQualifier().getDescription();
if (link != null) {
String colorString = (sel) ? "white" : "blue";
component.setToolTipText("Double-click to open link");
component.setText("<html>" + qualifier + " <font color=\"" + colorString + "\"><a href=" + link + ">" + text + "</a></font></html>");
} else {
String colorString = (sel) ? "white" : "black";
component.setText("<html>" + qualifier + " <font color=\"" + colorString + "\">" + text + "</font></html>");
}
} else if (value instanceof BioModelNode) {
BioModelNode node = (BioModelNode) value;
Object userObject = node.getUserObject();
if (userObject instanceof User) {
String label = null;
if (sessionUser != null && sessionUser.compareEqual((User) userObject)) {
label = "My BioModels (" + ((User) userObject).getName() + ") (" + node.getChildCount() + ")";
} else {
label = ((User) userObject).getName() + "(abcdefghijklmnopq)(000000)";
}
component.setToolTipText(label);
component.setText(label);
} else if (userObject instanceof BioModelInfo) {
BioModelInfo biomodelInfo = (BioModelInfo) userObject;
if (biomodelInfo.getVersion().getFlag().compareEqual(org.vcell.util.document.VersionFlag.Archived)) {
component.setText("(Archived) " + component.getText());
} else if (biomodelInfo.getVersion().getFlag().compareEqual(org.vcell.util.document.VersionFlag.Published)) {
component.setText("(Published) " + component.getText());
}
} else if (userObject instanceof Geometry) {
Geometry geo = (Geometry) userObject;
String label = "";
// geomety info, when spatial--shows name+1D/2D/3D
if (geo.getDimension() > 0) {
label = geo.getName() + " (" + geo.getDimension() + "D)";
} else {
label = BioModelChildSummary.COMPARTMENTAL_GEO_STR;
}
component.setToolTipText("Geometry");
component.setText(label);
setIcon(fieldGeometryIcon);
} else if (userObject instanceof String && "AppType".equals(node.getRenderHint("type"))) {
String label = (String) userObject;
component.setToolTipText("Application type");
component.setText(label);
setIcon(VCellIcons.mathTypeIcon);
} else if (userObject instanceof VCDocumentInfoNode) {
VCDocumentInfoNode infonode = (VCDocumentInfoNode) userObject;
User nodeUser = infonode.getVCDocumentInfo().getVersion().getOwner();
String modelName = infonode.getVCDocumentInfo().getVersion().getName();
String username = nodeUser.getName();
if (nodeUser.compareEqual(sessionUser) || username.equals(VCDocumentDbTreeModel.USER_tutorial) || username.equals(VCDocumentDbTreeModel.USER_Education) || username.equals(VCDocumentDbTreeModel.USER_tutorial610) || username.equals(VCDocumentDbTreeModel.USER_tutorial611)) {
component.setText(modelName);
} else {
component.setText("<html><b>" + username + " </b> : " + modelName + "</html>");
}
}
}
} catch (Throwable e) {
e.printStackTrace(System.out);
}
//
if (component.getToolTipText() == null || component.getToolTipText().length() == 0) {
component.setToolTipText(component.getText());
}
return component;
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class BioModelWindowManager method actionPerformed.
/**
* Invoked when an action occurs.
*/
public void actionPerformed(java.awt.event.ActionEvent e) {
String actionCommand = e.getActionCommand();
final Object source = e.getSource();
if (source instanceof GeometryViewer && (actionCommand.equals(GuiConstants.ACTIONCMD_CREATE_GEOMETRY) || actionCommand.equals(GuiConstants.ACTIONCMD_EDITCURRENTSPATIAL_GEOMETRY))) {
final GeometryViewer geometryViewer = (GeometryViewer) source;
AsynchClientTask precomputeAllTask = new AsynchClientTask("precomputeAll geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry newGeom = (Geometry) hashTable.get("doc");
if (newGeom != null) {
newGeom.precomputeAll(new GeometryThumbnailImageFactoryAWT());
}
}
};
AsynchClientTask setGeomOnSimContextTask = new AsynchClientTask("Setting geometry on application", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry newGeom = (Geometry) hashTable.get("doc");
for (SimulationContext simulationContext : getBioModel().getSimulationContexts()) {
if (simulationContext == geometryViewer.getGeometryOwner()) {
if (newGeom.getName() == null) {
newGeom.setName(getBioModel().getName() + "_" + (simulationContext.getName() + "_" + BeanUtils.generateDateTimeString()));
}
simulationContext.setGeometry(newGeom);
return;
}
}
Geometry origGeom = geometryViewer.getGeometryOwner().getGeometry();
throw new IllegalArgumentException("Couldn't find matching application editor for orig geom '" + origGeom.getName() + "' key=" + origGeom.getKey() + " in application hash.");
}
};
Geometry currentGeometry = geometryViewer.getGeometryOwner().getGeometry();
createGeometry(currentGeometry, new AsynchClientTask[] { /*oldEditorTask,*/
precomputeAllTask, setGeomOnSimContextTask }, TopLevelWindowManager.DEFAULT_CREATEGEOM_SELECT_DIALOG_TITLE, TopLevelWindowManager.APPLY_GEOMETRY_BUTTON_TEXT, (actionCommand.equals(GuiConstants.ACTIONCMD_EDITCURRENTSPATIAL_GEOMETRY) ? new DocumentWindowManager.GeometrySelectionInfo() : null));
}
if (source instanceof MathematicsPanel && actionCommand.equals(GuiConstants.ACTIONCMD_CREATE_MATH_MODEL)) {
SimulationContext sc = ((MathematicsPanel) source).getSimulationContext();
getRequestManager().createMathModelFromApplication(this, "Untitled", sc);
}
if (source instanceof GeometryViewer && actionCommand.equals(GuiConstants.ACTIONCMD_CHANGE_GEOMETRY)) {
final GeometryViewer geometryViewer = (GeometryViewer) source;
getRequestManager().changeGeometry(this, (SimulationContext) geometryViewer.getGeometryOwner());
}
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class ClientRequestManager method isDifferentFromBlank.
/**
* Insert the method's description here.
* Creation date: (5/10/2004 3:48:16 PM)
*/
public boolean isDifferentFromBlank(VCDocumentType documentType, VCDocument vcDocument) {
if (documentType != vcDocument.getDocumentType()) {
// we have to open the doc in a new window, hence return true;
return true;
}
VCDocument blank = null;
if (vcDocument.getDocumentType() != VCDocumentType.GEOMETRY_DOC) {
// BioModel/MathModel
blank = createDefaultDocument(vcDocument.getDocumentType());
try {
blank.setName(vcDocument.getName());
}// ignore. doesn't happen
catch (PropertyVetoException e) {
}
return !blank.compareEqual(vcDocument);
} else {
// Geometry
blank = new Geometry(vcDocument.getName(), 1);
if (blank.compareEqual(vcDocument)) {
return false;
}
blank = new Geometry(vcDocument.getName(), 2);
if (blank.compareEqual(vcDocument)) {
return false;
}
blank = new Geometry(vcDocument.getName(), 3);
if (blank.compareEqual(vcDocument)) {
return false;
}
return true;
}
}
Aggregations