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);
}
}
Aggregations