use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class GeometryFilamentCurvePanel method setGeometry.
/**
* Sets the geometry property (cbit.vcell.geometry.Geometry) value.
* @param geometry The new value for the property.
* @see #getGeometry
*/
public void setGeometry(cbit.vcell.geometry.Geometry geometry) {
cbit.vcell.geometry.Geometry oldValue = fieldGeometry;
fieldGeometry = geometry;
firePropertyChange("geometry", oldValue, geometry);
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class GeometryGuiTest method main.
public static void main(java.lang.String[] args) {
try {
javax.swing.JFrame frame = new javax.swing.JFrame();
GeometryViewer aGeometryViewer;
aGeometryViewer = new GeometryViewer();
frame.setContentPane(aGeometryViewer);
frame.setSize(aGeometryViewer.getSize());
frame.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
Geometry csGeometry = getExampleGeometryCSG();
// try to convert this CSG geometry to image
ISize imageSize = csGeometry.getGeometrySpec().getDefaultSampledImageSize();
Geometry imageGeometry = RayCaster.resampleGeometry(new GeometryThumbnailImageFactoryAWT(), csGeometry, imageSize);
// aGeometryViewer.setGeometry(csGeometry);
aGeometryViewer.setGeometry(imageGeometry);
frame.setSize(600, 600);
frame.setVisible(true);
} catch (Throwable exception) {
System.err.println("Exception occurred in main() of javax.swing.JPanel");
exception.printStackTrace(System.out);
}
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class GeometryGuiTest method getExampleGeometryCSG.
public static Geometry getExampleGeometryCSG() throws PropertyVetoException, ExpressionException, GeometryException, ImageException {
// translated rotated cube
CSGPrimitive cube = new CSGPrimitive("cube", CSGPrimitive.PrimitiveType.CUBE);
CSGRotation rotatedCube = new CSGRotation("Rotation", new Vect3d(1, 2, 3), Math.PI / 4.0);
rotatedCube.setChild(cube);
// translated sphere
CSGTranslation translatedSphere = new CSGTranslation("translation", new Vect3d(0.5, 0.5, 0.5));
CSGPrimitive sphere = new CSGPrimitive("sphere", CSGPrimitive.PrimitiveType.SPHERE);
translatedSphere.setChild(sphere);
// union
CSGSetOperator csgSetOperator = new CSGSetOperator("difference", OperatorType.DIFFERENCE);
csgSetOperator.addChild(rotatedCube);
csgSetOperator.addChild(translatedSphere);
// scaled union
CSGScale csgScale = new CSGScale("scale", new Vect3d(3, 3, 3));
csgScale.setChild(csgSetOperator);
CSGTranslation csgTranslatedUnion = new CSGTranslation("translationUnion", new Vect3d(5, 5, 5));
csgTranslatedUnion.setChild(csgScale);
Geometry geometry = new Geometry("csg", 3);
CSGObject csgObject = new CSGObject(null, "obj1", 1);
csgObject.setRoot(csgTranslatedUnion);
geometry.getGeometrySpec().addSubVolume(new AnalyticSubVolume("background", new Expression(1.0)));
geometry.getGeometrySpec().addSubVolume(csgObject, true);
geometry.refreshDependencies();
geometry.precomputeAll(new GeometryThumbnailImageFactoryAWT());
return geometry;
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class BioModelTreeModel method propertyChange.
/**
* Insert the method's description here.
* Creation date: (5/9/01 8:28:22 AM)
* @param evt java.beans.PropertyChangeEvent
*/
public void propertyChange(java.beans.PropertyChangeEvent evt) {
try {
if (evt.getSource() == getBioModel() && evt.getPropertyName().equals("simulations")) {
refreshTree();
Simulation[] oldSims = (Simulation[]) evt.getOldValue();
if (oldSims != null) {
for (int i = 0; i < oldSims.length; i++) {
oldSims[i].removePropertyChangeListener(this);
}
}
Simulation[] newSims = (Simulation[]) evt.getNewValue();
if (newSims != null) {
for (int i = 0; i < newSims.length; i++) {
newSims[i].addPropertyChangeListener(this);
}
}
} else if (evt.getSource() == getBioModel() && evt.getPropertyName().equals("simulationContexts")) {
refreshTree();
SimulationContext[] oldSCs = (SimulationContext[]) evt.getOldValue();
if (oldSCs != null) {
for (int i = 0; i < oldSCs.length; i++) {
oldSCs[i].removePropertyChangeListener(this);
}
}
SimulationContext[] newSCs = (SimulationContext[]) evt.getNewValue();
if (newSCs != null) {
for (int i = 0; i < newSCs.length; i++) {
newSCs[i].addPropertyChangeListener(this);
}
}
} else if (evt.getSource() == getBioModel() && evt.getPropertyName().equals("description")) {
BioModel bioModel = (BioModel) evt.getSource();
BioModelNode bioModelNode = ((BioModelNode) getRoot()).findNodeByUserObject(bioModel);
BioModelNode annotNode = bioModelNode.findNodeByUserObject(new Annotation((String) evt.getOldValue()));
if (annotNode == null && evt.getNewValue() != null && !((String) evt.getNewValue()).equals("")) {
//
// must add annotation node (was null string)
//
bioModelNode.insert(new BioModelNode(new Annotation((String) evt.getNewValue()), false), 0);
nodeStructureChanged(bioModelNode);
} else if (annotNode != null && evt.getNewValue() != null && !((String) evt.getNewValue()).equals("")) {
//
// change annotation content for annotation node
//
annotNode.setUserObject(new Annotation((String) evt.getNewValue()));
nodeChanged(annotNode);
} else if (annotNode != null && (evt.getNewValue() == null || ((String) evt.getNewValue()).equals(""))) {
//
// delete annotation node
//
removeNodeFromParent(annotNode);
}
} else if (evt.getSource() instanceof Simulation) {
if (evt.getPropertyName().equals("name")) {
Simulation sim = (Simulation) evt.getSource();
BioModelNode simNode = ((BioModelNode) getRoot()).findNodeByUserObject(sim);
nodeChanged(simNode);
} else if (evt.getPropertyName().equals("description")) {
Simulation sim = (Simulation) evt.getSource();
BioModelNode simNode = ((BioModelNode) getRoot()).findNodeByUserObject(sim);
BioModelNode annotNode = simNode.findNodeByUserObject(new Annotation((String) evt.getOldValue()));
if (annotNode == null && evt.getNewValue() != null && !((String) evt.getNewValue()).equals("")) {
//
// must add annotation node (was null string)
//
simNode.insert(new BioModelNode(new Annotation((String) evt.getNewValue()), false), 0);
nodeStructureChanged(simNode);
} else if (annotNode != null && evt.getNewValue() != null && !((String) evt.getNewValue()).equals("")) {
//
// change annotation content for annotation node
//
annotNode.setUserObject(new Annotation((String) evt.getNewValue()));
nodeChanged(annotNode);
} else if (annotNode != null && (evt.getNewValue() == null || ((String) evt.getNewValue()).equals(""))) {
//
// delete annotation node
//
removeNodeFromParent(annotNode);
}
}
} else if (evt.getSource() instanceof SimulationContext) {
if (evt.getPropertyName().equals("geometry")) {
Geometry oldGeometry = (Geometry) evt.getOldValue();
Geometry newGeometry = (Geometry) evt.getNewValue();
BioModelNode geoNode = ((BioModelNode) getRoot()).findNodeByUserObject(oldGeometry);
geoNode.setUserObject(newGeometry);
nodeChanged(geoNode);
} else if (evt.getPropertyName().equals("name")) {
SimulationContext simContext = (SimulationContext) evt.getSource();
BioModelNode scNode = ((BioModelNode) getRoot()).findNodeByUserObject(simContext);
nodeChanged(scNode);
} else if (evt.getPropertyName().equals("description")) {
SimulationContext simContext = (SimulationContext) evt.getSource();
BioModelNode scNode = ((BioModelNode) getRoot()).findNodeByUserObject(simContext);
BioModelNode annotNode = scNode.findNodeByUserObject(new Annotation((String) evt.getOldValue()));
if (annotNode == null && evt.getNewValue() != null && !((String) evt.getNewValue()).equals("")) {
//
// must add annotation node (was null string)
//
scNode.insert(new BioModelNode(new Annotation((String) evt.getNewValue()), false), 0);
nodeStructureChanged(scNode);
} else if (annotNode != null && evt.getNewValue() != null && !((String) evt.getNewValue()).equals("")) {
//
// change annotation content for annotation node
//
annotNode.setUserObject(new Annotation((String) evt.getNewValue()));
nodeChanged(annotNode);
} else if (annotNode != null && (evt.getNewValue() == null || ((String) evt.getNewValue()).equals(""))) {
//
// delete annotation node
//
removeNodeFromParent(annotNode);
}
} else if (evt.getPropertyName().equals("mathDescription")) {
SimulationContext simContext = (SimulationContext) evt.getSource();
BioModelNode scNode = ((BioModelNode) getRoot()).findNodeByUserObject(simContext);
nodeStructureChanged(scNode);
}
}
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class BioModelTreePanel method actionsOnClick.
/**
* Comment
*/
private void actionsOnClick(MouseEvent mouseEvent) {
DefaultMutableTreeNode currentTreeSelection = (DefaultMutableTreeNode) getJTree2().getLastSelectedPathComponent();
Object selectedObject = null;
if (currentTreeSelection == null) {
return;
}
selectedObject = currentTreeSelection.getUserObject();
// double click
if (mouseEvent.getClickCount() == 2) {
if (selectedObject instanceof SimulationContext) {
fireActionPerformed(new ActionEvent(this, mouseEvent.getID(), GuiConstants.ACTIONCMD_OPEN_APPLICATION, mouseEvent.getModifiers()));
} else if (selectedObject instanceof Annotation) {
editAnnotation();
} else if (selectedObject instanceof MathDescription) {
fireActionPerformed(new ActionEvent(this, mouseEvent.getID(), GuiConstants.ACTIONCMD_OPEN_APPLICATION_MATH, mouseEvent.getModifiers()));
} else if (selectedObject instanceof Geometry) {
fireActionPerformed(new ActionEvent(this, mouseEvent.getID(), GuiConstants.ACTIONCMD_OPEN_APPLICATION_GEOMETRY, mouseEvent.getModifiers()));
} else if (selectedObject instanceof Simulation) {
fireActionPerformed(new ActionEvent(this, mouseEvent.getID(), GuiConstants.ACTIONCMD_OPEN_APPLICATION_SIMULATION, mouseEvent.getModifiers()));
} else if (selectedObject instanceof MathType) {
// deterministic or stochastic or rule-bsaed
fireActionPerformed(new ActionEvent(this, mouseEvent.getID(), GuiConstants.ACTIONCMD_OPEN_APPLICATION_DETSTOCH, mouseEvent.getModifiers()));
}
return;
}
// right click
if (mouseEvent.isPopupTrigger()) {
Point mousePoint = mouseEvent.getPoint();
if (selectedObject instanceof BioModel) {
getBioModelPopupMenu().show(getJTree2(), mousePoint.x, mousePoint.y);
} else if (selectedObject instanceof SimulationContext) {
getAppPopupMenu().show(getJTree2(), mousePoint.x, mousePoint.y);
} else if (selectedObject instanceof Simulation) {
getSimPopupMenu().show(getJTree2(), mousePoint.x, mousePoint.y);
}
if (selectedObject instanceof Annotation) {
getEditAnnotationPopupMenu().show(getJTree2(), mousePoint.x, mousePoint.y);
}
}
}
Aggregations