Search in sources :

Example 11 with CSGObject

use of cbit.vcell.geometry.CSGObject 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 CSGObject

use of cbit.vcell.geometry.CSGObject 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 CSGObject

use of cbit.vcell.geometry.CSGObject in project vcell by virtualcell.

the class MathModelEditor method setRightBottomPanelOnSelection.

@Override
protected void setRightBottomPanelOnSelection(Object[] selections) {
    if (selections == null) {
        return;
    }
    JComponent bottomComponent = rightBottomEmptyPanel;
    int destComponentIndex = DocumentEditorTabID.object_properties.ordinal();
    boolean bShowInDatabaseProperties = false;
    if (selections != null && selections.length == 1) {
        Object singleSelection = selections[0];
        if (singleSelection == mathModel) {
            bottomComponent = mathModelEditorAnnotationPanel;
        } else if (singleSelection instanceof DocumentEditorTreeFolderNode) {
            DocumentEditorTreeFolderNode folderNode = (DocumentEditorTreeFolderNode) singleSelection;
            if (folderNode.getFolderClass() == DocumentEditorTreeFolderClass.MATH_ANNOTATION_NODE) {
                bottomComponent = mathModelEditorAnnotationPanel;
            } else if (folderNode.getFolderClass() == DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE) {
                bottomComponent = simulationSummaryPanel;
            }
        } else if (singleSelection instanceof BioModelInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = bioModelMetaDataPanel;
        } else if (singleSelection instanceof MathModelInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = mathModelMetaDataPanel;
        } else if (singleSelection instanceof GeometryInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = geometryMetaDataPanel;
        } else if (singleSelection instanceof Simulation) {
            bottomComponent = simulationSummaryPanel;
        } else if (singleSelection instanceof CSGObject) {
            bottomComponent = csgObjectPropertiesPanel;
            csgObjectPropertiesPanel.setSimulationContext(getSelectedSimulationContext());
        }
    }
    if (bShowInDatabaseProperties) {
        for (destComponentIndex = 0; destComponentIndex < rightBottomTabbedPane.getTabCount(); destComponentIndex++) {
            Component c = rightBottomTabbedPane.getComponentAt(destComponentIndex);
            if (c == bioModelMetaDataPanel || c == mathModelMetaDataPanel || c == geometryMetaDataPanel) {
                break;
            }
        }
        if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
            rightBottomTabbedPane.addTab(DATABASE_PROPERTIES_TAB_TITLE, new TabCloseIcon(), bottomComponent);
        }
    }
    if (rightSplitPane.getBottomComponent() != rightBottomTabbedPane) {
        rightSplitPane.setBottomComponent(rightBottomTabbedPane);
    }
    if (rightBottomTabbedPane.getComponentAt(destComponentIndex) != bottomComponent) {
        rightBottomTabbedPane.setComponentAt(destComponentIndex, bottomComponent);
        rightBottomTabbedPane.repaint();
    }
    rightBottomTabbedPane.setSelectedComponent(bottomComponent);
}
Also used : Simulation(cbit.vcell.solver.Simulation) TabCloseIcon(cbit.vcell.client.desktop.biomodel.TabCloseIcon) JComponent(javax.swing.JComponent) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) DocumentEditorTreeFolderNode(cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderNode) CSGObject(cbit.vcell.geometry.CSGObject) MathModelInfo(org.vcell.util.document.MathModelInfo) CSGObject(cbit.vcell.geometry.CSGObject) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Example 14 with CSGObject

use of cbit.vcell.geometry.CSGObject 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 CSGObject

use of cbit.vcell.geometry.CSGObject 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

CSGObject (cbit.vcell.geometry.CSGObject)23 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)11 GeometryThumbnailImageFactoryAWT (cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT)8 Expression (cbit.vcell.parser.Expression)7 CSGNode (cbit.vcell.geometry.CSGNode)6 CSGSetOperator (cbit.vcell.geometry.CSGSetOperator)6 SubVolume (cbit.vcell.geometry.SubVolume)6 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)5 BioModelNode (cbit.vcell.desktop.BioModelNode)5 CSGTransformation (cbit.vcell.geometry.CSGTransformation)5 Geometry (cbit.vcell.geometry.Geometry)5 ImageSubVolume (cbit.vcell.geometry.ImageSubVolume)5 Hashtable (java.util.Hashtable)5 BioModel (cbit.vcell.biomodel.BioModel)4 CSGPrimitive (cbit.vcell.geometry.CSGPrimitive)4 CSGScale (cbit.vcell.geometry.CSGScale)4 CSGTranslation (cbit.vcell.geometry.CSGTranslation)4 SimulationContext (cbit.vcell.mapping.SimulationContext)4 ImageException (cbit.image.ImageException)3 CSGRotation (cbit.vcell.geometry.CSGRotation)3