Search in sources :

Example 21 with ReactionContainerShape

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

the class GraphContainerLayoutReactions method resizeContainerContainerShape.

public void resizeContainerContainerShape(ContainerContainerShape shape, Dimension newSize, Graphics2D g) {
    shape.getSpaceManager().setSize(newSize);
    int remainingWidth = shape.getSpaceManager().getSize().width;
    int[] widths = new int[shape.getStructureContainers().size()];
    for (int i = 0; i < shape.getStructureContainers().size(); i++) {
        widths[i] = getPreferedSize(shape.getStructureContainers().get(i), g).width;
        remainingWidth -= widths[i];
    // remainingWidth -= 8;// TODO make 8 (space between reaction slices) a field
    }
    for (int i = 0; i < widths.length; i++) {
        // redistribute evenly
        int extraWidth = remainingWidth / shape.getStructureContainers().size();
        if (i == 0) {
            // add extra width to first element.
            extraWidth += remainingWidth % shape.getStructureContainers().size();
        }
        ReactionContainerShape reactionContainerShape = shape.getStructureContainers().get(i);
        Dimension reactionContainerPreferedSize = getPreferedSize(reactionContainerShape, g);
        resize(reactionContainerShape, new Dimension(reactionContainerPreferedSize.width, shape.getSpaceManager().getSize().height), g);
    }
    refreshLayoutChildren(shape);
}
Also used : ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) Dimension(java.awt.Dimension) Point(java.awt.Point)

Aggregations

ReactionContainerShape (cbit.vcell.graph.ReactionContainerShape)21 Point (java.awt.Point)16 SpeciesContextShape (cbit.vcell.graph.SpeciesContextShape)13 ReactionStepShape (cbit.vcell.graph.ReactionStepShape)12 ContainerContainerShape (cbit.vcell.graph.ContainerContainerShape)11 ReactionRuleDiagramShape (cbit.vcell.graph.ReactionRuleDiagramShape)11 CatalystShape (cbit.vcell.graph.CatalystShape)9 RubberBandRectShape (cbit.gui.graph.RubberBandRectShape)8 Shape (cbit.gui.graph.Shape)8 FluxReactionShape (cbit.vcell.graph.FluxReactionShape)8 ProductShape (cbit.vcell.graph.ProductShape)8 ReactantShape (cbit.vcell.graph.ReactantShape)8 RuleParticipantSignatureDiagramShape (cbit.vcell.graph.RuleParticipantSignatureDiagramShape)8 SimpleReactionShape (cbit.vcell.graph.SimpleReactionShape)8 Structure (cbit.vcell.model.Structure)8 Dimension (java.awt.Dimension)8 ContainerShape (cbit.gui.graph.ContainerShape)7 ElipseShape (cbit.gui.graph.ElipseShape)7 RubberBandEdgeShape (cbit.gui.graph.RubberBandEdgeShape)7 ReactionParticipantShape (cbit.vcell.graph.ReactionParticipantShape)7