use of cbit.vcell.graph.MembraneShape in project vcell by virtualcell.
the class GraphContainerLayoutVCellClassical method refreshLayoutChildrenMembraneShape.
public void refreshLayoutChildrenMembraneShape(MembraneShape shape) {
// this is like a row/column layout (1 column)
// find featureShape child
FeatureShape featureShape = null;
for (Shape child : shape.getChildren()) {
if (child instanceof FeatureShape) {
featureShape = (FeatureShape) child;
}
}
// calculate total height of all children (not including label)
// position featureShape (and label)
int centerX = shape.getSpaceManager().getSize().width / 2;
int currentY = MembraneShape.memSpacingY;
if (featureShape != null) {
featureShape.getSpaceManager().setRelPos(centerX - featureShape.getSpaceManager().getSize().width / 2, currentY);
currentY += featureShape.getSpaceManager().getSize().height + MembraneShape.memSpacingY;
}
// position speciesContextShapes
// angle = 0 at north pole and increases counter clockwise
int numSpeciesContexts = shape.countChildren() - 1;
if (numSpeciesContexts > 0) {
double deltaAngle = MembraneShape.TotalAngle / (numSpeciesContexts + 1);
double currentAngle = MembraneShape.BeginAngle + deltaAngle;
for (Shape child : shape.getChildren()) {
if (child instanceof SpeciesContextShape) {
child.getSpaceManager().setRelPos(shape.getRadialPosition(currentAngle));
currentAngle = (currentAngle + deltaAngle) % (2 * Math.PI);
}
}
}
}
Aggregations