use of cbit.vcell.geometry.AnalyticSubVolume in project vcell by virtualcell.
the class SubVolumeTable method getSQLValueList.
/**
* This method was created in VisualAge.
* @return java.lang.String
* @param key KeyValue
* @param modelName java.lang.String
*/
public String getSQLValueList(InsertHashtable hash, KeyValue key, Geometry geom, SubVolume sv, KeyValue geomKey, int ordinalValue) throws DataAccessException {
StringBuffer buffer = new StringBuffer();
buffer.append("(");
buffer.append(key + ",");
buffer.append("'" + sv.getName() + "',");
if (sv instanceof ImageSubVolume) {
ImageSubVolume isv = (ImageSubVolume) sv;
KeyValue pixelClassKey = hash.getDatabaseKey(isv.getPixelClass());
if (pixelClassKey == null) {
pixelClassKey = isv.getPixelClass().getKey();
}
if (pixelClassKey == null) {
throw new DataAccessException("can't get a KeyValue for pixelClass while inserting an imageSubVolume");
}
buffer.append(pixelClassKey + ",");
} else {
buffer.append("null" + ",");
}
// buffer.append(geom.getKey() + ",");
buffer.append(geomKey + ",");
if (sv instanceof AnalyticSubVolume) {
buffer.append("'" + TokenMangler.getSQLEscapedString(((AnalyticSubVolume) sv).getExpression().infix()) + "',");
} else if (sv instanceof CSGObject) {
Xmlproducer producer = new Xmlproducer(true);
buffer.append("'" + TokenMangler.getSQLEscapedString(XmlUtil.xmlToString(producer.getXML((CSGObject) sv))) + "',");
} else {
buffer.append("null" + ",");
}
buffer.append(sv.getHandle() + ",");
buffer.append(ordinalValue + ")");
return buffer.toString();
}
use of cbit.vcell.geometry.AnalyticSubVolume in project vcell by virtualcell.
the class SubVolumeTable method getAnalyticOrCompartmentSubVolume.
/**
* This method was created in VisualAge.
* @return Model
* @param rset ResultSet
* @param log SessionLog
*/
public SubVolume getAnalyticOrCompartmentSubVolume(KeyValue key, ResultSet rset) throws SQLException, ExpressionException, DataAccessException {
// KeyValue key = new KeyValue(rset.getBigDecimal(id.toString(),0));
String svName = rset.getString(name.toString());
int handleValue = rset.getInt(handle.toString());
String expString = rset.getString(expression.toString());
if (rset.wasNull()) {
return new CompartmentSubVolume(key, handleValue);
} else {
try {
if (expString.startsWith("<") && expString.endsWith(">")) {
String xmlStr = TokenMangler.getSQLRestoredString(expString);
XmlReader xmlReader = new XmlReader(true);
Element csgObjElement = (XmlUtil.stringToXML(xmlStr, null)).getRootElement();
try {
CSGObject csgObject = xmlReader.getCSGObject(csgObjElement, key);
return csgObject;
} catch (Exception e1) {
e1.printStackTrace(System.out);
throw new DataAccessException(e1.getMessage(), e1);
}
}
Expression exp = new Expression(expString);
return new AnalyticSubVolume(key, svName, exp, handleValue);
} catch (Exception e) {
e.printStackTrace(System.out);
throw new DataAccessException(e.getMessage(), e);
}
}
}
use of cbit.vcell.geometry.AnalyticSubVolume in project vcell by virtualcell.
the class ROIMultiPaintManager method sampleAnalyticIntoImage.
private void sampleAnalyticIntoImage(OverlayEditorPanelJAI.ImgSubVolHelper imgSubVolHelper) {
try {
Extent extent = (editedGeometryAttributes == null ? originalExtent : editedGeometryAttributes.extent);
Origin orig = (editedGeometryAttributes == null ? originalOrigin : editedGeometryAttributes.origin);
int numX = roiComposite[0].getWidth();
int numY = roiComposite[0].getHeight();
int numZ = roiComposite.length;
int dim = (roiComposite.length > 1 ? 1 : 0) + (roiComposite[0].getHeight() > 1 ? 1 : 0) + 1;
double cX = calcCoord(imgSubVolHelper.getMousePoint().x, numX, orig.getX(), extent.getX());
double cY = calcCoord(imgSubVolHelper.getMousePoint().y, numY, orig.getY(), extent.getY());
double cZ = calcCoord(imgSubVolHelper.getZCenter(), numZ, orig.getZ(), extent.getZ());
Coordinate center = new Coordinate(cX, cY, cZ);
AnalyticSubVolume tempSV = GeometrySubVolumePanel.createAnalyticSubVolume(overlayEditorPanelJAI, dim, center, "tempSV");
tempSV.rebind();
for (int k = 0; k < numZ; k++) {
double coordZ = calcCoord(k, numZ, orig.getZ(), extent.getZ());
for (int j = 0; j < numY; j++) {
double coordY = calcCoord(j, numY, orig.getY(), extent.getY());
for (int i = 0; i < numX; i++) {
double coordX = calcCoord(i, numX, orig.getX(), extent.getX());
if (tempSV.isInside(coordX, coordY, coordZ, null)) {
((DataBufferByte) roiComposite[k].getRaster().getDataBuffer()).getData()[j * numX + i] = (byte) (imgSubVolHelper.getCurrentSubVolHandle().getContrastColorIndex());
}
}
}
}
} catch (UserCancelException uce) {
// ignore
} catch (Exception e) {
DialogUtils.showErrorDialog(overlayEditorPanelJAI, e.getClass().getName() + " " + e.getMessage());
}
}
use of cbit.vcell.geometry.AnalyticSubVolume in project vcell by virtualcell.
the class GeometrySubVolumePanel method moveSubvolumeFront.
/**
* connEtoM6: (FrontButton.action.actionPerformed(java.awt.event.ActionEvent) --> Geometry.bringForward(Lcbit.vcell.geometry.AnalyticSubVolume;)V)
* @param arg1 java.awt.event.ActionEvent
*/
private void moveSubvolumeFront() {
try {
if ((getSelectedSubVolume() != null)) {
AsynchClientTask task1 = new AsynchClientTask("moving to front", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
SubVolume selectedSubVolume = getSelectedSubVolume();
if (selectedSubVolume instanceof CSGObject) {
getGeometrySpec().bringForward((CSGObject) selectedSubVolume);
} else if (selectedSubVolume instanceof AnalyticSubVolume) {
getGeometrySpec().bringForward((AnalyticSubVolume) selectedSubVolume);
}
getGeometry().precomputeAll(new GeometryThumbnailImageFactoryAWT());
}
};
ClientTaskDispatcher.dispatch(GeometrySubVolumePanel.this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1 }, false);
}
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of cbit.vcell.geometry.AnalyticSubVolume in project vcell by virtualcell.
the class GeometrySubVolumePanel method addSubVolume.
private void addSubVolume(final SubVolume subVolume) {
AsynchClientTask task1 = new AsynchClientTask("adding subdomain", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
if (subVolume instanceof AnalyticSubVolume) {
getGeometrySpec().addSubVolume((AnalyticSubVolume) subVolume, true);
} else if (subVolume instanceof CSGObject) {
getGeometrySpec().addSubVolume((CSGObject) subVolume, true);
}
getGeometry().precomputeAll(new GeometryThumbnailImageFactoryAWT());
}
};
AsynchClientTask task2 = new AsynchClientTask("adding subdomain", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
DocumentEditorSubPanel.setTableSelections(new Object[] { subVolume }, ivjScrollPaneTable, ivjgeometrySubVolumeTableModel);
}
};
ClientTaskDispatcher.dispatch(GeometrySubVolumePanel.this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, true, false, false, null, true);
}
Aggregations