Search in sources :

Example 26 with SurfaceClass

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

the class GeomDbDriver method getGeometry.

/**
 * This method was created in VisualAge.
 * @return cbit.vcell.model.Model
 * @param rset java.sql.ResultSet
 */
private Geometry getGeometry(QueryHashtable dbc, Connection con, User user, ResultSet rset) throws SQLException, DataAccessException {
    // 
    // get Image reference
    // 
    java.math.BigDecimal bigD = rset.getBigDecimal(geomTable.imageRef.toString());
    KeyValue imageRef = null;
    if (!rset.wasNull()) {
        imageRef = new KeyValue(bigD);
    }
    // 
    // get geometry object
    // 
    Geometry tempGeometry = null;
    try {
        tempGeometry = geomTable.getGeometry(rset, con);
    } catch (PropertyVetoException e) {
        throw new DataAccessException(e.getMessage());
    }
    Geometry geom = null;
    // 
    // get image for this geometry
    // 
    VCImage vcImage = null;
    if (imageRef != null) {
        // permission checking for the image is disabled because it is a child of this geometry
        vcImage = getVCImage(dbc, con, user, imageRef, false);
    }
    if (vcImage != null) {
        geom = new Geometry(tempGeometry, vcImage);
    } else {
        geom = tempGeometry;
    }
    // 
    // get SubVolumes for this geometry
    // 
    SubVolume[] subVolumes = getSubVolumesFromGeometry(dbc, con, geom.getVersion().getVersionKey());
    if (subVolumes != null) {
        try {
            geom.getGeometrySpec().setSubVolumes(subVolumes);
        } catch (java.beans.PropertyVetoException e) {
            lg.error(e.getMessage(), e);
            throw new DataAccessException(e.getMessage());
        }
    }
    // 
    if (geom.getDimension() > 0) {
        getSurfaceDescription(con, geom);
    }
    // 
    if (geom.getDimension() > 0) {
        getFilaments(con, geom);
    }
    // 
    // get SurfaceClasses for this geometry
    // 
    SurfaceClass[] surfaceClasses = getSurfaceClassesFromGeometry(dbc, con, geom.getVersion().getVersionKey());
    if (surfaceClasses != null) {
        try {
            geom.getGeometrySurfaceDescription().setSurfaceClasses(surfaceClasses);
        } catch (java.beans.PropertyVetoException e) {
            lg.error(e.getMessage(), e);
            throw new DataAccessException(e.getMessage());
        }
    }
    return geom;
}
Also used : KeyValue(org.vcell.util.document.KeyValue) SurfaceClass(cbit.vcell.geometry.SurfaceClass) VCImage(cbit.image.VCImage) Geometry(cbit.vcell.geometry.Geometry) PropertyVetoException(java.beans.PropertyVetoException) PropertyVetoException(java.beans.PropertyVetoException) BigDecimal(java.math.BigDecimal) SubVolume(cbit.vcell.geometry.SubVolume) DataAccessException(org.vcell.util.DataAccessException)

Example 27 with SurfaceClass

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

the class GeomDbDriver method insertSurfaceClassesSQL.

private void insertSurfaceClassesSQL(InsertHashtable hash, Connection con, Geometry geom, KeyValue geomKey) throws SQLException, cbit.image.ImageException, DataAccessException, ObjectNotFoundException {
    if (geom.getGeometrySurfaceDescription() == null || geom.getGeometrySurfaceDescription().getSurfaceClasses() == null) {
        return;
    }
    SurfaceClass[] surfaceClasses = geom.getGeometrySurfaceDescription().getSurfaceClasses();
    for (int i = 0; i < surfaceClasses.length; i++) {
        SurfaceClass surfaceClass = surfaceClasses[i];
        if (hash.getDatabaseKey(surfaceClass) == null) {
            KeyValue newSurfaceClassKey = keyFactory.getNewKey(con);
            String sql = "INSERT INTO " + SurfaceClassTable.table.getTableName() + " " + SurfaceClassTable.table.getSQLColumnList() + " VALUES " + SurfaceClassTable.table.getSQLValueList(hash, newSurfaceClassKey, geom, surfaceClass, geomKey);
            // System.out.println(sql);
            updateCleanSQL(con, sql);
            hash.put(surfaceClass, newSurfaceClassKey);
        }
    }
}
Also used : KeyValue(org.vcell.util.document.KeyValue) SurfaceClass(cbit.vcell.geometry.SurfaceClass)

