use of cbit.vcell.graph.GeometryContextGeometryShape in project vcell by virtualcell.
the class GraphContainerLayoutVCellClassical method getPreferedSizeGeometryContextGeometryShape.
public Dimension getPreferedSizeGeometryContextGeometryShape(GeometryContextGeometryShape shape, Graphics2D g) throws GraphModel.NotReadyException {
Dimension d = shape.getPreferedSizeSelf(g);
int height = 2 * shape.getLabelSize().height + 2;
Dimension childDim = new Dimension();
try {
if (shape.countChildren() > 0) {
for (Shape child : shape.getChildren()) {
childDim.height += getPreferedSize(child, g).height;
childDim.width = Math.max(childDim.width, getPreferedSize(child, g).width);
}
} else {
childDim = new Dimension(100, 100);
}
} catch (ConcurrentModificationException exception) {
throw new GraphModel.NotReadyException(exception);
}
Dimension newDim = new Dimension(Math.max(d.width, childDim.width) + 10, height + childDim.height);
return newDim;
}
use of cbit.vcell.graph.GeometryContextGeometryShape in project vcell by virtualcell.
the class GraphContainerLayoutVCellClassical method refreshLayoutChildrenGeometryContextGeometryShape.
public void refreshLayoutChildrenGeometryContextGeometryShape(GeometryContextGeometryShape shape) {
final int PAD_Y = 5;
int centerX = shape.getSpaceManager().getSize().width / 2;
int totalPadY = PAD_Y * (shape.countChildren() - 1);
int totalChildHeight = 0;
int maxChildWidth = 0;
for (Shape child : shape.getChildren()) {
totalChildHeight += child.getSpaceManager().getSize().height;
maxChildWidth = Math.max(maxChildWidth, child.getSpaceManager().getSize().width);
}
int currentY = shape.getSpaceManager().getSize().height / 2 + shape.getLabelSize().height / 2 - totalPadY / 2 - totalChildHeight / 2;
for (int i = 0; i < shape.countChildren(); ++i) {
Shape child = shape.getChildren().get(i);
if (i == shape.countChildren() - 1) {
child.getSpaceManager().setRelPos(centerX - child.getSpaceManager().getSize().width / 2, currentY);
} else {
child.getSpaceManager().setRelPos(centerX - maxChildWidth / 2, currentY);
}
int dy = child.getSpaceManager().getSize().height + PAD_Y;
currentY += dy;
child.refreshLayoutSelf();
refreshLayoutChildren(child);
}
}
use of cbit.vcell.graph.GeometryContextGeometryShape in project vcell by virtualcell.
the class StructureMappingCartoon method refreshAll.
/**
* This method was created by a SmartGuide.
*/
@Override
public void refreshAll() {
clearAllShapes();
if (getSimulationContext() == null) {
fireGraphChanged(new GraphEvent(this));
return;
}
GeometryContextGeometryShape geometryShape = new GeometryContextGeometryShape(this, getGeometryContext().getGeometry());
// GeometryContextStructureShape structureShape = new GeometryContextStructureShape(this,getGeometryContext().getModel());
// GeometryContextContainerShape containerShape = new GeometryContextContainerShape(this,getGeometryContext(),structureShape,geometryShape);
// addShape(containerShape);
addShape(geometryShape);
// addShape(structureShape);
getGeometryContext().removePropertyChangeListener(this);
getGeometryContext().addPropertyChangeListener(this);
//
// create all StructureShapes
//
// Structure structures[] = getGeometryContext().getModel().getStructures();
// for (int i=0;i<structures.length;i++){
// if (structures[i] instanceof Feature){
// //addShape(new FeatureShape((Feature)structures[i],getGeometryContext().getModel(),this));
// StructureMappingFeatureShape smShape = new StructureMappingFeatureShape((Feature)structures[i],getGeometryContext().getModel(),this);
// addShape(smShape);
// containerShape.addChildShape(smShape);
// structures[i].removePropertyChangeListener(this);
// structures[i].addPropertyChangeListener(this);
// }
// }
// create all SubvolumeLegendShapes (for legend)
//
GeometrySpec geometrySpec = getGeometryContext().getGeometry().getGeometrySpec();
SubVolume[] subVolumes = geometrySpec.getSubVolumes();
for (int i = 0; i < subVolumes.length; i++) {
cbit.vcell.geometry.SubVolume subvolume = subVolumes[i];
GeometryClassLegendShape subvolumeLegendShape = new GeometryClassLegendShape(subvolume, getGeometryContext().getGeometry(), this, 10);
addShape(subvolumeLegendShape);
geometryShape.addChildShape(subvolumeLegendShape);
}
// --------------------------------------------------
if ((subVolumeContainerShape == null) || (subVolumeContainerShape.getModelObject() != getGeometryContext().getGeometry())) {
subVolumeContainerShape = new SubVolumeContainerShape(getGeometryContext().getGeometry(), this);
}
subVolumeContainerShape.removeAllChildren();
addShape(subVolumeContainerShape);
geometryShape.addChildShape(subVolumeContainerShape);
// --------------------------------------------------
// // create all SubvolumeShapes (for image)
// //
// for (int i=0;i<subVolumes.length;i++){
// cbit.vcell.geometry.SubVolume subvolume = (cbit.vcell.geometry.SubVolume)subVolumes[i];
// SubvolumeShape subvolumeShape = new SubvolumeShape(subvolume,getGeometryContext().getGeometry(),this);
// addShape(subvolumeShape);
// subVolumeContainerShape.addChildShape(subvolumeShape);
// }
//
// create all FeatureMappingShapes
//
// StructureMapping structureMappings[] = getGeometryContext().getStructureMappings();
// for (int i=0;i<structureMappings.length;i++){
// StructureMapping structureMapping = structureMappings[i];
// if (structureMapping instanceof FeatureMapping){
// FeatureMapping featureMapping = (FeatureMapping)structureMapping;
// if (featureMapping.getSubVolume()!=null){
// FeatureShape featureShape = (FeatureShape)getShapeFromModelObject(featureMapping.getFeature());
// SubvolumeLegendShape subvolumeLegendShape = (SubvolumeLegendShape)getShapeFromModelObject(featureMapping.getSubVolume());
// FeatureMappingShape fmShape = new FeatureMappingShape(featureMapping,featureShape,subvolumeLegendShape,this);
// //FeatureMappingShape fmShape = new FeatureMappingShape(featureMapping,featureShape,featureMapping.getSubVolume(),imageShape,this);
// addShape(fmShape);
// containerShape.addChildShape(fmShape);
// }
// }
// }
//
// assign children to shapes according to heirarchy in Model
//
// int nullParentCount=0;
// Enumeration enum_shape = getShapes();
// while (enum_shape.hasMoreElements()){
// Shape shape = (Shape)enum_shape.nextElement();
// //
// // for each featureShape, find corresponding featureShape
// //
// if (shape instanceof FeatureShape){
// FeatureShape fs = (FeatureShape)shape;
// Membrane membrane = fs.getFeature().getMembrane();
// if (membrane!=null){
// //
// // add this feature as child to parent feature
// //
// Feature parentFeature = membrane.getOutsideFeature();
// FeatureShape parentFeatureShape = (FeatureShape)getShapeFromModelObject(parentFeature);
// if (!parentFeatureShape.contains(fs)){
// parentFeatureShape.addChildShape(fs);
// }
// }else{
// if (!structureShape.contains(fs)){
// structureShape.addChildShape(fs);
// }
// nullParentCount++;
// }
// }
// }
fireGraphChanged(new GraphEvent(this));
}
Aggregations