Search in sources :

Example 1 with GraphViewAction

use of cbit.gui.graph.actions.GraphViewAction in project vcell by virtualcell.

the class ReactionCartoonTool method shapeHasMenuActionEnabled.

@Override
public boolean shapeHasMenuActionEnabled(Shape shape, String menuAction) {
    if (menuAction.equals(CartoonToolMiscActions.Properties.MENU_ACTION)) {
        if (shape instanceof CatalystShape) {
            return false;
        }
    }
    if (menuAction.equals(CartoonToolMiscActions.SearchReactions.MENU_ACTION)) {
        if (!(shape instanceof ReactionContainerShape) || !getReactionCartoon().getStructureSuite().getStructures().contains(shape.getModelObject())) {
            return false;
        }
    }
    GraphViewAction paintingAction = ActionUtil.getAction(paintingActions, menuAction);
    if (paintingAction != null) {
        return paintingAction.isEnabledForShape(shape);
    }
    GraphViewAction groupAction = ActionUtil.getAction(groupActions, menuAction);
    if (groupAction != null) {
        return groupAction.isEnabledForShape(shape);
    }
    if (shape instanceof ReactionContainerShape) {
        if (menuAction.equals(CartoonToolEditActions.PasteNew.MENU_ACTION)) {
            ReactionSpeciesCopy reactionSpeciesCopy = (ReactionSpeciesCopy) VCellTransferable.getFromClipboard(VCellTransferable.REACTION_SPECIES_ARRAY_FLAVOR);
            if (reactionSpeciesCopy != null) {
                Structure targetStructure = ((ReactionContainerShape) shape).getStructure();
                if (reactionSpeciesCopy.getReactStepArr() != null) {
                    for (int i = 0; i < reactionSpeciesCopy.getReactStepArr().length; i++) {
                        if (!reactionSpeciesCopy.getReactStepArr()[i].getStructure().getClass().equals(targetStructure.getClass())) {
                            return false;
                        }
                    }
                }
                return true;
            } else {
                return false;
            }
        } else if (menuAction.equals(CartoonToolEditActions.Delete.MENU_ACTION)) {
            if (((ReactionContainerShape) shape).getStructureSuite().getStructures().size() == 1) {
                return false;
            }
        }
    }
    return true;
}
Also used : ReactionSpeciesCopy(cbit.vcell.model.ReactionSpeciesCopy) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) CatalystShape(cbit.vcell.graph.CatalystShape) GraphViewAction(cbit.gui.graph.actions.GraphViewAction) Structure(cbit.vcell.model.Structure) Point(java.awt.Point)

Example 2 with GraphViewAction

use of cbit.gui.graph.actions.GraphViewAction 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

GraphViewAction (cbit.gui.graph.actions.GraphViewAction)2 CatalystShape (cbit.vcell.graph.CatalystShape)2 ReactionContainerShape (cbit.vcell.graph.ReactionContainerShape)2 ProductShape (cbit.vcell.graph.ProductShape)1 ReactantShape (cbit.vcell.graph.ReactantShape)1 ReactionRuleDiagramShape (cbit.vcell.graph.ReactionRuleDiagramShape)1 ReactionStepShape (cbit.vcell.graph.ReactionStepShape)1 RuleParticipantSignatureDiagramShape (cbit.vcell.graph.RuleParticipantSignatureDiagramShape)1 SpeciesContextShape (cbit.vcell.graph.SpeciesContextShape)1 ReactionSpeciesCopy (cbit.vcell.model.ReactionSpeciesCopy)1 Structure (cbit.vcell.model.Structure)1 Point (java.awt.Point)1