use of cbit.vcell.graph.SubVolumeContainerShape 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));
}
use of cbit.vcell.graph.SubVolumeContainerShape in project vcell by virtualcell.
the class GraphContainerLayoutVCellClassical method refreshLayoutChildrenGeometryContextStructureShape.
public void refreshLayoutChildrenGeometryContextStructureShape(GeometryContextStructureShape shape) {
// calculate total height and max width of SubVolumeContainerShape
int childHeight = 0;
int childWidth = 0;
for (Shape child : shape.getChildren()) {
childHeight += child.getSpaceManager().getSize().height;
childWidth = Math.max(childWidth, child.getSpaceManager().getSize().width);
}
int centerX = shape.getSpaceManager().getSize().width / 2;
int centerY = shape.getSpaceManager().getSize().height / 2;
int currY = Math.max(0, centerY - childHeight / 2) + shape.getLabelSize().height + 2;
for (Shape child : shape.getChildren()) {
child.getSpaceManager().setRelPos(centerX - child.getSpaceManager().getSize().width / 2, currY);
currY += child.getSpaceManager().getSize().height;
child.refreshLayoutSelf();
refreshLayoutChildren(child);
}
}
Aggregations