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;
}
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);
}
}
}
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();
}
}
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;
}
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));
}
Aggregations