Search in sources :

Example 1 with AllStructureSuite

use of cbit.vcell.graph.structures.AllStructureSuite in project vcell by virtualcell.

the class ReactionCartoonTool method mouseReleased.

@Override
public void mouseReleased(MouseEvent event) {
    if (getReactionCartoon() == null) {
        return;
    }
    try {
        if (dragStructTimer != null) {
            dragStructTimer.stop();
        }
        endPointWorld = getReactionCartoon().getResizeManager().unzoom(event.getPoint());
        Shape endShape = getReactionCartoon().pickWorld(endPointWorld);
        if (event.isPopupTrigger() && mode == Mode.SELECT) {
            // win, linux popup
            popupMenu(getReactionCartoon().getSelectedShape(), event.getX(), event.getY());
            return;
        }
        if (mode == Mode.SELECT && bStartRxContainerLabel) {
            resetDropTargets(null, mode == Mode.STRUCTURE);
            if (endShape != null && endShape instanceof ReactionContainerShape) {
                Rectangle labelOutlineRectangle = ((ReactionContainerShape) endShape).getLabelOutline(endShape.getAbsX(), endShape.getAbsY());
                boolean bLabel = labelOutlineRectangle.contains(startPointWorld.x, startPointWorld.y);
                getGraphPane().setCursor((bLabel ? Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) : Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)));
            }
            bStartRxContainerLabel = false;
            RXContainerDropTargetInfo trueRXContainerDropTargetInfo = getSelectedContainerDropTargetInfo();
            lastRXContainerDropTargetInfoMap = null;
            if (trueRXContainerDropTargetInfo == null) {
                // turn off rxDropTargetRectangles
                getGraphPane().repaint();
                return;
            }
            StructureSuite structureSuite = null;
            structureSuite = getReactionCartoon().getStructureSuite();
            if (structureSuite != null) {
                Structure[] originalOrderedStructArr = structureSuite.getStructures().toArray(new Structure[0]);
                // find where user wants to put the structure
                try {
                    if (trueRXContainerDropTargetInfo != null) {
                        ArrayList<Structure> newStructOrderList = new ArrayList<Structure>(Arrays.asList(originalOrderedStructArr));
                        newStructOrderList.remove(((ReactionContainerShape) startShape).getStructure());
                        int indexEnd = newStructOrderList.indexOf(((ReactionContainerShape) trueRXContainerDropTargetInfo.dropShape).getStructure());
                        int indexClosestNeighbor = (trueRXContainerDropTargetInfo.closestNeighborShape == null ? (trueRXContainerDropTargetInfo.insertFlag == RXContainerDropTargetInfo.INSERT_BEGINNING ? 0 : newStructOrderList.size()) : newStructOrderList.indexOf(((ReactionContainerShape) trueRXContainerDropTargetInfo.closestNeighborShape).getStructure()));
                        if (indexClosestNeighbor < indexEnd) {
                            newStructOrderList.add(indexEnd, ((ReactionContainerShape) startShape).getStructure());
                        } else {
                            newStructOrderList.add(indexClosestNeighbor, ((ReactionContainerShape) startShape).getStructure());
                        }
                        if (structureSuite instanceof AllStructureSuite) {
                            ((AllStructureSuite) structureSuite).setModelStructureOrder(true);
                        }
                        ArrayList<Diagram> newDiagramOrderList = new ArrayList<Diagram>();
                        for (Structure structure : newStructOrderList) {
                            newDiagramOrderList.add(getModel().getDiagram(structure));
                        }
                        getModel().setDiagrams(newDiagramOrderList.toArray(new Diagram[0]));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return;
        }
        // else do select and move
        switch(mode) {
            case SELECT:
                {
                    getGraphPane().setCursor(Cursor.getDefaultCursor());
                    if (bMoving) {
                        getGraphPane().invalidate();
                        ((JViewport) getGraphPane().getParent()).revalidate();
                        getGraphPane().repaint();
                        saveDiagram();
                    } else if (bRectStretch) {
                        Point absLoc = rectShape.getSpaceManager().getRelPos();
                        Dimension size = rectShape.getSpaceManager().getSize();
                        // remove temporary rectangle
                        getReactionCartoon().removeShape(rectShape);
                        rectShape = null;
                        Rectangle rect = new Rectangle(absLoc.x, absLoc.y, size.width, size.height);
                        boolean bShift = (event.getModifiers() & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK;
                        boolean bCntrl = (event.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK;
                        selectEventFromWorld(rect, bShift, bCntrl);
                        getGraphPane().repaint();
                    }
                    bMoving = false;
                    movingShape = null;
                    bRectStretch = false;
                    rectShape = null;
                    break;
                }
            case LINEDIRECTED:
                {
                    getGraphPane().setCursor(Cursor.getDefaultCursor());
                    if (bLineStretch && getDragDistanceSquared() >= MIN_DRAG_DISTANCE_TO_CREATE_NEW_ELEMENTS_SQUARED) {
                        bLineStretch = false;
                        // set label and color for line depending on which shape the edge started.
                        // (rather than attachment area on ReactionStepShape)
                        LineType lineType = getLineTypeFromDirection(startShape, endPointWorld);
                        if (endShape instanceof SimpleReactionShape) {
                            SimpleReaction simpleReaction = (SimpleReaction) endShape.getModelObject();
                            Object startShapeObject = null;
                            if (startShape != null) {
                                startShapeObject = startShape.getModelObject();
                            }
                            if (startShapeObject instanceof SpeciesContext) {
                                SpeciesContext speciesContext = (SpeciesContext) startShapeObject;
                                lineAction(speciesContext, simpleReaction);
                            } else if (startShapeObject instanceof Structure) {
                                Structure structure = (Structure) startShapeObject;
                                lineActon(structure, simpleReaction);
                            }
                        } else if (endShape instanceof SpeciesContextShape) {
                            SpeciesContext speciesContextEnd = (SpeciesContext) endShape.getModelObject();
                            Object startShapeObject = null;
                            if (startShape != null) {
                                startShapeObject = startShape.getModelObject();
                            }
                            if (startShapeObject instanceof SimpleReaction) {
                                SimpleReaction simpleReaction = (SimpleReaction) startShapeObject;
                                lineAction(simpleReaction, speciesContextEnd);
                            } else if (startShapeObject instanceof FluxReaction) {
                                FluxReaction fluxReaction = (FluxReaction) startShapeObject;
                                lineAction(fluxReaction, speciesContextEnd);
                            } else if (startShapeObject instanceof SpeciesContext) {
                                SpeciesContext speciesContextStart = (SpeciesContext) startShapeObject;
                                if (!speciesContextStart.equals(speciesContextEnd)) {
                                    lineAction(speciesContextStart, speciesContextEnd);
                                }
                            } else if (startShapeObject instanceof Structure) {
                                Structure startStructure = (Structure) startShapeObject;
                                lineAction(startStructure, speciesContextEnd);
                            }
                        } else if (endShape instanceof FluxReactionShape) {
                            FluxReaction fluxReaction = (FluxReaction) endShape.getModelObject();
                            fluxReaction.setModel(getModel());
                            Object startShapeObject = null;
                            if (startShape != null) {
                                startShapeObject = startShape.getModelObject();
                            }
                            if (startShapeObject instanceof SpeciesContext) {
                                SpeciesContext speciesContext = (SpeciesContext) startShapeObject;
                                lineAction(speciesContext, fluxReaction);
                            } else if (startShapeObject instanceof Structure) {
                                Structure structure = (Structure) startShapeObject;
                                lineActon(structure, fluxReaction);
                            }
                            // remove temporary edge
                            getReactionCartoon().removeShape(edgeShape);
                            edgeShape = null;
                        } else if (endShape instanceof ReactionContainerShape) {
                            Structure endStructure = (Structure) endShape.getModelObject();
                            Object startObject = null;
                            if (startShape != null) {
                                startObject = startShape.getModelObject();
                            }
                            if (startObject instanceof SimpleReaction) {
                                SimpleReaction reaction = (SimpleReaction) startObject;
                                lineAction(reaction, endStructure);
                            } else if (startObject instanceof FluxReaction) {
                                FluxReaction reaction = (FluxReaction) startObject;
                                lineAction(reaction, endStructure);
                            } else if (startObject instanceof SpeciesContext) {
                                SpeciesContext speciesContextStart = (SpeciesContext) startObject;
                                lineAction(speciesContextStart, endStructure);
                            } else if (startObject instanceof Structure) {
                                Structure startStructure = (Structure) startObject;
                                lineAction(startStructure, endStructure, endShape);
                            }
                        }
                    }
                    saveDiagram();
                    break;
                }
            case LINECATALYST:
                {
                    getGraphPane().setCursor(Cursor.getDefaultCursor());
                    if (bLineStretch && getDragDistanceSquared() >= MIN_DRAG_DISTANCE_TO_CREATE_NEW_ELEMENTS_SQUARED) {
                        bLineStretch = false;
                        // set label and color for line depending on which shape the edge started.
                        // (rather than attachment area on ReactionStepShape)
                        Object startObject = startShape.getModelObject();
                        Object endObject = endShape.getModelObject();
                        ReactionStep reactionStep = null;
                        SpeciesContext speciesContext = null;
                        if (startObject instanceof ReactionStep) {
                            reactionStep = (ReactionStep) startObject;
                            if (endObject instanceof SpeciesContext) {
                                if (StructureUtil.reactionHereCanHaveParticipantThere(reactionStep.getStructure(), ((SpeciesContext) endObject).getStructure())) {
                                    speciesContext = (SpeciesContext) endObject;
                                }
                            } else if (endObject instanceof Structure) {
                                Structure endStructure = (Structure) endObject;
                                if (StructureUtil.reactionHereCanHaveParticipantThere(reactionStep.getStructure(), endStructure)) {
                                    speciesContext = getReactionCartoon().getModel().createSpeciesContext(endStructure);
                                    getReactionCartoon().notifyChangeEvent();
                                    Point endPos = edgeShape.getEnd();
                                    positionShapeForObject(endStructure, speciesContext, endPos);
                                }
                            }
                        } else if (startObject instanceof SpeciesContext) {
                            speciesContext = (SpeciesContext) startObject;
                            if (endObject instanceof ReactionStep) {
                                if (StructureUtil.reactionHereCanHaveParticipantThere(((ReactionStep) endObject).getStructure(), speciesContext.getStructure())) {
                                    reactionStep = (ReactionStep) endObject;
                                }
                            } else if (endObject instanceof Structure) {
                                Structure endStructure = (Structure) endObject;
                                if (StructureUtil.reactionHereCanHaveParticipantThere(endStructure, speciesContext.getStructure())) {
                                    reactionStep = getReactionCartoon().getModel().createSimpleReaction(endStructure);
                                    getReactionCartoon().notifyChangeEvent();
                                    Point endPos = edgeShape.getEnd();
                                    positionShapeForObject(endStructure, reactionStep, endPos);
                                }
                            }
                        } else if (startObject instanceof Structure) {
                            Structure startStructure = (Structure) startObject;
                            if (endObject instanceof ReactionStep) {
                                reactionStep = (ReactionStep) endObject;
                                if (StructureUtil.reactionHereCanHaveParticipantThere(reactionStep.getStructure(), startStructure)) {
                                    speciesContext = getReactionCartoon().getModel().createSpeciesContext(startStructure);
                                    getReactionCartoon().notifyChangeEvent();
                                    positionShapeForObject(startStructure, speciesContext, startPointWorld);
                                }
                            } else if (endObject instanceof SpeciesContext) {
                                speciesContext = (SpeciesContext) endObject;
                                if (StructureUtil.reactionHereCanHaveParticipantThere(startStructure, speciesContext.getStructure())) {
                                    reactionStep = getReactionCartoon().getModel().createSimpleReaction(startStructure);
                                    getReactionCartoon().notifyChangeEvent();
                                    positionShapeForObject(startStructure, reactionStep, startPointWorld);
                                }
                            } else if (endObject instanceof Structure) {
                                Structure endStructure = (Structure) endObject;
                                if (StructureUtil.reactionHereCanHaveParticipantThere(startStructure, endStructure)) {
                                    speciesContext = getReactionCartoon().getModel().createSpeciesContext(endStructure);
                                    reactionStep = getReactionCartoon().getModel().createSimpleReaction(startStructure);
                                    getReactionCartoon().notifyChangeEvent();
                                    Point endPos = edgeShape.getEnd();
                                    positionShapeForObject(endStructure, speciesContext, endPos);
                                    positionShapeForObject(startStructure, reactionStep, startPointWorld);
                                } else if (StructureUtil.reactionHereCanHaveParticipantThere(endStructure, startStructure)) {
                                    speciesContext = getReactionCartoon().getModel().createSpeciesContext(startStructure);
                                    reactionStep = getReactionCartoon().getModel().createSimpleReaction(endStructure);
                                    getReactionCartoon().notifyChangeEvent();
                                    positionShapeForObject(startStructure, speciesContext, startPointWorld);
                                    Point endPos = edgeShape.getEnd();
                                    positionShapeForObject(endStructure, reactionStep, endPos);
                                }
                            }
                        }
                        if (reactionStep != null && speciesContext != null) {
                            Catalyst catalyst = null;
                            for (ReactionParticipant participant : reactionStep.getReactionParticipants()) {
                                if (participant instanceof Catalyst && participant.getSpeciesContext().equals(speciesContext)) {
                                    catalyst = (Catalyst) participant;
                                }
                            }
                            if (catalyst == null) {
                                reactionStep.addCatalyst(speciesContext);
                                getReactionCartoon().notifyChangeEvent();
                            }
                        // add reactionParticipant to model
                        } else {
                            getGraphPane().repaint();
                        }
                    }
                    saveDiagram();
                    break;
                }
            default:
                {
                    break;
                }
        }
    } catch (Exception e) {
        System.out.println("CartoonTool.mouseReleased: uncaught exception");
        e.printStackTrace(System.out);
    }
    resetMouseActionHistory();
    getGraphPane().repaint();
}
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) AllStructureSuite(cbit.vcell.graph.structures.AllStructureSuite) StructureSuite(cbit.vcell.graph.structures.StructureSuite) Rectangle(java.awt.Rectangle) ArrayList(java.util.ArrayList) SimpleReactionShape(cbit.vcell.graph.SimpleReactionShape) FluxReaction(cbit.vcell.model.FluxReaction) SpeciesContext(cbit.vcell.model.SpeciesContext) Structure(cbit.vcell.model.Structure) SimpleReaction(cbit.vcell.model.SimpleReaction) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) Point(java.awt.Point) Dimension(java.awt.Dimension) Point(java.awt.Point) PropertyVetoException(java.beans.PropertyVetoException) UtilCancelException(org.vcell.util.UtilCancelException) ExpressionException(cbit.vcell.parser.ExpressionException) UserCancelException(org.vcell.util.UserCancelException) Diagram(cbit.vcell.model.Diagram) FluxReactionShape(cbit.vcell.graph.FluxReactionShape) ReactionStep(cbit.vcell.model.ReactionStep) AllStructureSuite(cbit.vcell.graph.structures.AllStructureSuite) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Catalyst(cbit.vcell.model.Catalyst)

Example 2 with AllStructureSuite

use of cbit.vcell.graph.structures.AllStructureSuite in project vcell by virtualcell.

the class ReactionCartoonTool method layout.

public void layout(String layoutName, boolean bWarn) throws Exception {
    System.out.println(layoutName);
    // -----Turn off user forced reaction diagram structure order
    if (getReactionCartoon().getStructureSuite() instanceof AllStructureSuite) {
        AllStructureSuite allStructureSuite = ((AllStructureSuite) getReactionCartoon().getStructureSuite());
        if (allStructureSuite.getModelStructureOrder()) {
            // make auto-sort
            allStructureSuite.setModelStructureOrder(false);
            // get auto-sorted structures
            List<Structure> autoSortedStructures = allStructureSuite.getStructures();
            ArrayList<Diagram> newDiagramOrderList = new ArrayList<Diagram>();
            for (Structure structure : autoSortedStructures) {
                newDiagramOrderList.add(getModel().getDiagram(structure));
            }
            Diagram[] autosortDiagramOrder = newDiagramOrderList.toArray(new Diagram[0]);
            if (bWarn && autoSortedStructures.size() > 1) {
                // no point in warning if there's just one structure
                final String OK = "OK";
                String response = DialogUtils.showWarningDialog(getGraphPane(), "Re-organizing species/reaction display positions...", new String[] { OK, "Cancel" }, OK);
                if (response != null && response.equals(OK)) {
                    // getModel().setDiagrams(autosortDiagramOrder);
                    allStructureSuite.setModelStructureOrder(true);
                } else {
                    allStructureSuite.setModelStructureOrder(true);
                    return;
                }
            } else {
                getModel().setDiagrams(autosortDiagramOrder);
            }
        }
    }
    // -----
    GraphLayoutTasks.dispatchTasks(getGraphPane(), graphEmbeddingManager, this, layoutName);
}
Also used : ArrayList(java.util.ArrayList) AllStructureSuite(cbit.vcell.graph.structures.AllStructureSuite) Structure(cbit.vcell.model.Structure) Diagram(cbit.vcell.model.Diagram)

Example 3 with AllStructureSuite

use of cbit.vcell.graph.structures.AllStructureSuite in project vcell by virtualcell.

the class ITextWriter method generateDocReactionsImage.

public static BufferedImage generateDocReactionsImage(Model model, Integer width) throws Exception {
    // if (model == null || !isValidResolutionSetting(resolution)) {
    // throw new IllegalArgumentException("Invalid parameters for generating reactions image for  model: " + model.getName());
    // }
    ReactionCartoon rcartoon = new ReactionCartoonFull();
    rcartoon.setModel(model);
    StructureSuite structureSuite = new AllStructureSuite(new Model.Owner() {

        @Override
        public Model getModel() {
            return model;
        }
    });
    rcartoon.setStructureSuite(structureSuite);
    rcartoon.refreshAll();
    // dummy settings to get the real dimensions.
    BufferedImage dummyBufferedImage = new BufferedImage(DEF_IMAGE_WIDTH, DEF_IMAGE_HEIGHT, BufferedImage.TYPE_3BYTE_BGR);
    Graphics2D dummyGraphics = (Graphics2D) dummyBufferedImage.getGraphics();
    Dimension prefDim = rcartoon.getPreferedCanvasSize(dummyGraphics);
    dummyGraphics.dispose();
    // double width = prefDim.getWidth();
    // double height = prefDim.getHeight();
    double widthHeightRatio = (double) prefDim.getWidth() / (double) prefDim.getHeight();
    if (width == null) {
        width = ITextWriter.DEF_IMAGE_WIDTH;
    }
    int height = (int) ((double) width / widthHeightRatio);
    // int MAX_IMAGE_HEIGHT = 532;
    // if (width < ITextWriter.DEF_IMAGE_WIDTH) {
    // width = ITextWriter.DEF_IMAGE_WIDTH;
    // }
    // height= height * width/prefDim.getWidth();
    // if (height < ITextWriter.DEF_IMAGE_HEIGHT) {
    // height = ITextWriter.DEF_IMAGE_HEIGHT;
    // } else if (height > MAX_IMAGE_HEIGHT) {
    // height = MAX_IMAGE_HEIGHT;
    // }
    // width= width * height/prefDim.getHeight();
    Dimension newDim = new Dimension((int) width, (int) height);
    rcartoon.getResizeManager().setZoomPercent((int) (100 * width / prefDim.getWidth()));
    BufferedImage bufferedImage = new BufferedImage(newDim.width, newDim.height, BufferedImage.TYPE_3BYTE_BGR);
    Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    GraphContainerLayoutReactions containerLayout = new GraphContainerLayoutReactions();
    containerLayout.layout(rcartoon, g, prefDim);
    rcartoon.paint(g);
    g.dispose();
    return bufferedImage;
}
Also used : AllStructureSuite(cbit.vcell.graph.structures.AllStructureSuite) StructureSuite(cbit.vcell.graph.structures.StructureSuite) Dimension(java.awt.Dimension) GraphContainerLayoutReactions(cbit.gui.graph.GraphContainerLayoutReactions) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) ReactionCartoon(cbit.vcell.graph.ReactionCartoon) MathModel(cbit.vcell.mathmodel.MathModel) IndexColorModel(java.awt.image.IndexColorModel) Model(cbit.vcell.model.Model) BioModel(cbit.vcell.biomodel.BioModel) ReactionCartoonFull(cbit.vcell.graph.ReactionCartoonFull) AllStructureSuite(cbit.vcell.graph.structures.AllStructureSuite)

