Search in sources :

Example 1 with RuleParticipantSignatureShortDiagramShape

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

the class GraphContainerLayoutReactions method getPreferedSizeReactionContainerShape.

public Dimension getPreferedSizeReactionContainerShape(ReactionContainerShape shape, Graphics2D g) {
    // get size when empty
    Font origFont = g.getFont();
    g.setFont(shape.getLabelFont(g));
    try {
        Dimension preferredSize = shape.getPreferedSizeSelf(g);
        // make larger than empty size so that children fit
        for (Shape child : shape.getChildren()) {
            if (child instanceof ReactionStepShape || child instanceof SpeciesContextShape || child instanceof RuleParticipantSignatureFullDiagramShape || child instanceof RuleParticipantSignatureShortDiagramShape || child instanceof ReactionRuleDiagramShape) {
                preferredSize.width = Math.max(preferredSize.width, child.getSpaceManager().getRelPos().x + child.getSpaceManager().getSize().width);
                preferredSize.height = Math.max(preferredSize.height, child.getSpaceManager().getRelPos().y + child.getSpaceManager().getSize().height);
            }
        }
        preferredSize.width = preferredSize.width + WIDTH_PADDING;
        preferredSize.height = preferredSize.height + HEIGHT_PADDING;
        Structure structure = shape.getStructure();
        int minWidthSum = 0;
        for (Structure structure2 : shape.getStructureSuite().getStructures()) {
            if (structure2 instanceof Feature) {
                minWidthSum += FEATURE_MIN_WIDTH;
            } else {
                minWidthSum += MEMBRANE_MIN_WIDTH;
            }
        }
        int compartmentMinWidth = 0;
        if (structure instanceof Feature) {
            compartmentMinWidth = FEATURE_MIN_WIDTH;
        } else {
            compartmentMinWidth = MEMBRANE_MIN_WIDTH;
        }
        int apportionedWidth = compartmentMinWidth * TOTAL_MIN_WIDTH / minWidthSum;
        if (preferredSize.width < compartmentMinWidth) {
            preferredSize.width = compartmentMinWidth;
        }
        if (preferredSize.width < apportionedWidth) {
            preferredSize.width = apportionedWidth;
        }
        if (preferredSize.height < MIN_HEIGHT) {
            preferredSize.height = MIN_HEIGHT;
        }
        return preferredSize;
    } finally {
        g.setFont(origFont);
    }
}
Also used : RuleParticipantSignatureShortDiagramShape(cbit.vcell.graph.RuleParticipantSignatureShortDiagramShape) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) RuleParticipantSignatureFullDiagramShape(cbit.vcell.graph.RuleParticipantSignatureFullDiagramShape) RuleParticipantSignatureShortDiagramShape(cbit.vcell.graph.RuleParticipantSignatureShortDiagramShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) ReactionRuleFullDiagramShape(cbit.vcell.graph.ReactionRuleFullDiagramShape) ContainerContainerShape(cbit.vcell.graph.ContainerContainerShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) RuleParticipantSignatureFullDiagramShape(cbit.vcell.graph.RuleParticipantSignatureFullDiagramShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) Dimension(java.awt.Dimension) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) Structure(cbit.vcell.model.Structure) Feature(cbit.vcell.model.Feature) Font(java.awt.Font) Point(java.awt.Point)

Aggregations

ContainerContainerShape (cbit.vcell.graph.ContainerContainerShape)1 ReactionContainerShape (cbit.vcell.graph.ReactionContainerShape)1 ReactionRuleDiagramShape (cbit.vcell.graph.ReactionRuleDiagramShape)1 ReactionRuleFullDiagramShape (cbit.vcell.graph.ReactionRuleFullDiagramShape)1 ReactionStepShape (cbit.vcell.graph.ReactionStepShape)1 RuleParticipantSignatureFullDiagramShape (cbit.vcell.graph.RuleParticipantSignatureFullDiagramShape)1 RuleParticipantSignatureShortDiagramShape (cbit.vcell.graph.RuleParticipantSignatureShortDiagramShape)1 SpeciesContextShape (cbit.vcell.graph.SpeciesContextShape)1 Feature (cbit.vcell.model.Feature)1 Structure (cbit.vcell.model.Structure)1 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 Point (java.awt.Point)1