Search in sources :

Example 1 with ProductShape

use of cbit.vcell.graph.ProductShape in project vcell by virtualcell.

the class ReactionCartoonTool method menuAction.

@Override
protected void menuAction(Shape shape, String menuAction) {
    if (shape == null) {
        return;
    }
    if (menuAction.equals(CartoonToolMiscActions.Properties.MENU_ACTION)) {
        if (shape instanceof FluxReactionShape) {
        // showFluxReactionPropertiesDialog((FluxReactionShape) shape);
        } else if (shape instanceof SimpleReactionShape) {
        // showSimpleReactionPropertiesDialog((SimpleReactionShape) shape);
        } else if (shape instanceof ReactantShape) {
        // Point locationOnScreen = shape.getSpaceManager().getAbsLoc();
        // Point graphPaneLocation = getGraphPane().getLocationOnScreen();
        // locationOnScreen.translate(graphPaneLocation.x,
        // graphPaneLocation.y);
        // showReactantPropertiesDialog((ReactantShape) shape,
        // locationOnScreen);
        } else if (shape instanceof ProductShape) {
        // Point locationOnScreen = shape.getSpaceManager().getAbsLoc();
        // Point graphPaneLocation = getGraphPane().getLocationOnScreen();
        // locationOnScreen.translate(graphPaneLocation.x,
        // graphPaneLocation.y);
        // showProductPropertiesDialog((ProductShape) shape,
        // locationOnScreen);
        } else if (shape instanceof SpeciesContextShape) {
        // showEditSpeciesDialog(getGraphPane(), getReactionCartoon()
        // .getModel(), ((SpeciesContextShape) shape)
        // .getSpeciesContext());
        } else if (shape instanceof ReactionContainerShape) {
        // ReactionContainerShape rcs = (ReactionContainerShape) shape;
        // if (rcs.getStructure() instanceof Feature) {
        // //
        // // showFeaturePropertyDialog is invoked in two modes:
        // //
        // // 1) parent!=null and child==null
        // // upon ok, it adds a new feature to the supplied parent.
        // //
        // // 2) parent==null and child!=null
        // // upon ok, edits the feature name
        // //
        // showFeaturePropertiesDialog(getGraphPane(),
        // (getReactionCartoon().getModel() == null ? null
        // : getReactionCartoon().getModel()), null,
        // (Feature) rcs.getStructure());
        // } else if (rcs.getStructure() instanceof Membrane) {
        // showMembranePropertiesDialog(getGraphPane(), (Membrane) rcs
        // .getStructure());
        // }
        }
    } else if (menuAction.equals(CartoonToolMiscActions.AddSpecies.MENU_ACTION)) {
        if (shape instanceof ReactionContainerShape) {
            getGraphModel().deselectShape(shape);
            // showCreateSpeciesContextDialog(getGraphPane(),
            // getReactionCartoon().getModel(),
            // ((ReactionContainerShape) shape).getStructure(), null);
            SpeciesContext speciesContext = getReactionCartoon().getModel().createSpeciesContext(((ReactionContainerShape) shape).getStructure());
            getGraphModel().select(speciesContext);
        }
    } else if (menuAction.equals(CartoonToolEditActions.Copy.MENU_ACTION)) {
        if (shape instanceof SpeciesContextShape || shape instanceof ReactionStepShape || // rule participants whose rule is not selected won't
        shape instanceof RuleParticipantSignatureDiagramShape || // be copied since standalone they are meaningless
        shape instanceof ReactionRuleDiagramShape) {
            SpeciesContext[] spArray = getSelectedSpeciesContextArray();
            ReactionStep[] rsArray = getSelectedReactionStepArray();
            ReactionRule[] rrArray = getSelectedReactionRuleArray();
            MolecularType[] mtArray = getSelectedMolecularTypeArray(rrArray, rsArray, spArray);
            Structure[] structArray = getSelectedStructuresArray(rrArray, rsArray, spArray, mtArray);
            Structure fromStruct = null;
            ReactionContainerShape rcs = null;
            Shape parentShape = shape.getParent();
            if (parentShape instanceof ReactionContainerShape) {
                rcs = (ReactionContainerShape) parentShape;
                fromStruct = rcs.getStructure();
            }
            ReactionSpeciesCopy reactionSpeciesCopy = new ReactionSpeciesCopy(spArray, rsArray, rrArray, mtArray, fromStruct, structArray);
            VCellTransferable.sendToClipboard(reactionSpeciesCopy);
        }
    } else if (/*menuAction.equals(CartoonToolEditActions.Paste.MENU_ACTION)
				|| */
    menuAction.equals(CartoonToolEditActions.PasteNew.MENU_ACTION)) {
        if (shape instanceof ReactionContainerShape) {
            pasteReactionsAndSpecies(((ReactionContainerShape) shape).getStructure());
        }
    } else if (menuAction.equals(CartoonToolEditActions.Delete.MENU_ACTION)) {
        try {
            if (getGraphModel().getSelectedShape() instanceof ReactionContainerShape && menuAction.equals(CartoonToolEditActions.Delete.MENU_ACTION)) {
                getModel().removeStructure(((ReactionContainerShape) getGraphModel().getSelectedShape()).getStructure());
                return;
            }
            if (getSelectedReactionStepArray() != null || getSelectedSpeciesContextArray() != null) {
                deleteReactionsAndSpecies(getGraphPane(), getSelectedReactionStepArray(), getSelectedSpeciesContextArray());
            }
            if (getSelectedReactionParticipantArray() != null && menuAction.equals(CartoonToolEditActions.Delete.MENU_ACTION)) {
                ReactionParticipant[] reactionParticipantArr = getSelectedReactionParticipantArray();
                String response = DialogUtils.showWarningDialog(getGraphPane(), "Delete " + reactionParticipantArr.length + " Reaction Stoichiometries", new String[] { RXSPECIES_DELETE, RXSPECIES_CANCEL }, RXSPECIES_CANCEL);
                if (response != null && response.equals(RXSPECIES_DELETE)) {
                    for (int i = 0; i < reactionParticipantArr.length; i++) {
                        ReactionStep reactionStep = reactionParticipantArr[i].getReactionStep();
                        reactionStep.removeReactionParticipant(reactionParticipantArr[i]);
                    }
                }
            }
        } catch (UserCancelException uce) {
            return;
        } catch (PropertyVetoException e) {
            DialogUtils.showErrorDialog(getGraphPane(), e.getMessage());
        } catch (Exception e) {
            DialogUtils.showErrorDialog(getGraphPane(), e.getMessage(), e);
        }
    } else if (menuAction.equals(CartoonToolMiscActions.SearchReactions.MENU_ACTION)) {
        try {
            if (shape instanceof ReactionContainerShape) {
                showReactionBrowserDialog(((ReactionContainerShape) shape).getStructure(), null);
            }
        } catch (Exception e) {
            DialogUtils.showErrorDialog(getGraphPane(), e.getMessage(), e);
        }
    } else if (menuAction.equals(CartoonToolSaveAsImageActions.MenuAction.MENU_ACTION)) {
        try {
            String resType = null;
            if (shape instanceof ReactionContainerShape) {
                showSaveReactionImageDialog();
            }
        } catch (Exception e) {
            e.printStackTrace();
            DialogUtils.showErrorDialog(getGraphPane(), e.getMessage(), e);
        }
    } else if (menuAction.equals(CartoonToolMiscActions.Annotate.MENU_ACTION)) {
        if (shape instanceof ReactionStepShape) {
            // MIRIAMHelper.showMIRIAMAnnotationDialog(((SimpleReactionShape)shape).getReactionStep());
            // System.out.println("Menu action annotate activated...");
            ReactionStep rs = ((ReactionStepShape) shape).getReactionStep();
            VCMetaData vcMetaData = rs.getModel().getVcMetaData();
            try {
                String newAnnotation = DialogUtils.showAnnotationDialog(getGraphPane(), vcMetaData.getFreeTextAnnotation(rs));
                vcMetaData.setFreeTextAnnotation(rs, newAnnotation);
            } catch (UtilCancelException e) {
            // Do Nothing
            } catch (Throwable exc) {
                exc.printStackTrace(System.out);
                DialogUtils.showErrorDialog(getGraphPane(), "Failed to edit annotation!\n" + exc.getMessage(), exc);
            }
        }
    } else {
    // default action is to ignore
    }
}
Also used : ReactionSpeciesCopy(cbit.vcell.model.ReactionSpeciesCopy) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) 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) ProductShape(cbit.vcell.graph.ProductShape) UserCancelException(org.vcell.util.UserCancelException) SimpleReactionShape(cbit.vcell.graph.SimpleReactionShape) ReactantShape(cbit.vcell.graph.ReactantShape) SpeciesContext(cbit.vcell.model.SpeciesContext) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) Structure(cbit.vcell.model.Structure) UtilCancelException(org.vcell.util.UtilCancelException) ReactionRule(cbit.vcell.model.ReactionRule) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) Point(java.awt.Point) PropertyVetoException(java.beans.PropertyVetoException) UtilCancelException(org.vcell.util.UtilCancelException) ExpressionException(cbit.vcell.parser.ExpressionException) UserCancelException(org.vcell.util.UserCancelException) FluxReactionShape(cbit.vcell.graph.FluxReactionShape) MolecularType(org.vcell.model.rbm.MolecularType) PropertyVetoException(java.beans.PropertyVetoException) ReactionStep(cbit.vcell.model.ReactionStep) RuleParticipantSignatureDiagramShape(cbit.vcell.graph.RuleParticipantSignatureDiagramShape) ReactionParticipant(cbit.vcell.model.ReactionParticipant)

