Search in sources :

Example 1 with ReactionContainerShape

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

the class GraphContainerLayoutReactions method getPreferedSizeReactionContainerShape.

public Dimension getPreferedSizeReactionContainerShape(ReactionContainerShape shape, Graphics2D g) {
    // get size when empty
    Font origFont = g.getFont();
    g.setFont(shape.getLabelFont(g));
    try {
        Dimension preferredSize = shape.getPreferedSizeSelf(g);
        // make larger than empty size so that children fit
        for (Shape child : shape.getChildren()) {
            if (child instanceof ReactionStepShape || child instanceof SpeciesContextShape || child instanceof RuleParticipantSignatureFullDiagramShape || child instanceof RuleParticipantSignatureShortDiagramShape || child instanceof ReactionRuleDiagramShape) {
                preferredSize.width = Math.max(preferredSize.width, child.getSpaceManager().getRelPos().x + child.getSpaceManager().getSize().width);
                preferredSize.height = Math.max(preferredSize.height, child.getSpaceManager().getRelPos().y + child.getSpaceManager().getSize().height);
            }
        }
        preferredSize.width = preferredSize.width + WIDTH_PADDING;
        preferredSize.height = preferredSize.height + HEIGHT_PADDING;
        Structure structure = shape.getStructure();
        int minWidthSum = 0;
        for (Structure structure2 : shape.getStructureSuite().getStructures()) {
            if (structure2 instanceof Feature) {
                minWidthSum += FEATURE_MIN_WIDTH;
            } else {
                minWidthSum += MEMBRANE_MIN_WIDTH;
            }
        }
        int compartmentMinWidth = 0;
        if (structure instanceof Feature) {
            compartmentMinWidth = FEATURE_MIN_WIDTH;
        } else {
            compartmentMinWidth = MEMBRANE_MIN_WIDTH;
        }
        int apportionedWidth = compartmentMinWidth * TOTAL_MIN_WIDTH / minWidthSum;
        if (preferredSize.width < compartmentMinWidth) {
            preferredSize.width = compartmentMinWidth;
        }
        if (preferredSize.width < apportionedWidth) {
            preferredSize.width = apportionedWidth;
        }
        if (preferredSize.height < MIN_HEIGHT) {
            preferredSize.height = MIN_HEIGHT;
        }
        return preferredSize;
    } finally {
        g.setFont(origFont);
    }
}
Also used : RuleParticipantSignatureShortDiagramShape(cbit.vcell.graph.RuleParticipantSignatureShortDiagramShape) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) RuleParticipantSignatureFullDiagramShape(cbit.vcell.graph.RuleParticipantSignatureFullDiagramShape) RuleParticipantSignatureShortDiagramShape(cbit.vcell.graph.RuleParticipantSignatureShortDiagramShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) ReactionRuleFullDiagramShape(cbit.vcell.graph.ReactionRuleFullDiagramShape) ContainerContainerShape(cbit.vcell.graph.ContainerContainerShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) RuleParticipantSignatureFullDiagramShape(cbit.vcell.graph.RuleParticipantSignatureFullDiagramShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) Dimension(java.awt.Dimension) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) Structure(cbit.vcell.model.Structure) Feature(cbit.vcell.model.Feature) Font(java.awt.Font) Point(java.awt.Point)

Example 2 with ReactionContainerShape

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

the class GraphContainerLayoutReactions method refreshLayoutChildrenContainerContainerShape.

public void refreshLayoutChildrenContainerContainerShape(ContainerContainerShape shape) {
    List<ReactionContainerShape> structureContainers = shape.getStructureContainers();
    int currentX = 0;
    int currentY = 0;
    for (int i = 0; i < structureContainers.size(); i++) {
        structureContainers.get(i).getSpaceManager().setRelPos(currentX, currentY);
        currentX += structureContainers.get(i).getSpaceManager().getSize().width;
    }
}
Also used : ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) Point(java.awt.Point)

Example 3 with ReactionContainerShape

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

the class GraphContainerLayoutVCellClassical method getPreferedSizeReactionContainerShape.