Example 28 with SurfaceClass

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

the class GeomDbDriver method getSurfaceClassesFromGeometry.

private SurfaceClass[] getSurfaceClassesFromGeometry(QueryHashtable dbc, Connection con, KeyValue geomKey) throws SQLException, DataAccessException {
    // log.print("GeomDbDriver.getSubVolumesFromGeometry(geometryKey="+geomKey+")");
    String sql;
    sql = " SELECT * " + " FROM " + SurfaceClassTable.table.getTableName() + " WHERE " + SurfaceClassTable.table.geometryRef + " = " + geomKey;
    // System.out.println(sql);
    Statement stmt = con.createStatement();
    Vector<SurfaceClass> surfaceClassV = new Vector<SurfaceClass>();
    try {
        ResultSet rset = stmt.executeQuery(sql);
        // showMetaData(rset);
        SurfaceClass surfaceClass = null;
        while (rset.next()) {
            surfaceClass = getSurfaceClass(dbc, con, rset);
            surfaceClassV.addElement(surfaceClass);
        }
        if (surfaceClassV.size() > 0) {
            return surfaceClassV.toArray(new SurfaceClass[0]);
        } else {
            return null;
        }
    } catch (ExpressionException e) {
        throw new DataAccessException(e.getMessage());
    } finally {
        // Release resources include resultset
        stmt.close();
    }
}
Also used : SurfaceClass(cbit.vcell.geometry.SurfaceClass) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) Vector(java.util.Vector) ExpressionException(cbit.vcell.parser.ExpressionException) DataAccessException(org.vcell.util.DataAccessException)

Example 29 with SurfaceClass

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

the class GeomDbDriver method getSurfaceClass.

private SurfaceClass getSurfaceClass(QueryHashtable dbc, Connection con, ResultSet rset) throws SQLException, DataAccessException, ExpressionException {
    // showMetaData(rset);
    // 
    // if already in cache, then return that instance instead of a new one
    // 
    KeyValue surfaceClassKey = new KeyValue(rset.getBigDecimal(SurfaceClassTable.table.id.toString()));
    SurfaceClass surfaceClass = (SurfaceClass) dbc.get(surfaceClassKey);
    if (surfaceClass != null) {
        return surfaceClass;
    }
    String surfaceClassName = rset.getString(SurfaceClassTable.table.name.toString());
    BigDecimal subVolumeRef1 = rset.getBigDecimal(SurfaceClassTable.table.subVolumeRef1.toString());
    BigDecimal subVolumeRef2 = rset.getBigDecimal(SurfaceClassTable.table.subVolumeRef2.toString());
    KeyValue subVolumeref1Key = null;
    KeyValue subVolumeref2Key = null;
    HashSet<SubVolume> subVolumeSet = new HashSet<SubVolume>();
    if (subVolumeRef1 != null) {
        subVolumeref1Key = new KeyValue(subVolumeRef1);
        SubVolume subvolume = (SubVolume) dbc.get(subVolumeref1Key);
        if (subvolume != null) {
            subVolumeSet.add(subvolume);
        } else {
            throw new DataAccessException("Subvolume key=" + subVolumeref1Key + " not found in cache");
        }
    }
    if (subVolumeRef2 != null) {
        subVolumeref2Key = new KeyValue(subVolumeRef2);
        SubVolume subvolume = (SubVolume) dbc.get(subVolumeref2Key);
        if (subvolume != null) {
            subVolumeSet.add(subvolume);
        } else {
            throw new DataAccessException("Subvolume key=" + subVolumeref1Key + " not found in cache");
        }
    }
    SurfaceClass surfaceclass = new SurfaceClass(subVolumeSet, surfaceClassKey, surfaceClassName);
    // 
    // put newly read SumVolume into object cache
    // 
    dbc.put(surfaceClassKey, surfaceclass);
    return surfaceclass;
}
Also used : KeyValue(org.vcell.util.document.KeyValue) SurfaceClass(cbit.vcell.geometry.SurfaceClass) SubVolume(cbit.vcell.geometry.SubVolume) BigDecimal(java.math.BigDecimal) DataAccessException(org.vcell.util.DataAccessException) HashSet(java.util.HashSet)

