Search in sources :

Example 1 with StructureMappingStructureShape

use of cbit.vcell.graph.StructureMappingStructureShape in project vcell by virtualcell.

the class GraphContainerLayoutVCellClassical method getPreferedSizeStructureMappingFeatureShape.

public Dimension getPreferedSizeStructureMappingFeatureShape(StructureMappingStructureShape shape, Graphics2D g) throws GraphModel.NotReadyException {
    FontMetrics fm = g.getFontMetrics();
    shape.getLabelSize().height = fm.getMaxAscent() + fm.getMaxDescent();
    shape.getLabelSize().width = fm.stringWidth(shape.getLabel());
    if (shape.countChildren() > 0) {
        int totalHeight = shape.getLabelSize().height;
        int maxWidth = shape.getLabelSize().width;
        for (Shape child : shape.getChildren()) {
            Dimension childDim = getPreferedSize(child, g);
            totalHeight += childDim.height + StructureShape.defaultSpacingY;
            maxWidth = Math.max(maxWidth, childDim.width);
        }
        shape.getSpaceManager().setSizePreferred((maxWidth + StructureShape.defaultSpacingX * 2), (totalHeight + StructureShape.defaultSpacingY));
    } else {
        shape.getSpaceManager().setSizePreferred((shape.getLabelSize().width + StructureShape.defaultSpacingX * 2), (shape.getLabelSize().height + StructureShape.defaultSpacingY * 2));
    }
    return shape.getSpaceManager().getSizePreferred();
}
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) FontMetrics(java.awt.FontMetrics) Dimension(java.awt.Dimension) Point(java.awt.Point)

Example 2 with StructureMappingStructureShape

use of cbit.vcell.graph.StructureMappingStructureShape in project vcell by virtualcell.

the class GraphContainerLayoutVCellClassical method refreshLayoutChildrenStructureMappingFeatureShape.

public void refreshLayoutChildrenStructureMappingFeatureShape(StructureMappingStructureShape shape) {
    // calculate total height and max width of Child compartments (membranes)
    int memHeight = 0;
    int memWidth = 0;
    for (Shape child : shape.getChildren()) {
        memHeight += child.getSpaceManager().getSize().height;
        memWidth = Math.max(memWidth, child.getSpaceManager().getSize().width);
    }
    // position label
    int currentY = shape.getLabelSize().height;
    currentY += shape.getLabelSize().height;
    // find current centerX
    int totalSpacingX = shape.getSpaceManager().getSize().width - memWidth;
    if (totalSpacingX < 0) {
        LayoutErrorLog.logErrorMessage("unable to fit children within container (width)");
    }
    int spacingX = totalSpacingX / 2;
    int extraSpacingX = totalSpacingX % 2;
    int currentX = spacingX + extraSpacingX;
    // position child compartments
    int totalSpacingY = (shape.getSpaceManager().getSize().height - currentY) - memHeight;
    if (totalSpacingY < 0) {
        LayoutErrorLog.logErrorMessage("unable to fit children within container (height)");
    }
    int spacingY = totalSpacingY / (shape.countChildren() + 1);
    int extraSpacingY = totalSpacingY % (shape.countChildren() + 1);
    int centerX = currentX + memWidth / 2;
    // position children (and label)
    int colY = currentY + extraSpacingY;
    for (Shape child : shape.getChildren()) {
        child.getSpaceManager().setRelPos(centerX - child.getSpaceManager().getSize().width / 2, colY);
        colY += child.getSpaceManager().getSize().height + spacingY;
    }
    currentX += spacingX;
    colY += spacingY;
    if (colY != shape.getSpaceManager().getSize().height) {
        throw new RuntimeException("layout for column incorrect (" + shape.getLabel() + "), currentY=" + currentY + ", screenSize.height=" + shape.getSpaceManager().getSize().height);
    }
    if (shape.countChildren() > 0) {
        currentX += memWidth;
    }
    if (currentX != shape.getSpaceManager().getSize().width) {
        throw new RuntimeException("layout for column widths incorrect (" + shape.getLabel() + "), currentX=" + currentX + ", screenSize.width=" + shape.getSpaceManager().getSize().width);
    }
}
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)

Aggregations

BioPaxShape (cbit.vcell.client.desktop.biomodel.pathway.shapes.BioPaxShape)2 ContainerContainerShape (cbit.vcell.graph.ContainerContainerShape)2 FeatureShape (cbit.vcell.graph.FeatureShape)2 GeometryClassLegendShape (cbit.vcell.graph.GeometryClassLegendShape)2 GeometryContextContainerShape (cbit.vcell.graph.GeometryContextContainerShape)2 GeometryContextGeometryShape (cbit.vcell.graph.GeometryContextGeometryShape)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 SubVolumeContainerShape (cbit.vcell.graph.SubVolumeContainerShape)2 Point (java.awt.Point)2 Dimension (java.awt.Dimension)1 FontMetrics (java.awt.FontMetrics)1