Example 2 with ProductShape

use of cbit.vcell.graph.ProductShape in project vcell by virtualcell.

the class ReactionCartoonTool method shapeHasMenuAction.

@Override
public boolean shapeHasMenuAction(Shape shape, String menuAction) {
    if (menuAction.equals(CartoonToolMiscActions.Annotate.MENU_ACTION)) {
        if (shape instanceof ReactionStepShape) {
            return true;
        }
    }
    if (menuAction.equals(CartoonToolEditActions.Copy.MENU_ACTION)) {
        if (shape instanceof SpeciesContextShape || shape instanceof ReactionStepShape || // rule participants don't make sense without their rule
        shape instanceof RuleParticipantSignatureDiagramShape || shape instanceof ReactionRuleDiagramShape) {
            return true;
        }
    }
    if (/*menuAction.equals(CartoonToolEditActions.Paste.MENU_ACTION)
				|| */
    menuAction.equals(CartoonToolEditActions.PasteNew.MENU_ACTION)) {
        if (shape instanceof ReactionContainerShape) {
            return true;
        }
    }
    if (menuAction.equals(CartoonToolEditActions.Delete.MENU_ACTION)) {
        if (shape instanceof ReactionContainerShape || shape instanceof ReactionStepShape || shape instanceof SpeciesContextShape || shape instanceof ReactantShape || shape instanceof ProductShape || shape instanceof CatalystShape || shape instanceof ReactionRuleDiagramShape || shape instanceof RuleParticipantSignatureDiagramShape) {
            return true;
        }
    }
    if (menuAction.equals(CartoonToolMiscActions.AddSpecies.MENU_ACTION)) {
        if (shape instanceof ReactionContainerShape) {
            return true;
        }
    }
    if (menuAction.equals(CartoonToolMiscActions.SearchReactions.MENU_ACTION)) {
        if (shape instanceof ReactionContainerShape) {
            return true;
        }
    }
    if (menuAction.equals(CartoonToolSaveAsImageActions.MenuAction.MENU_ACTION)) {
        if (shape instanceof ReactionContainerShape) {
            return true;
        }
    }
    if (menuAction.equals(CartoonToolMiscActions.Properties.MENU_ACTION)) {
        if (shape instanceof ReactionStepShape || shape instanceof SpeciesContextShape || shape instanceof ReactantShape || shape instanceof ProductShape || shape instanceof CatalystShape || shape instanceof ReactionContainerShape) {
            return true;
        }
    }
    GraphViewAction paintingAction = ActionUtil.getAction(paintingActions, menuAction);
    if (paintingAction != null) {
        return paintingAction.canBeAppliedToShape(shape);
    }
    GraphViewAction groupAction = ActionUtil.getAction(groupActions, menuAction);
    if (groupAction != null) {
        return groupAction.canBeAppliedToShape(shape);
    }
    return false;
}
Also used : ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) CatalystShape(cbit.vcell.graph.CatalystShape) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) ProductShape(cbit.vcell.graph.ProductShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) ReactantShape(cbit.vcell.graph.ReactantShape) GraphViewAction(cbit.gui.graph.actions.GraphViewAction) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) RuleParticipantSignatureDiagramShape(cbit.vcell.graph.RuleParticipantSignatureDiagramShape)

