Search in sources :

Example 1 with GeometryContextGeometryShape

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;
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) NotReadyException(cbit.gui.graph.GraphModel.NotReadyException) SubVolumeContainerShape(cbit.vcell.graph.SubVolumeContainerShape) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) MembraneShape(cbit.vcell.graph.MembraneShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) GeometryContextStructureShape(cbit.vcell.graph.GeometryContextStructureShape) FeatureShape(cbit.vcell.graph.FeatureShape) StructureMappingStructureShape(cbit.vcell.graph.StructureMappingStructureShape) ContainerContainerShape(cbit.vcell.graph.ContainerContainerShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) GeometryContextContainerShape(cbit.vcell.graph.GeometryContextContainerShape) GeometryContextGeometryShape(cbit.vcell.graph.GeometryContextGeometryShape) StructureShape(cbit.vcell.graph.StructureShape) GeometryClassLegendShape(cbit.vcell.graph.GeometryClassLegendShape) BioPaxShape(cbit.vcell.client.desktop.biomodel.pathway.shapes.BioPaxShape) Dimension(java.awt.Dimension) Point(java.awt.Point)

Example 2 with GeometryContextGeometryShape

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);
    }
}
Also used : SubVolumeContainerShape(cbit.vcell.graph.SubVolumeContainerShape) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) MembraneShape(cbit.vcell.graph.MembraneShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) GeometryContextStructureShape(cbit.vcell.graph.GeometryContextStructureShape) FeatureShape(cbit.vcell.graph.FeatureShape) StructureMappingStructureShape(cbit.vcell.graph.StructureMappingStructureShape) ContainerContainerShape(cbit.vcell.graph.ContainerContainerShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) GeometryContextContainerShape(cbit.vcell.graph.GeometryContextContainerShape) GeometryContextGeometryShape(cbit.vcell.graph.GeometryContextGeometryShape) StructureShape(cbit.vcell.graph.StructureShape) GeometryClassLegendShape(cbit.vcell.graph.GeometryClassLegendShape) BioPaxShape(cbit.vcell.client.desktop.biomodel.pathway.shapes.BioPaxShape) Point(java.awt.Point)

Example 3 with GeometryContextGeometryShape

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));
}
Also used : GeometrySpec(cbit.vcell.geometry.GeometrySpec) GeometryClassLegendShape(cbit.vcell.graph.GeometryClassLegendShape) SubVolume(cbit.vcell.geometry.SubVolume) GeometryContextGeometryShape(cbit.vcell.graph.GeometryContextGeometryShape) GraphEvent(cbit.gui.graph.GraphEvent) SubVolume(cbit.vcell.geometry.SubVolume) SubVolumeContainerShape(cbit.vcell.graph.SubVolumeContainerShape)

Aggregations

GeometryClassLegendShape (cbit.vcell.graph.GeometryClassLegendShape)3 GeometryContextGeometryShape (cbit.vcell.graph.GeometryContextGeometryShape)3 SubVolumeContainerShape (cbit.vcell.graph.SubVolumeContainerShape)3 BioPaxShape (cbit.vcell.client.desktop.biomodel.pathway.shapes.BioPaxShape)2 ContainerContainerShape (cbit.vcell.graph.ContainerContainerShape)2 FeatureShape (cbit.vcell.graph.FeatureShape)2 GeometryContextContainerShape (cbit.vcell.graph.GeometryContextContainerShape)2 GeometryContextStructureShape (cbit.vcell.graph.GeometryContextStructureShape)2 MembraneShape (cbit.vcell.graph.MembraneShape)2 ReactionContainerShape (cbit.vcell.graph.ReactionContainerShape)2 ReactionStepShape (cbit.vcell.graph.ReactionStepShape)2 SpeciesContextShape (cbit.vcell.graph.SpeciesContextShape)2 StructureMappingStructureShape (cbit.vcell.graph.StructureMappingStructureShape)2 StructureShape (cbit.vcell.graph.StructureShape)2 Point (java.awt.Point)2 GraphEvent (cbit.gui.graph.GraphEvent)1 NotReadyException (cbit.gui.graph.GraphModel.NotReadyException)1 GeometrySpec (cbit.vcell.geometry.GeometrySpec)1 SubVolume (cbit.vcell.geometry.SubVolume)1 Dimension (java.awt.Dimension)1