use of cbit.vcell.geometry.Curve in project vcell by virtualcell.
the class PDEDataContextPanel method getInitalCurveSelection.
/**
* Insert the method's description here.
* Creation date: (7/4/2003 6:10:48 PM)
*/
public CurveSelectionInfo getInitalCurveSelection(int tool, Coordinate wc) {
//
CurveSelectionInfo newCurveSelection = null;
VariableType variableType = getPdeDataContext().getDataIdentifier().getVariableType();
if (variableType.equals(VariableType.MEMBRANE) || variableType.equals(VariableType.MEMBRANE_REGION)) {
if (getPdeDataContext().getCartesianMesh().isChomboMesh() && tool == CurveEditorTool.TOOL_POINT) {
newCurveSelection = findChomboSinglePointSelectionInfoForPoint(wc);
} else {
CurveSelectionInfo[] closeCSI = getImagePlaneManagerPanel().getCurveRenderer().getCloseCurveSelectionInfos(wc);
if (closeCSI != null) {
for (int i = 0; i < closeCSI.length; i += 1) {
if (membranesAndIndexes != null && membranesAndIndexes.containsKey(closeCSI[i].getCurve())) {
if (tool == CurveEditorTool.TOOL_LINE) {
newCurveSelection = new CurveSelectionInfo(new CurveSelectionCurve((SampledCurve) (closeCSI[i].getCurve())));
} else if (tool == CurveEditorTool.TOOL_POINT) {
newCurveSelection = new CurveSelectionInfo(new CurveSelectionCurve((SampledCurve) (closeCSI[i].getCurve())));
double dist = closeCSI[i].getCurve().getDistanceTo(wc);
int segmentIndex = closeCSI[i].getCurve().pickSegment(wc, dist * 1.1);
Coordinate[] coordArr = closeCSI[i].getCurve().getSampledCurve().getControlPointsForSegment(segmentIndex);
Coordinate middleCoord = new Coordinate((coordArr[0].getX() + coordArr[1].getX()) / 2, (coordArr[0].getY() + coordArr[1].getY()) / 2, (coordArr[0].getZ() + coordArr[1].getZ()) / 2);
newCurveSelection = new CurveSelectionInfo(new SinglePoint(middleCoord));
}
break;
}
}
}
}
}
if (newCurveSelection != null) {
if (membraneSamplerCurves == null) {
membraneSamplerCurves = new java.util.Vector<Curve>();
}
membraneSamplerCurves.add(newCurveSelection.getCurve());
}
return newCurveSelection;
}
use of cbit.vcell.geometry.Curve in project vcell by virtualcell.
the class GeometryFilamentCurvePanel method setCurve3.
/**
* Set the Curve3 to a new value.
* @param newValue cbit.vcell.geometry.Curve
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void setCurve3(cbit.vcell.geometry.Curve newValue) {
if (ivjCurve3 != newValue) {
try {
cbit.vcell.geometry.Curve oldValue = getCurve3();
ivjCurve3 = newValue;
connPtoP8SetSource();
firePropertyChange("curve", oldValue, newValue);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
;
// user code begin {3}
// user code end
}
use of cbit.vcell.geometry.Curve in project vcell by virtualcell.
the class DisplayImageOp method displayImage.
public void displayImage(final Image image, String title, WindowListener listener) {
final ImagePlaneManagerPanel imagePanel = new ImagePlaneManagerPanel();
double[] doublePixels = image.getDoublePixels();
double minPixel = Double.MAX_VALUE;
double maxPixel = -Double.MAX_VALUE;
for (int i = 0; i < doublePixels.length; i++) {
double pixel = doublePixels[i];
doublePixels[i] = pixel;
minPixel = Math.min(minPixel, pixel);
maxPixel = Math.max(maxPixel, pixel);
}
Range newRange = new Range(minPixel, maxPixel);
SourceDataInfo source = new SourceDataInfo(SourceDataInfo.RAW_VALUE_TYPE, doublePixels, image.getExtent(), image.getOrigin(), newRange, 0, image.getNumX(), 1, image.getNumY(), image.getNumX(), image.getNumZ(), image.getNumX() * image.getNumY());
imagePanel.setDisplayAdapterServicePanelVisible(true);
imagePanel.setCurveValueProvider(new CurveValueProvider() {
@Override
public void curveAdded(Curve curve) {
System.out.println("called curveAdded(" + curve + "), do nothing for now");
}
@Override
public void curveRemoved(Curve curve) {
System.out.println("called curveRemoved(" + curve + ")");
}
@Override
public String getCurveValue(CurveSelectionInfo csi) {
System.out.println("called getCurveValue(CurveSelectionInfo " + csi);
return null;
}
@Override
public CurveSelectionInfo getInitalCurveSelection(int tool, Coordinate wc) {
System.out.println("called getInitialCurveSelection(tool=" + tool + ", coord=" + wc + ")");
return null;
}
@Override
public boolean isAddControlPointOK(int tool, Coordinate wc, Curve addedToThisCurve) {
System.out.println("called isAddControlPointOK");
return true;
}
@Override
public boolean providesInitalCurve(int tool, Coordinate wc) {
System.out.println("called providesInitialCurve(tool=" + tool + " (TOOL_LINE=" + CurveEditorTool.TOOL_LINE + "), coord=" + wc);
return false;
}
@Override
public void setDescription(Curve curve) {
System.out.println("called setDescription(" + curve + ")");
curve.setDescription(CurveValueProvider.DESCRIPTION_VOLUME);
}
@Override
public CurveSelectionInfo findChomboCurveSelectionInfoForPoint(CoordinateIndex ci) {
System.out.println("called find ChomboCurveSelectionInfoForPoint(coord=" + ci + ")");
return null;
}
});
DisplayAdapterService das = imagePanel.getDisplayAdapterServicePanel().getDisplayAdapterService();
das.setValueDomain(null);
das.addColorModelForValues(DisplayAdapterService.createGrayColorModel(), DisplayAdapterService.createGraySpecialColors(), DisplayAdapterService.GRAY);
das.addColorModelForValues(DisplayAdapterService.createBlueRedColorModel(), DisplayAdapterService.createBlueRedSpecialColors(), DisplayAdapterService.BLUERED);
das.setActiveColorModelID(DisplayAdapterService.BLUERED);
final JFrame jframe = new JFrame();
jframe.setTitle(title);
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
GridBagConstraints imageConstraints = new GridBagConstraints();
imageConstraints.gridx = 0;
imageConstraints.gridy = 0;
imageConstraints.weightx = 1.0;
imageConstraints.weighty = 1.0;
imageConstraints.fill = GridBagConstraints.BOTH;
panel.add(imagePanel, imageConstraints);
JButton plotButton = new JButton("plot");
plotButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Curve curve = imagePanel.getCurveRenderer().getSelection().getCurve();
VariableType variableType = VariableType.VOLUME;
Curve samplerCurve = curve.getSampledCurve();
samplerCurve.setDescription(curve.getDescription());
VCImage vcImage = new VCImageUncompressed(null, new byte[image.getISize().getXYZ()], image.getExtent(), image.getISize().getX(), image.getISize().getY(), image.getISize().getZ());
int dimension = 1 + (image.getISize().getY() > 0 ? 1 : 0) + (image.getISize().getZ() > 0 ? 1 : 0);
RegionImage regionImage = new RegionImage(vcImage, dimension, image.getExtent(), image.getOrigin(), RegionImage.NO_SMOOTHING);
CartesianMesh mesh = CartesianMesh.createSimpleCartesianMesh(image.getOrigin(), image.getExtent(), image.getISize(), regionImage);
SpatialSelectionVolume ssVolume = new SpatialSelectionVolume(new CurveSelectionInfo(samplerCurve), variableType, mesh);
String varName = "var";
SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[] { new VolVariable(varName, null) };
PlotData plotData = getLineScan(ssVolume, image, mesh);
PlotPane plotPane = new PlotPane();
DataSymbolMetadataResolver resolver = null;
Plot2D plot2D = new Plot2D(symbolTableEntries, resolver, new String[] { varName }, new PlotData[] { plotData }, new String[] { "Values along curve", "Distance (\u00b5m)", "[" + varName + "]" });
plotPane.setPlot2D(plot2D);
DialogUtils.showComponentCloseDialog(jframe, plotPane, "plot");
} catch (ImageException | IOException | DataAccessException | MathException e1) {
e1.printStackTrace();
}
}
});
GridBagConstraints plotButtonConstraints = new GridBagConstraints();
plotButtonConstraints.gridx = 0;
plotButtonConstraints.gridy = 1;
panel.add(plotButton, plotButtonConstraints);
jframe.getContentPane().add(panel);
jframe.setSize(500, 500);
jframe.addWindowListener(listener);
jframe.setVisible(true);
imagePanel.setSourceDataInfo(source);
}
use of cbit.vcell.geometry.Curve in project vcell by virtualcell.
the class GeomDbDriver method getFilaments.
/**
* Insert the method's description here.
* Creation date: (7/29/00 2:10:42 PM)
* @param con java.sql.Connection
* @param geom cbit.vcell.geometry.Geometry
*/
private void getFilaments(Connection con, Geometry geom) throws SQLException, DataAccessException {
String sql = null;
sql = " SELECT " + filamentTable.filamentName.getQualifiedColName() + "," + curveTable.curveData.getQualifiedColName() + " FROM " + filamentTable.getTableName() + "," + curveTable.getTableName() + " WHERE " + filamentTable.geometryRef.getQualifiedColName() + " = " + geom.getVersion().getVersionKey() + " AND " + curveTable.filamentRef.getQualifiedColName() + " = " + filamentTable.id.getQualifiedColName();
// System.out.println(sql);
Statement stmt = con.createStatement();
try {
ResultSet rset = stmt.executeQuery(sql);
while (rset.next()) {
String filColName = filamentTable.filamentName.toString();
String filamentType = rset.getString(filColName);
Field curveCol = curveTable.curveData;
// Curve curve = CurveTable.decodeCurve(new String(rset.getBytes(curveColName)));
String curveString = (String) DbDriver.getLOB(rset, curveCol, dbSyntax);
Curve curve = CurveTable.decodeCurve(curveString);
//
geom.getGeometrySpec().getFilamentGroup().addCurve(filamentType, curve);
}
} catch (Exception e) {
throw new DataAccessException(e.toString());
} finally {
// Release resources include resultset
stmt.close();
}
}
use of cbit.vcell.geometry.Curve in project vcell by virtualcell.
the class GeomDbDriver method insertFilamentsSQL.
/**
* This method was created in VisualAge.
* @param vcimage cbit.image.VCImage
* @param userid java.lang.String
* @exception java.rmi.RemoteException The exception description.
*/
private void insertFilamentsSQL(Connection con, Geometry geom, KeyValue geomKey) throws SQLException, DataAccessException {
String sql;
Filament[] filaments = geom.getGeometrySpec().getFilamentGroup().getFilaments();
for (int i = 0; i < filaments.length; i++) {
// Iterate through Filaments
KeyValue newFilamentKey = keyFactory.getNewKey(con);
//
// Insert Filament
//
Filament currentFilament = filaments[i];
sql = "INSERT INTO " + filamentTable.getTableName() + " " + filamentTable.getSQLColumnList() + " VALUES " + filamentTable.getSQLValueList(newFilamentKey, currentFilament.getName(), geomKey);
updateCleanSQL(con, sql);
//
// Insert all Curves for this filament
//
Curve[] curves = currentFilament.getCurves();
for (int j = 0; j < curves.length; j += 1) {
KeyValue newCurveKey = keyFactory.getNewKey(con);
sql = "INSERT INTO " + curveTable.getTableName() + " " + curveTable.getSQLColumnList() + " VALUES " + curveTable.getSQLValueList(newCurveKey, newFilamentKey, dbSyntax);
//
switch(dbSyntax) {
case ORACLE:
{
updateCleanSQL(con, sql);
updateCleanLOB(con, curveTable.id.toString(), newCurveKey, curveTable.tableName, curveTable.curveData, CurveTable.encodeCurve(curves[j]), dbSyntax);
break;
}
case POSTGRES:
{
updatePreparedCleanSQL(con, sql, CurveTable.encodeCurve(curves[j]));
break;
}
default:
{
throw new RuntimeException("unexpected DatabaseSyntax " + dbSyntax);
}
}
}
}
}
Aggregations