use of cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT in project vcell by virtualcell.
the class MathModelWindowManager 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)) {
AsynchClientTask geomRegionsTask = new AsynchClientTask("Update Geometric regions", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry newGeom = (Geometry) hashTable.get("doc");
ClientRequestManager.continueAfterMathModelGeomChangeWarning(MathModelWindowManager.this, newGeom);
newGeom.precomputeAll(new GeometryThumbnailImageFactoryAWT());
}
};
AsynchClientTask applyGeomTask = new AsynchClientTask("Apply Geometry", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry newGeom = (Geometry) hashTable.get("doc");
if (newGeom.getName() == null) {
newGeom.setName(getMathModel().getName() + "_" + BeanUtils.generateDateTimeString());
}
((MathModel) getVCDocument()).getMathDescription().setGeometry(newGeom);
}
};
createGeometry(getMathModel().getMathDescription().getGeometry(), new AsynchClientTask[] { /*editSelectTask,*/
geomRegionsTask, applyGeomTask }, TopLevelWindowManager.DEFAULT_CREATEGEOM_SELECT_DIALOG_TITLE, TopLevelWindowManager.APPLY_GEOMETRY_BUTTON_TEXT, (actionCommand.equals(GuiConstants.ACTIONCMD_EDITCURRENTSPATIAL_GEOMETRY) ? new DocumentWindowManager.GeometrySelectionInfo() : null));
}
if (source instanceof GeometryViewer && actionCommand.equals(GuiConstants.ACTIONCMD_CHANGE_GEOMETRY)) {
Hashtable<String, Object> hashTable = new Hashtable<String, Object>();
hashTable.put(SELECT_GEOM_POPUP, new Boolean(true));
getRequestManager().changeGeometry(this, null, hashTable);
}
}
use of cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT in project vcell by virtualcell.
the class BioModelEditorApplicationPanel method setSimulationContext.
public void setSimulationContext(SimulationContext newValue) {
if (simulationContext == newValue) {
return;
}
final boolean respondingToSelectionManager = selectionManager.isBusy();
final Object[] selectedObj = selectionManager.getSelectedObjects();
SimulationContext oldValue = simulationContext;
if (oldValue != null) {
oldValue.removePropertyChangeListener(eventHandler);
}
if (newValue != null) {
newValue.addPropertyChangeListener(eventHandler);
}
simulationContext = newValue;
AsynchClientTask task1 = new AsynchClientTask("loading application", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
simulationContext.getGeometry().precomputeAll(new GeometryThumbnailImageFactoryAWT());
}
};
AsynchClientTask task2 = new AsynchClientTask("showing application", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
applicationGeometryPanel.setSimulationContext(simulationContext);
applicationSpecificationsPanel.setSimulationContext(simulationContext);
applicationProtocolsPanel.setSimulationContext(simulationContext);
applicationSimulationsPanel.setSimulationContext(simulationContext);
parameterEstimationPanel.setSelectionManager(null);
showOrHideFittingPanel();
parameterEstimationPanel.setSelectionManager(selectionManager);
if (respondingToSelectionManager) {
selectionManager.setSelectedObjects(new Object[0]);
selectionManager.setSelectedObjects(selectedObj);
}
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
use of cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT 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.GeometryThumbnailImageFactoryAWT 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.GeometryThumbnailImageFactoryAWT in project vcell by virtualcell.
the class GeometrySubVolumeTableModel method setValueAt.
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
if (rowIndex < 0 || rowIndex >= getRowCount()) {
throw new RuntimeException("GeometrySubVolumeTableModel.setValueAt(), row = " + rowIndex + " out of range [" + 0 + "," + (getRowCount() - 1) + "]");
}
if (columnIndex < 0 || columnIndex >= getColumnCount()) {
throw new RuntimeException("GeometrySubVolumeTableModel.setValueAt(), column = " + columnIndex + " out of range [" + 0 + "," + (getColumnCount() - 1) + "]");
}
final SubVolume subVolume = getValueAt(rowIndex);
try {
switch(columnIndex) {
case COLUMN_NAME:
{
final String newName = (String) aValue;
final String oldName = subVolume.getName();
subVolume.setName(newName);
AsynchClientTask task1 = new AsynchClientTask("changing the name", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
getGeometry().precomputeAll(new GeometryThumbnailImageFactoryAWT());
GeometrySpec gs = getGeometry().getGeometrySpec();
if (gs != null) {
gs.geometryNameChanged(oldName, newName);
} else {
if (lg.isWarnEnabled()) {
lg.warn(getGeometry().getDescription() + " has no GeometrySpec?");
}
}
}
};
ClientTaskDispatcher.dispatch(ownerTable, new Hashtable<String, Object>(), new AsynchClientTask[] { task1 }, false);
break;
}
case COLUMN_VALUE:
{
if (subVolume instanceof AnalyticSubVolume) {
final AnalyticSubVolume analyticSubVolume = (AnalyticSubVolume) subVolume;
if (aValue instanceof ScopedExpression) {
throw new RuntimeException("unexpected value type ScopedExpression");
} else if (aValue instanceof String) {
final String newExpressionString = (String) aValue;
analyticSubVolume.setExpression(new Expression(newExpressionString));
AsynchClientTask task1 = new AsynchClientTask("changing the expression", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
getGeometry().precomputeAll(new GeometryThumbnailImageFactoryAWT());
}
};
ClientTaskDispatcher.dispatch(ownerTable, new Hashtable<String, Object>(), new AsynchClientTask[] { task1 }, false);
}
}
break;
}
}
} catch (Exception e) {
e.printStackTrace(System.out);
DialogUtils.showErrorDialog(ownerTable, e.getMessage(), e);
}
}
Aggregations