use of cbit.vcell.graph.ReactionContainerShape in project vcell by virtualcell.
the class ReactionCartoonTool method mouseMoved.
@Override
public void mouseMoved(MouseEvent event) {
if (getReactionCartoon() == null) {
return;
}
Point startPointWorld = getGraphModel().getResizeManager().unzoom(event.getPoint());
if (mode == Mode.STRUCTURE) {
RXContainerDropTargetInfo lastTrueRXContainerDropTargetInfo = getSelectedContainerDropTargetInfo();
lastRXContainerDropTargetInfoMap = updateRXContainerDropTargetInfoMap(startPointWorld);
RXContainerDropTargetInfo currentTrueRXContainerDropTargetInfo = getSelectedContainerDropTargetInfo();
if (!Compare.isEqualOrNull(lastTrueRXContainerDropTargetInfo, currentTrueRXContainerDropTargetInfo)) {
activateDropTargetEnable();
getGraphPane().repaint();
}
return;
}
Shape mouseShape = getReactionCartoon().pickWorld(startPointWorld);
if (mouseShape instanceof ReactionContainerShape) {
Rectangle labelOutlineRectangle = ((ReactionContainerShape) mouseShape).getLabelOutline(mouseShape.getAbsX(), mouseShape.getAbsY());
boolean bLabel = labelOutlineRectangle.contains(startPointWorld.x, startPointWorld.y);
if (bLabel) {
if (!getGraphPane().getCursor().equals(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR))) {
getGraphPane().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
} else {
if (!getGraphPane().getCursor().equals(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR))) {
getGraphPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
} else {
if (!getGraphPane().getCursor().equals(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR))) {
getGraphPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
}
use of cbit.vcell.graph.ReactionContainerShape in project vcell by virtualcell.
the class GraphContainerLayoutVCellClassical method getPreferedSizeContainerContainerShape.
public Dimension getPreferedSizeContainerContainerShape(ContainerContainerShape shape, Graphics2D g) throws GraphModel.NotReadyException {
// get size when empty
Dimension emptySize = shape.getPreferedSizeSelf(g);
// make larger than empty size so that children fit
for (Shape child : shape.getChildren()) {
if (child instanceof ReactionContainerShape) {
emptySize.width = Math.max(emptySize.width, child.getSpaceManager().getRelPos().x + getPreferedSize(child, g).width);
// emptySize.width += 8; // spaces between compartments
emptySize.height = Math.max(emptySize.height, child.getSpaceManager().getRelPos().y + getPreferedSize(child, g).height);
}
}
return emptySize;
}
use of cbit.vcell.graph.ReactionContainerShape in project vcell by virtualcell.
the class GraphContainerLayoutVCellClassical method refreshLayoutChildrenContainerContainerShape.
public void refreshLayoutChildrenContainerContainerShape(ContainerContainerShape shape) {
List<ReactionContainerShape> structureContainers = shape.getStructureContainers();
int currentX = 4;
int currentY = 0;
for (int i = 0; i < structureContainers.size(); i++) {
structureContainers.get(i).getSpaceManager().setRelPos(currentX, currentY);
currentX += structureContainers.get(i).getSpaceManager().getSize().width;
int padding = 8;
if (i < structureContainers.size() - 1) {
Structure structure1 = structureContainers.get(i).getStructure();
Structure structure2 = structureContainers.get(i + 1).getStructure();
if (StructureUtil.areAdjacent(structure1, structure2)) {
padding = 0;
}
}
currentX += padding;
}
}
use of cbit.vcell.graph.ReactionContainerShape in project vcell by virtualcell.
the class GraphContainerLayoutReactions method getPreferedSizeContainerContainerShape.
public Dimension getPreferedSizeContainerContainerShape(ContainerContainerShape shape, Graphics2D g) {
// get size when empty
Dimension emptySize = shape.getPreferedSizeSelf(g);
// make larger than empty size so that children fit
int widthSum = 0;
for (Shape child : shape.getChildren()) {
if (child instanceof ReactionContainerShape) {
Dimension preferedSizeChild = getPreferedSize(child, g);
emptySize.width = Math.max(emptySize.width, child.getSpaceManager().getRelPos().x + preferedSizeChild.width);
widthSum += preferedSizeChild.width;
// emptySize.width += 8; // spaces between compartments
emptySize.height = Math.max(emptySize.height, child.getSpaceManager().getRelPos().y + preferedSizeChild.height);
}
}
emptySize.width = Math.max(emptySize.width, widthSum);
return emptySize;
}
use of cbit.vcell.graph.ReactionContainerShape in project vcell by virtualcell.
the class GraphContainerLayoutReactions method getBoundaryForAutomaticLayout.
public Rectangle getBoundaryForAutomaticLayout(Shape shape) {
if (shape instanceof ReactionContainerShape) {
Point absLoc = shape.getAbsPos();
Dimension size = shape.getSize();
return new Rectangle(absLoc.x + WIDTH_PADDING, absLoc.y + HEIGHT_PADDING + TOP_LABEL_HEIGHT, size.width - 2 * WIDTH_PADDING, size.height - 2 * HEIGHT_PADDING - TOP_LABEL_HEIGHT);
}
return new Rectangle(shape.getAbsPos(), shape.getSize());
}
Aggregations