use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class PDEDataContextPanel method getCurveValue.
/**
* Insert the method's description here.
* Creation date: (3/13/2001 12:53:10 PM)
* @return java.lang.String
* @param csi cbit.vcell.geometry.CurveSelectionInfo
*/
public String getCurveValue(CurveSelectionInfo csi) {
String infoS = null;
if (csi.getType() == CurveSelectionInfo.TYPE_SEGMENT) {
if (membranesAndIndexes != null) {
java.util.Enumeration<SampledCurve> keysEnum = membranesAndIndexes.keys();
while (keysEnum.hasMoreElements()) {
Curve curve = (Curve) keysEnum.nextElement();
if (csi.getCurve() == curve) {
int[] membraneIndexes = (int[]) membranesAndIndexes.get(curve);
if (meshDisplayAdapter != null) {
double[] membraneValues = meshDisplayAdapter.getDataValuesForMembraneIndexes(membraneIndexes, getPdeDataContext().getDataValues(), getPdeDataContext().getDataIdentifier().getVariableType());
if (membraneValues != null) {
Coordinate segmentWC = getPdeDataContext().getCartesianMesh().getCoordinateFromMembraneIndex(membraneIndexes[csi.getSegment()]);
String xCoordString = NumberUtils.formatNumber(segmentWC.getX());
String yCoordString = NumberUtils.formatNumber(segmentWC.getY());
String zCoordString = NumberUtils.formatNumber(segmentWC.getZ());
boolean bDefined = getDataInfoProvider() == null || getDataInfoProvider().isDefined(membraneIndexes[csi.getSegment()]);
infoS = "(" + xCoordString + "," + yCoordString + "," + zCoordString + ") [" + membraneIndexes[csi.getSegment()] + "] Value = " + (bDefined ? membraneValues[csi.getSegment()] : "Undefined");
if (getPdeDataContext().getCartesianMesh() != null && getPdeDataContext().getCartesianMesh().isChomboMesh()) {
if (bDefined && getDataInfoProvider() != null) {
StructureMetricsEntry structure = ((CartesianMeshChombo) getDataInfoProvider().getPDEDataContext().getCartesianMesh()).getStructureInfo(getDataInfoProvider().getPDEDataContext().getDataIdentifier());
if (structure != null) {
infoS += " || " + structure.getDisplayLabel();
}
}
} else {
if (getDataInfoProvider() != null) {
MembraneDataInfo membraneDataInfo = getDataInfoProvider().getMembraneDataInfo(membraneIndexes[csi.getSegment()]);
infoS += " ";
infoS += " \"" + membraneDataInfo.membraneName + "\"";
infoS += " mrID=" + membraneDataInfo.membraneRegionID;
}
String curveDescr = CurveRenderer.getROIDescriptions(segmentWC, getImagePlaneManagerPanel().getCurveRenderer());
if (curveDescr != null) {
infoS += " " + curveDescr;
}
}
break;
}
}
}
}
}
}
return infoS;
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class ImageJHelper method sendMembraneOutline.
private static void sendMembraneOutline(ImageJConnection imageJConnection, Hashtable<SampledCurve, int[]>[] membraneTables) throws Exception {
if (membraneTables != null) {
// num slices
imageJConnection.dos.writeInt(membraneTables.length);
for (Hashtable<SampledCurve, int[]> membraneTable : membraneTables) {
// System.out.println();
if (membraneTable != null) {
// some slices have no membrane outline
// num polygons on slice
imageJConnection.dos.writeInt(membraneTable.size());
Enumeration<SampledCurve> sliceMembranes = membraneTable.keys();
while (sliceMembranes.hasMoreElements()) {
SampledCurve sampledCurve = sliceMembranes.nextElement();
Vector<Coordinate> polygonPoints = sampledCurve.getControlPointsVector();
// System.out.println(polygonPoints.size());
// num points for polygon
imageJConnection.dos.writeInt(polygonPoints.size());
// isClosed
imageJConnection.dos.writeInt((sampledCurve.isClosed() ? 1 : 0));
for (Coordinate coord : polygonPoints) {
imageJConnection.dos.writeDouble(coord.getX());
imageJConnection.dos.writeDouble(coord.getY());
imageJConnection.dos.writeDouble(coord.getZ());
}
}
} else {
imageJConnection.dos.writeInt(0);
}
}
} else {
imageJConnection.dos.writeInt(0);
}
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class ImagePlaneManager method snapWorldCoordinate.
/**
* Insert the method's description here.
* Creation date: (7/12/2004 1:52:04 PM)
*/
public org.vcell.util.Coordinate snapWorldCoordinate(org.vcell.util.Coordinate targetC) {
if (getSourceDataInfo() != null) {
double distance = 0;
org.vcell.util.CoordinateIndex centerCI = getSourceDataInfo().getDataIndexFromWorldCoordinate(targetC);
Coordinate centerCoord = getSourceDataInfo().getWorldCoordinateFromIndex(centerCI);
return centerCoord;
}
return null;
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class PDEOffscreenRenderer method getPixelsRGB.
/**
* Insert the method's description here.
* Creation date: (3/1/2001 11:54:44 PM)
* @return int[]
*/
public int[] getPixelsRGB(int imageScale, int membrScale, int meshMode, int volVarMembrOutlineThickness) {
if (getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.VOLUME) || getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.POSTPROCESSING)) {
CartesianMesh mesh = getServerPDEDataContext().getCartesianMesh();
MeshDisplayAdapter meshDisplayAdapter = new MeshDisplayAdapter(mesh);
BufferedImage bufferedImage = getScaledRGBVolume(mesh, meshMode, imageScale, false);
//
if (!getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.POSTPROCESSING) && volVarMembrOutlineThickness > 0) {
cbit.vcell.geometry.CurveRenderer curveRenderer = new cbit.vcell.geometry.CurveRenderer(getDisplayAdapterService());
curveRenderer.setNormalAxis(getNormalAxis());
org.vcell.util.Origin origin = mesh.getOrigin();
org.vcell.util.Extent extent = mesh.getExtent();
curveRenderer.setWorldOrigin(new org.vcell.util.Coordinate(origin.getX(), origin.getY(), origin.getZ()));
Coordinate pixeldelta = getPixelDelta(extent, mesh, meshMode, imageScale);
curveRenderer.setWorldDelta(new org.vcell.util.Coordinate(pixeldelta.getX(), pixeldelta.getY(), pixeldelta.getZ()));
Hashtable<SampledCurve, int[]> curvesAndMembraneIndexes = meshDisplayAdapter.getCurvesAndMembraneIndexes(getNormalAxis(), getSlice());
if (curvesAndMembraneIndexes != null) {
Curve[] curves = (Curve[]) org.vcell.util.BeanUtils.getArray(curvesAndMembraneIndexes.keys(), Curve.class);
for (int i = 0; curves != null && i < curves.length; i++) {
curveRenderer.addCurve(curves[i]);
curveRenderer.renderPropertySegmentColors(curves[i], null);
curveRenderer.renderPropertyLineWidthMultiplier(curves[i], volVarMembrOutlineThickness);
}
Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
// must be false or could get more than 256 colors
curveRenderer.setAntialias(false);
curveRenderer.draw(g);
}
}
return ((DataBufferInt) bufferedImage.getData().getDataBuffer()).getData();
} else if (getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.MEMBRANE)) {
CartesianMesh mesh = getServerPDEDataContext().getCartesianMesh();
MeshDisplayAdapter meshDisplayAdapter = new MeshDisplayAdapter(mesh);
BufferedImage bufferedImage = getScaledRGBVolume(mesh, meshMode, imageScale, true);
//
// apply curve renderer
//
cbit.vcell.geometry.CurveRenderer curveRenderer = new cbit.vcell.geometry.CurveRenderer(getDisplayAdapterService());
curveRenderer.setNormalAxis(getNormalAxis());
org.vcell.util.Origin origin = mesh.getOrigin();
org.vcell.util.Extent extent = mesh.getExtent();
curveRenderer.setWorldOrigin(new org.vcell.util.Coordinate(origin.getX(), origin.getY(), origin.getZ()));
Coordinate pixeldelta = getPixelDelta(extent, mesh, meshMode, imageScale);
curveRenderer.setWorldDelta(new org.vcell.util.Coordinate(pixeldelta.getX(), pixeldelta.getY(), pixeldelta.getZ()));
Hashtable<SampledCurve, int[]> curvesAndMembraneIndexes = meshDisplayAdapter.getCurvesAndMembraneIndexes(getNormalAxis(), getSlice());
if (curvesAndMembraneIndexes != null) {
Curve[] curves = (Curve[]) org.vcell.util.BeanUtils.getArray(curvesAndMembraneIndexes.keys(), Curve.class);
for (int i = 0; curves != null && i < curves.length; i++) {
curveRenderer.addCurve(curves[i]);
curveRenderer.renderPropertySegmentColors(curves[i], getCurveColors(curvesAndMembraneIndexes, curves[i], meshDisplayAdapter));
curveRenderer.renderPropertyLineWidthMultiplier(curves[i], membrScale);
}
Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
curveRenderer.setAntialias(false);
curveRenderer.draw(g);
}
return ((DataBufferInt) bufferedImage.getData().getDataBuffer()).getData();
} else {
throw new RuntimeException("unsupported VariableType " + getServerPDEDataContext().getDataIdentifier().getVariableType());
}
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class PDEOffscreenRenderer method getPixelDelta.
private Coordinate getPixelDelta(Extent extent, CartesianMesh mesh, int meshMode, int imageScale) {
ImagePaneModel imagePaneModel = new ImagePaneModel();
imagePaneModel.setMode(meshMode);
imagePaneModel.setZoom(imageScale);
double pixelScaleX = extent.getX() / imagePaneModel.getScaledLength(mesh.getSizeX());
double pixelScaleY = extent.getY() / imagePaneModel.getScaledLength(mesh.getSizeY());
double pixelScaleZ = extent.getZ() / imagePaneModel.getScaledLength(mesh.getSizeZ());
return new Coordinate(pixelScaleX, pixelScaleY, pixelScaleZ);
}
Aggregations