Aggregations

CatalystShape (cbit.vcell.graph.CatalystShape)2 ProductShape (cbit.vcell.graph.ProductShape)2 ReactantShape (cbit.vcell.graph.ReactantShape)2 ReactionContainerShape (cbit.vcell.graph.ReactionContainerShape)2 ReactionRuleDiagramShape (cbit.vcell.graph.ReactionRuleDiagramShape)2 ReactionStepShape (cbit.vcell.graph.ReactionStepShape)2 RuleParticipantSignatureDiagramShape (cbit.vcell.graph.RuleParticipantSignatureDiagramShape)2 SpeciesContextShape (cbit.vcell.graph.SpeciesContextShape)2 ContainerShape (cbit.gui.graph.ContainerShape)1 ElipseShape (cbit.gui.graph.ElipseShape)1 RubberBandEdgeShape (cbit.gui.graph.RubberBandEdgeShape)1 RubberBandRectShape (cbit.gui.graph.RubberBandRectShape)1 Shape (cbit.gui.graph.Shape)1 GraphViewAction (cbit.gui.graph.actions.GraphViewAction)1 VCMetaData (cbit.vcell.biomodel.meta.VCMetaData)1 ContainerContainerShape (cbit.vcell.graph.ContainerContainerShape)1 FluxReactionShape (cbit.vcell.graph.FluxReactionShape)1 ReactionParticipantShape (cbit.vcell.graph.ReactionParticipantShape)1 SimpleReactionShape (cbit.vcell.graph.SimpleReactionShape)1 ReactionParticipant (cbit.vcell.model.ReactionParticipant)1