Example 30 with SurfaceClass

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

the class StructureMappingTableModel method updateSubdomainComboBox.

@SuppressWarnings({ "rawtypes", "unchecked" })
private void updateSubdomainComboBox() {
    GeometryClass[] geometryClasses = getGeometryContext().getGeometry().getGeometryClasses();
    DefaultComboBoxModel aModel = new DefaultComboBoxModel();
    for (GeometryClass gc : geometryClasses) {
        aModel.addElement(gc);
    }
    JComboBox subdomainComboBoxCellEditor = new JComboBox();
    subdomainComboBoxCellEditor.setRenderer(new DefaultListCellRenderer() {

        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            setHorizontalTextPosition(SwingConstants.LEFT);
            if (value instanceof GeometryClass) {
                GeometryClass gc = (GeometryClass) value;
                setText(gc.getName());
                if (value instanceof SubVolume) {
                    SubVolume subVolume = (SubVolume) value;
                    java.awt.Color handleColor = new java.awt.Color(colormap[subVolume.getHandle()]);
                    // small square icon with subdomain color
                    Icon icon = new ColorIcon(10, 10, handleColor, true);
                    setHorizontalTextPosition(SwingConstants.RIGHT);
                    setIcon(icon);
                } else if (value instanceof SurfaceClass) {
                    SurfaceClass sc = (SurfaceClass) value;
                    Set<SubVolume> sv = sc.getAdjacentSubvolumes();
                    Iterator<SubVolume> iterator = sv.iterator();
                    SubVolume sv1 = iterator.next();
                    SubVolume sv2 = iterator.next();
                    java.awt.Color c1 = new java.awt.Color(colormap[sv2.getHandle()]);
                    java.awt.Color c2 = new java.awt.Color(colormap[sv1.getHandle()]);
                    Icon icon = new ColorIconEx(10, 10, c1, c2);
                    setIcon(icon);
                    setHorizontalTextPosition(SwingConstants.RIGHT);
                }
            }
            return this;
        }
    });
    subdomainComboBoxCellEditor.setModel(aModel);
    ownerTable.getColumnModel().getColumn(SPATIAL_COLUMN_SUBDOMAIN).setCellEditor(new DefaultCellEditor(subdomainComboBoxCellEditor));
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) ColorIcon(org.vcell.util.gui.ColorIcon) JComboBox(javax.swing.JComboBox) SurfaceClass(cbit.vcell.geometry.SurfaceClass) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) DefaultCellEditor(javax.swing.DefaultCellEditor) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) SubVolume(cbit.vcell.geometry.SubVolume) ColorIcon(org.vcell.util.gui.ColorIcon) Icon(javax.swing.Icon) Component(java.awt.Component) ColorIconEx(org.vcell.util.gui.ColorIconEx) JList(javax.swing.JList)

Aggregations

SurfaceClass (cbit.vcell.geometry.SurfaceClass)48 SubVolume (cbit.vcell.geometry.SubVolume)42 GeometryClass (cbit.vcell.geometry.GeometryClass)19 Expression (cbit.vcell.parser.Expression)19 Geometry (cbit.vcell.geometry.Geometry)15 Feature (cbit.vcell.model.Feature)13 MathDescription (cbit.vcell.math.MathDescription)12 Model (cbit.vcell.model.Model)12 SpeciesContext (cbit.vcell.model.SpeciesContext)12 VCImage (cbit.image.VCImage)11 ImageSubVolume (cbit.vcell.geometry.ImageSubVolume)11 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)11 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)11 Membrane (cbit.vcell.model.Membrane)11 Structure (cbit.vcell.model.Structure)11 FeatureMapping (cbit.vcell.mapping.FeatureMapping)10 ArrayList (java.util.ArrayList)10 ImageException (cbit.image.ImageException)9 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)8 CompartmentSubVolume (cbit.vcell.geometry.CompartmentSubVolume)8