use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class StructureMappingTableModel method propertyChange.
/**
* This method gets called when a bound property is changed.
* @param evt A PropertyChangeEvent object describing the event source
* and the property that has changed.
*/
public void propertyChange(java.beans.PropertyChangeEvent evt) {
if (evt.getSource() == this && evt.getPropertyName().equals(PROPERTY_GEOMETRY_CONTEXT)) {
GeometryContext oldValue = (GeometryContext) evt.getOldValue();
if (oldValue != null) {
oldValue.removePropertyChangeListener(this);
StructureMapping[] oldStructureMappings = oldValue.getStructureMappings();
for (int i = 0; i < oldStructureMappings.length; i++) {
oldStructureMappings[i].removePropertyChangeListener(this);
}
SubVolume[] subvols = oldValue.getGeometry().getGeometrySpec().getSubVolumes();
for (int i = 0; i < subvols.length; i++) {
subvols[i].removePropertyChangeListener(this);
}
}
GeometryContext newValue = (GeometryContext) evt.getNewValue();
if (newValue != null) {
newValue.addPropertyChangeListener(this);
StructureMapping[] newStructureMappings = newValue.getStructureMappings();
for (int i = 0; i < newStructureMappings.length; i++) {
newStructureMappings[i].addPropertyChangeListener(this);
}
SubVolume[] subvols = newValue.getGeometry().getGeometrySpec().getSubVolumes();
for (int i = 0; i < subvols.length; i++) {
subvols[i].addPropertyChangeListener(this);
}
}
update();
}
if (evt.getSource() == getGeometryContext() && evt.getPropertyName().equals(GeometryOwner.PROPERTY_NAME_GEOMETRY)) {
SubVolume[] subvols = ((Geometry) evt.getOldValue()).getGeometrySpec().getSubVolumes();
for (int i = 0; i < subvols.length; i++) {
subvols[i].removePropertyChangeListener(this);
}
subvols = ((Geometry) evt.getNewValue()).getGeometrySpec().getSubVolumes();
for (int i = 0; i < subvols.length; i++) {
subvols[i].addPropertyChangeListener(this);
}
update();
}
// subvolume name change
if (evt.getSource() instanceof SubVolume) {
update();
}
if (evt.getSource() instanceof GeometryContext && evt.getPropertyName().equals(GeometryContext.PROPERTY_STRUCTURE_MAPPINGS)) {
StructureMapping[] oldStructureMappings = (StructureMapping[]) evt.getOldValue();
StructureMapping[] newStructureMappings = (StructureMapping[]) evt.getNewValue();
for (int i = 0; oldStructureMappings != null && i < oldStructureMappings.length; i++) {
oldStructureMappings[i].removePropertyChangeListener(this);
}
for (int i = 0; newStructureMappings != null && i < newStructureMappings.length; i++) {
newStructureMappings[i].addPropertyChangeListener(this);
}
update();
}
if (evt.getSource() instanceof StructureMapping) {
fireTableRowsUpdated(0, getRowCount() - 1);
}
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class MathDebuggerPanel method main.
public static void main(java.lang.String[] args) {
try {
javax.swing.JFrame frame = new javax.swing.JFrame();
MathDebuggerPanel aMathDebuggerPanel;
aMathDebuggerPanel = new MathDebuggerPanel();
frame.setContentPane(aMathDebuggerPanel);
frame.setTitle("Math Descriptions Comparator");
frame.setSize(aMathDebuggerPanel.getSize());
frame.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
MathModel mathModel1 = new MathModel(null);
mathModel1.setName("math1");
Geometry geometry1 = new Geometry("geo", 0);
MathDescription mathDesc1 = mathModel1.getMathDescription();
mathDesc1.setGeometry(geometry1);
mathDesc1.addSubDomain(new CompartmentSubDomain("Compartment", CompartmentSubDomain.NON_SPATIAL_PRIORITY));
MathModel mathModel2 = new MathModel(null);
mathModel2.setName("math2");
Geometry geometry2 = new Geometry("geo", 0);
MathDescription mathDesc2 = mathModel2.getMathDescription();
mathDesc2.setGeometry(geometry2);
mathDesc2.addSubDomain(new CompartmentSubDomain("Compartment", CompartmentSubDomain.NON_SPATIAL_PRIORITY));
aMathDebuggerPanel.setMathModel1(mathModel1);
aMathDebuggerPanel.setMathModel2(mathModel2);
frame.setSize(1500, 800);
frame.setVisible(true);
} catch (Throwable exception) {
System.err.println("Exception occurred in main() of javax.swing.JPanel");
exception.printStackTrace(System.out);
}
}
use of cbit.vcell.geometry.Geometry 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.Geometry in project vcell by virtualcell.
the class GeometryTable method getGeometry.
/**
* This method was created in VisualAge.
* @return Model
* @param rset ResultSet
* @param log SessionLog
*/
public Geometry getGeometry(ResultSet rset, Connection con) throws SQLException, DataAccessException, PropertyVetoException {
int dim = rset.getInt(dimension.toString());
double ox = rset.getBigDecimal(originX.toString()).doubleValue();
double oy = rset.getBigDecimal(originY.toString()).doubleValue();
double oz = rset.getBigDecimal(originZ.toString()).doubleValue();
double ex = rset.getBigDecimal(ExtentTable.table.extentX.toString()).doubleValue();
double ey = rset.getBigDecimal(ExtentTable.table.extentY.toString()).doubleValue();
double ez = rset.getBigDecimal(ExtentTable.table.extentZ.toString()).doubleValue();
java.math.BigDecimal groupid = rset.getBigDecimal(VersionTable.privacy_ColumnName);
Version version = getVersion(rset, DbDriver.getGroupAccessFromGroupID(con, groupid));
Geometry geometry = new Geometry(version, dim);
geometry.getGeometrySpec().setOrigin(new org.vcell.util.Origin(ox, oy, oz));
geometry.getGeometrySpec().setExtent(new org.vcell.util.Extent(ex, ey, ez));
return geometry;
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class MathDescriptionDbDriver method getMathDescriptionSQL.
/**
* This method was created in VisualAge.
* @return cbit.vcell.math.MathDescription
* @param user cbit.vcell.server.User
* @param mathDescKey cbit.sql.KeyValue
*/
private MathDescription getMathDescriptionSQL(QueryHashtable dbc, Connection con, User user, KeyValue mathDescKey) throws SQLException, DataAccessException, ObjectNotFoundException {
String sql;
Field[] f = { userTable.userid, new cbit.sql.StarField(mathDescTable) };
Table[] t = { mathDescTable, userTable };
String condition = mathDescTable.id.getQualifiedColName() + " = " + mathDescKey + " AND " + userTable.id.getQualifiedColName() + " = " + mathDescTable.ownerRef.getQualifiedColName();
sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, (OuterJoin) null, condition, null, dbSyntax);
// System.out.println(sql);
MathDescription mathDescription = null;
Statement stmt = con.createStatement();
try {
ResultSet rset = stmt.executeQuery(sql);
if (rset.next()) {
//
// note: must call mathDescTable.getMathDescription() first (rset.getBytes(language) must be called first)
//
mathDescription = mathDescTable.getMathDescription(rset, con, dbSyntax);
//
// get Geometry reference and assign to mathDescription
//
java.math.BigDecimal bigD = rset.getBigDecimal(MathDescTable.table.geometryRef.toString());
KeyValue geomRef = null;
if (!rset.wasNull()) {
geomRef = new KeyValue(bigD);
} else {
throw new DataAccessException("Error: Geometry Reference Cannot be Null for MathDescription");
}
Geometry geom = (Geometry) geomDB.getVersionable(dbc, con, user, VersionableType.Geometry, geomRef, false);
try {
mathDescription.setGeometry(geom);
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace(System.out);
throw new DataAccessException("DataAccess Exception: " + e.getMessage());
}
} else {
throw new ObjectNotFoundException("MathDescription id=" + mathDescKey + " not found for user '" + user + "'");
}
} finally {
// Release resources include resultset
stmt.close();
}
return mathDescription;
}
Aggregations