Search in sources :

Example 31 with Shape

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));
        }
    }
}
Also used : SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) RubberBandRectShape(cbit.gui.graph.RubberBandRectShape) ProductShape(cbit.vcell.graph.ProductShape) ContainerShape(cbit.gui.graph.ContainerShape) CatalystShape(cbit.vcell.graph.CatalystShape) FluxReactionShape(cbit.vcell.graph.FluxReactionShape) ContainerContainerShape(cbit.vcell.graph.ContainerContainerShape) ReactantShape(cbit.vcell.graph.ReactantShape) ElipseShape(cbit.gui.graph.ElipseShape) SimpleReactionShape(cbit.vcell.graph.SimpleReactionShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) Shape(cbit.gui.graph.Shape) RuleParticipantSignatureDiagramShape(cbit.vcell.graph.RuleParticipantSignatureDiagramShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) RubberBandEdgeShape(cbit.gui.graph.RubberBandEdgeShape) ReactionParticipantShape(cbit.vcell.graph.ReactionParticipantShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) Rectangle(java.awt.Rectangle) Point(java.awt.Point)

Example 32 with Shape

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);
// }
}
Also used : RubberBandEdgeShape(cbit.gui.graph.RubberBandEdgeShape) StructureMappingShape(cbit.vcell.graph.StructureMappingShape) StructureShape(cbit.vcell.graph.StructureShape) GeometryClassLegendShape(cbit.vcell.graph.GeometryClassLegendShape) Shape(cbit.gui.graph.Shape)

Example 33 with Shape

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);
}
Also used : EdgeShape(cbit.gui.graph.EdgeShape) Shape(cbit.gui.graph.Shape) Point(java.awt.Point) Point(java.awt.Point)

Example 34 with Shape

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);
    }
}
Also used : EdgeShape(cbit.gui.graph.EdgeShape) EdgeShape(cbit.gui.graph.EdgeShape) Shape(cbit.gui.graph.Shape) Set(java.util.Set) HashSet(java.util.HashSet) Map(java.util.Map)

Example 35 with Shape

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;
}
Also used : EdgeShape(cbit.gui.graph.EdgeShape) Shape(cbit.gui.graph.Shape) Point(java.awt.Point) HashSet(java.util.HashSet)

Aggregations

Shape (cbit.gui.graph.Shape)57 Point (java.awt.Point)30 ContainerShape (cbit.gui.graph.ContainerShape)21 EdgeShape (cbit.gui.graph.EdgeShape)20 RubberBandRectShape (cbit.gui.graph.RubberBandRectShape)20 ArrayList (java.util.ArrayList)15 ElipseShape (cbit.gui.graph.ElipseShape)14 RubberBandEdgeShape (cbit.gui.graph.RubberBandEdgeShape)14 ReactionContainerShape (cbit.vcell.graph.ReactionContainerShape)14 CatalystShape (cbit.vcell.graph.CatalystShape)13 ContainerContainerShape (cbit.vcell.graph.ContainerContainerShape)13 FluxReactionShape (cbit.vcell.graph.FluxReactionShape)13 ProductShape (cbit.vcell.graph.ProductShape)13 ReactantShape (cbit.vcell.graph.ReactantShape)13 ReactionParticipantShape (cbit.vcell.graph.ReactionParticipantShape)13 ReactionRuleDiagramShape (cbit.vcell.graph.ReactionRuleDiagramShape)13 ReactionStepShape (cbit.vcell.graph.ReactionStepShape)13 RuleParticipantSignatureDiagramShape (cbit.vcell.graph.RuleParticipantSignatureDiagramShape)13 SimpleReactionShape (cbit.vcell.graph.SimpleReactionShape)13 SpeciesContextShape (cbit.vcell.graph.SpeciesContextShape)13