Example 4 with AllStructureSuite

use of cbit.vcell.graph.structures.AllStructureSuite in project vcell by virtualcell.

the class BioModelEditorModelPanel method bioModelChange.

private void bioModelChange() {
    if (bioModel == null) {
        return;
    }
    reactionCartoonEditorPanel.setModel(bioModel.getModel());
    reactionCartoonEditorPanel.setStructureSuite(new AllStructureSuite(this));
    bioModel.getRelationshipModel().removeRelationShipListener(reactionCartoonEditorPanel.getReactionCartoonFull());
    bioModel.getRelationshipModel().removeRelationShipListener(reactionCartoonEditorPanel.getReactionCartoonMolecule());
    bioModel.getRelationshipModel().removeRelationShipListener(reactionCartoonEditorPanel.getReactionCartoonRule());
    bioModel.getRelationshipModel().addRelationShipListener(reactionCartoonEditorPanel.getReactionCartoonFull());
    bioModel.getRelationshipModel().addRelationShipListener(reactionCartoonEditorPanel.getReactionCartoonMolecule());
    bioModel.getRelationshipModel().addRelationShipListener(reactionCartoonEditorPanel.getReactionCartoonRule());
    reactionCartoonEditorPanel.getReactionCartoonFull().refreshRelationshipInfo(bioModel.getRelationshipModel());
    reactionCartoonEditorPanel.getReactionCartoonMolecule().refreshRelationshipInfo(bioModel.getRelationshipModel());
    reactionCartoonEditorPanel.getReactionCartoonRule().refreshRelationshipInfo(bioModel.getRelationshipModel());
    // cartoonEditorPanel.setBioModel(bioModel);
    reactionTableModel.setBioModel(bioModel);
    structureTableModel.setBioModel(bioModel);
    speciesTableModel.setBioModel(bioModel);
    molecularTypeTableModel.setBioModel(bioModel);
    observableTableModel.setBioModel(bioModel);
// reactionCartoonEditorPanel.specialLayout();
}
Also used : AllStructureSuite(cbit.vcell.graph.structures.AllStructureSuite)