public Dimension getPreferedSizeReactionContainerShape(ReactionContainerShape shape, Graphics2D g) {
    // get size when empty
    Font origFont = g.getFont();
    g.setFont(shape.getLabelFont(g));
    try {
        Dimension emptySize = shape.getPreferedSizeSelf(g);
        // make larger than empty size so that children fit
        for (Shape child : shape.getChildren()) {
            if (child instanceof ReactionStepShape || child instanceof SpeciesContextShape) {
                emptySize.width = Math.max(emptySize.width, child.getSpaceManager().getRelPos().x + child.getSpaceManager().getSize().width);
                emptySize.height = Math.max(emptySize.height, child.getSpaceManager().getRelPos().y + child.getSpaceManager().getSize().height);
            }
        }
        emptySize.width = emptySize.width + emptySize.width / 10;
        emptySize.height = emptySize.height + emptySize.height / 10;
        return emptySize;
    } finally {
        g.setFont(origFont);
    }
}
Also used : SubVolumeContainerShape(cbit.vcell.graph.SubVolumeContainerShape) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) MembraneShape(cbit.vcell.graph.MembraneShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) GeometryContextStructureShape(cbit.vcell.graph.GeometryContextStructureShape) FeatureShape(cbit.vcell.graph.FeatureShape) StructureMappingStructureShape(cbit.vcell.graph.StructureMappingStructureShape) ContainerContainerShape(cbit.vcell.graph.ContainerContainerShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) GeometryContextContainerShape(cbit.vcell.graph.GeometryContextContainerShape) GeometryContextGeometryShape(cbit.vcell.graph.GeometryContextGeometryShape) StructureShape(cbit.vcell.graph.StructureShape) GeometryClassLegendShape(cbit.vcell.graph.GeometryClassLegendShape) BioPaxShape(cbit.vcell.client.desktop.biomodel.pathway.shapes.BioPaxShape) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) Dimension(java.awt.Dimension) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) Font(java.awt.Font)

Example 4 with ReactionContainerShape

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

the class GraphPane method getToolTipText.

@Override
public String getToolTipText(MouseEvent event) {
    if (graphModel == null) {
        return getToolTipText();
    }
    Point unzoomedMousePos = graphModel.getResizeManager().unzoom(event.getPoint());
    Shape pickedShape = graphModel.pickWorld(unzoomedMousePos);
    if (pickedShape == null) {
        return getToolTipText();
    }
    if (pickedShape instanceof ReactionContainerShape) {
        return ((ReactionContainerShape) pickedShape).getSpecialToolTipText(unzoomedMousePos);
    }
    return pickedShape.getLabel();
}
Also used : ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) Shape(cbit.gui.graph.Shape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) Point(java.awt.Point)

Example 5 with ReactionContainerShape

use of cbit.vcell.graph.ReactionContainerShape 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)

Aggregations

ReactionContainerShape (cbit.vcell.graph.ReactionContainerShape)21 Point (java.awt.Point)16 SpeciesContextShape (cbit.vcell.graph.SpeciesContextShape)13 ReactionStepShape (cbit.vcell.graph.ReactionStepShape)12 ContainerContainerShape (cbit.vcell.graph.ContainerContainerShape)11 ReactionRuleDiagramShape (cbit.vcell.graph.ReactionRuleDiagramShape)11 CatalystShape (cbit.vcell.graph.CatalystShape)9 RubberBandRectShape (cbit.gui.graph.RubberBandRectShape)8 Shape (cbit.gui.graph.Shape)8 FluxReactionShape (cbit.vcell.graph.FluxReactionShape)8 ProductShape (cbit.vcell.graph.ProductShape)8 ReactantShape (cbit.vcell.graph.ReactantShape)8 RuleParticipantSignatureDiagramShape (cbit.vcell.graph.RuleParticipantSignatureDiagramShape)8 SimpleReactionShape (cbit.vcell.graph.SimpleReactionShape)8 Structure (cbit.vcell.model.Structure)8 Dimension (java.awt.Dimension)8 ContainerShape (cbit.gui.graph.ContainerShape)7 ElipseShape (cbit.gui.graph.ElipseShape)7 RubberBandEdgeShape (cbit.gui.graph.RubberBandEdgeShape)7 ReactionParticipantShape (cbit.vcell.graph.ReactionParticipantShape)7