use of cbit.vcell.graph.ReactionRuleDiagramShape 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;
}
use of cbit.vcell.graph.ReactionRuleDiagramShape in project vcell by virtualcell.
the class ReactionCartoonTool method mouseClicked.
@Override
public void mouseClicked(MouseEvent event) {
Point screenPoint = new Point(event.getX(), event.getY());
Point worldPoint = screenToWorld(screenPoint);
try {
if (event.getButton() != MouseEvent.BUTTON1) {
return;
}
switch(mode) {
case SELECT:
{
if (event.getClickCount() == 2) {
final Shape selectedShape = getReactionCartoon().getSelectedShape();
if (selectedShape instanceof ReactionContainerShape || selectedShape instanceof SpeciesContextShape || selectedShape instanceof SimpleReactionShape || selectedShape instanceof FluxReactionShape || selectedShape instanceof ReactionRuleDiagramShape || selectedShape instanceof RuleParticipantSignatureDiagramShape) {
editInPlace(selectedShape, worldPoint);
}
if (selectedShape != null) {
menuAction(selectedShape, CartoonToolMiscActions.Properties.MENU_ACTION);
}
}
break;
}
case STEP:
{
Shape pickedShape = getReactionCartoon().pickWorld(worldPoint);
if (pickedShape instanceof ReactionContainerShape) {
Structure structure = ((ReactionContainerShape) pickedShape).getStructure();
if (getReactionCartoon().getStructureSuite().areReactionsShownFor(structure)) {
ReactionStep reactionStep = getReactionCartoon().getModel().createSimpleReaction(structure);
positionShapeForObject(structure, reactionStep, worldPoint);
saveDiagram();
}
}
break;
}
case FLUX:
{
Shape pickedShape = getReactionCartoon().pickWorld(worldPoint);
if (pickedShape instanceof ReactionContainerShape) {
Structure structure = ((ReactionContainerShape) pickedShape).getStructure();
if (structure instanceof Membrane) {
Membrane membrane = (Membrane) structure;
FluxReaction fluxReaction = getReactionCartoon().getModel().createFluxReaction(membrane);
ReactionStepShape frShape = (ReactionStepShape) getReactionCartoon().getShapeFromModelObject(fluxReaction);
Point parentLocation = frShape.getParent().getSpaceManager().getAbsLoc();
frShape.getSpaceManager().setRelPos(worldPoint.x - parentLocation.x, worldPoint.y - parentLocation.y);
saveDiagram();
// setMode(SELECT_MODE);
} else {
// setMode(SELECT_MODE);
// throw new Exception("fluxes only applicable to membranes");
}
}
break;
}
case SPECIES:
{
Shape pickedShape = getReactionCartoon().pickWorld(worldPoint);
if (pickedShape instanceof ReactionContainerShape) {
SpeciesContext speciesContext = getReactionCartoon().getModel().createSpeciesContext(((ReactionContainerShape) pickedShape).getStructure());
reactionCartoon.clearSelection();
getGraphModel().select(speciesContext);
positionShapeForObject(speciesContext.getStructure(), speciesContext, worldPoint);
// showCreateSpeciesContextDialog(getGraphPane(), getReactionCartoon().getModel(), ((ReactionContainerShape) pickedShape).getStructure(), scShapeLocation);
saveDiagram();
}
}
default:
break;
}
} catch (Exception e) {
System.out.println("CartoonTool.mouseClicked: uncaught exception");
e.printStackTrace(System.out);
Point canvasLoc = getGraphPane().getLocationOnScreen();
canvasLoc.x += screenPoint.x;
canvasLoc.y += screenPoint.y;
DialogUtils.showErrorDialog(getGraphPane(), e.getMessage(), e);
}
}
Aggregations