Example 5 with AllStructureSuite

use of cbit.vcell.graph.structures.AllStructureSuite in project vcell by virtualcell.

the class ReactionCartoonTool method updateRXContainerDropTargetInfoMap.

private HashMap<RXContainerDropTargetInfo, Boolean> updateRXContainerDropTargetInfoMap(Point pointWorld) {
    HashMap<RXContainerDropTargetInfo, Boolean> rxContainerDropTargetInfoMap = null;
    if (rxContainerDropTargetInfoMap == null) {
        // System.out.println("-----redoing map...");
        AllStructureSuite allStructureSuite = (getReactionCartoon().getStructureSuite() instanceof AllStructureSuite ? (AllStructureSuite) getReactionCartoon().getStructureSuite() : null);
        if (allStructureSuite == null) {
            throw new RuntimeException("Expecting " + AllStructureSuite.class.getName());
        }
        rxContainerDropTargetInfoMap = new HashMap<ReactionCartoonTool.RXContainerDropTargetInfo, Boolean>();
        Structure[] originalOrderedStructArr = allStructureSuite.getStructures().toArray(new Structure[0]);
        for (int i = 0; i < originalOrderedStructArr.length; i++) {
            Shape currentRXContainerShape = getReactionCartoon().getShapeFromModelObject(originalOrderedStructArr[i]);
            if (i == 0) {
                rxContainerDropTargetInfoMap.put(new RXContainerDropTargetInfo((ReactionContainerShape) currentRXContainerShape, null, RXContainerDropTargetInfo.INSERT_BEGINNING), false);
            } else {
                rxContainerDropTargetInfoMap.put(new RXContainerDropTargetInfo((ReactionContainerShape) currentRXContainerShape, (ReactionContainerShape) getReactionCartoon().getShapeFromModelObject(originalOrderedStructArr[i - 1]), null), false);
            }
            if (i == (originalOrderedStructArr.length - 1)) {
                rxContainerDropTargetInfoMap.put(new RXContainerDropTargetInfo((ReactionContainerShape) currentRXContainerShape, null, RXContainerDropTargetInfo.INSERT_END), false);
            }
        }
    }
    // System.out.println("-----Starting to update selection..."+pointWorld);
    for (RXContainerDropTargetInfo rxcContainerDropTargetInfo : rxContainerDropTargetInfoMap.keySet()) {
        if (rxcContainerDropTargetInfo.absoluteRectangle.contains(pointWorld)) {
            // System.out.println(rxcContainerDropTargetInfo.dropShape.getLabel()+" "+rxcContainerDropTargetInfo.closestNeighborShape);
            rxContainerDropTargetInfoMap.put(rxcContainerDropTargetInfo, true);
        } else {
            rxContainerDropTargetInfoMap.put(rxcContainerDropTargetInfo, false);
        }
    }
    return rxContainerDropTargetInfoMap;
}
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) AllStructureSuite(cbit.vcell.graph.structures.AllStructureSuite) Structure(cbit.vcell.model.Structure) Point(java.awt.Point)

