use of cbit.gui.graph.Shape 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.gui.graph.Shape in project vcell by virtualcell.
the class StructureMappingCartoonTool method selectEventFromWorld.
private void selectEventFromWorld(Point worldPoint) {
// Shape selectedShape = cartoon.getSelectedShape();
getStructureMappingCartoon().clearSelection();
Shape pickedShape = getStructureMappingCartoon().pickEdgeWorld(worldPoint);
if (pickedShape == null)
return;
// if (pickedShape!=selectedShape){
getStructureMappingCartoon().selectShape(pickedShape);
// }
}
use of cbit.gui.graph.Shape in project vcell by virtualcell.
the class ShapeGroupUtil method calculateGroupShapeAbsPos.
public static Point calculateGroupShapeAbsPos(Collection<Shape> memberShapes) {
int xSum = 0;
int ySum = 0;
int posCount = 0;
for (Shape memberShape : memberShapes) {
if (!willBeSkippedWhenGrouping(memberShape)) {
Point memberAbsPos = memberShape.getSpaceManager().getAbsLoc();
xSum += memberAbsPos.x;
ySum += memberAbsPos.y;
++posCount;
}
}
if (posCount == 0) {
posCount = 1;
}
return new Point(xSum / posCount, ySum / posCount);
}
use of cbit.gui.graph.Shape in project vcell by virtualcell.
the class ShapeGroupUtil method addEdgeBundleShapes.
public static void addEdgeBundleShapes(GraphModel graphModel, Shape groupShape, Shape groupParentShape) {
Map<Shape, Set<EdgeShape>> connections = ShapeUtil.getExternalConnections(graphModel, groupShape);
for (Map.Entry<Shape, Set<EdgeShape>> entry : connections.entrySet()) {
Shape externalShape = entry.getKey();
Set<EdgeShape> edgeShapes = entry.getValue();
EdgeBundleShape edgeBundleShape = new EdgeBundleShape(graphModel, groupShape, externalShape, "", edgeShapes);
groupParentShape.addChildShape(edgeBundleShape);
graphModel.addShape(edgeBundleShape);
}
}
use of cbit.gui.graph.Shape in project vcell by virtualcell.
the class ShapeGroupUtil method createGroup.
public static GroupShape createGroup(GraphModel graphModel, String groupName, Collection<Shape> memberShapes) throws Exception {
Set<Object> objects = new HashSet<Object>();
for (Shape memberShape : memberShapes) {
objects.add(memberShape.getModelObject());
}
VCNodeGroup group = new VCNodeGroup(groupName, objects);
GroupShape groupShape = new GroupShape(graphModel, group);
Point location = calculateGroupShapeAbsPos(memberShapes);
Shape groupParentShape = findGroupParentShape(memberShapes);
if (groupParentShape == null) {
groupParentShape = graphModel.getTopShape();
}
groupParentShape.addChildShape(groupShape);
groupShape.getSpaceManager().setAbsLoc(location);
moveMembersToGroup(groupShape, memberShapes);
addEdgeBundleShapes(graphModel, groupShape, groupParentShape);
graphModel.addShape(groupShape);
return groupShape;
}
Aggregations