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