Aggregations

AllStructureSuite (cbit.vcell.graph.structures.AllStructureSuite)6 Structure (cbit.vcell.model.Structure)4 Diagram (cbit.vcell.model.Diagram)3 Point (java.awt.Point)3 ArrayList (java.util.ArrayList)3 ContainerShape (cbit.gui.graph.ContainerShape)2 ElipseShape (cbit.gui.graph.ElipseShape)2 RubberBandEdgeShape (cbit.gui.graph.RubberBandEdgeShape)2 RubberBandRectShape (cbit.gui.graph.RubberBandRectShape)2 Shape (cbit.gui.graph.Shape)2 CatalystShape (cbit.vcell.graph.CatalystShape)2 ContainerContainerShape (cbit.vcell.graph.ContainerContainerShape)2 FluxReactionShape (cbit.vcell.graph.FluxReactionShape)2 ProductShape (cbit.vcell.graph.ProductShape)2 ReactantShape (cbit.vcell.graph.ReactantShape)2 ReactionContainerShape (cbit.vcell.graph.ReactionContainerShape)2 ReactionParticipantShape (cbit.vcell.graph.ReactionParticipantShape)2 ReactionRuleDiagramShape (cbit.vcell.graph.ReactionRuleDiagramShape)2 ReactionStepShape (cbit.vcell.graph.ReactionStepShape)2 RuleParticipantSignatureDiagramShape (cbit.vcell.graph.RuleParticipantSignatureDiagramShape)2