Search in sources :

Example 11 with AnalyticSubVolume

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();
}
Also used : KeyValue(org.vcell.util.document.KeyValue) Xmlproducer(cbit.vcell.xml.Xmlproducer) CSGObject(cbit.vcell.geometry.CSGObject) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) DataAccessException(org.vcell.util.DataAccessException)

Example 12 with AnalyticSubVolume

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);
        }
    }
}
Also used : CompartmentSubVolume(cbit.vcell.geometry.CompartmentSubVolume) Expression(cbit.vcell.parser.Expression) Element(org.jdom.Element) XmlReader(cbit.vcell.xml.XmlReader) CSGObject(cbit.vcell.geometry.CSGObject) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) SQLException(java.sql.SQLException) DataAccessException(org.vcell.util.DataAccessException)

Example 13 with AnalyticSubVolume

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());
    }
}
Also used : Origin(org.vcell.util.Origin) Extent(org.vcell.util.Extent) Coordinate(org.vcell.util.Coordinate) UserCancelException(org.vcell.util.UserCancelException) DataBufferByte(java.awt.image.DataBufferByte) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) Point(java.awt.Point) UtilCancelException(org.vcell.util.UtilCancelException) UserCancelException(org.vcell.util.UserCancelException)

Example 14 with AnalyticSubVolume

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);
    }
}
Also used : GeometryThumbnailImageFactoryAWT(cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) SubVolume(cbit.vcell.geometry.SubVolume) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) CSGObject(cbit.vcell.geometry.CSGObject) CSGObject(cbit.vcell.geometry.CSGObject) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume)

Example 15 with AnalyticSubVolume

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);
}
Also used : GeometryThumbnailImageFactoryAWT(cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) CSGObject(cbit.vcell.geometry.CSGObject) CSGObject(cbit.vcell.geometry.CSGObject) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume)

Aggregations

AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)20 Expression (cbit.vcell.parser.Expression)14 CSGObject (cbit.vcell.geometry.CSGObject)13 SubVolume (cbit.vcell.geometry.SubVolume)11 GeometryThumbnailImageFactoryAWT (cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT)10 Geometry (cbit.vcell.geometry.Geometry)8 ImageSubVolume (cbit.vcell.geometry.ImageSubVolume)7 Extent (org.vcell.util.Extent)7 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)6 Hashtable (java.util.Hashtable)6 Origin (org.vcell.util.Origin)6 GeometrySpec (cbit.vcell.geometry.GeometrySpec)5 ExpressionException (cbit.vcell.parser.ExpressionException)5 ISize (org.vcell.util.ISize)5 ImageException (cbit.image.ImageException)4 VCImage (cbit.image.VCImage)4 BioModel (cbit.vcell.biomodel.BioModel)4 GeometrySurfaceDescription (cbit.vcell.geometry.surface.GeometrySurfaceDescription)4 SimulationContext (cbit.vcell.mapping.SimulationContext)4 GeometryClass (cbit.vcell.geometry.GeometryClass)3