Package diva.graph

Examples of diva.graph.GraphModel


        // entity. This returns true only if the candidate object is
        // an instance of Locatable and the semantic object associated
        // with it is an instance of Entity.
        Filter portFilter = new Filter() {
            public boolean accept(Object candidate) {
                GraphModel model = getController().getGraphModel();
                Object semanticObject = model.getSemanticObject(candidate);

                if (candidate instanceof Locatable
                        && semanticObject instanceof Entity
                        && !((Entity) semanticObject).isClassDefinition()) {
                    return true;
View Full Code Here


            // top level is not an FSM actor.
            ActorViewerGraphController controller = new ActorViewerGraphController();

            controller.setConfiguration(_configuration);

            GraphModel model = new ActorGraphModel(_toplevel);
            pane = new GraphPane(controller, model);
        }

        JGraph modelViewer = new JGraph(pane);
View Full Code Here

    /** Layout the graph again.
     */
    private void _doLayout(GraphModel graph, GraphPane gp) {
        // Do the layout
        try {
            final GraphModel layoutGraph = graph;
            final GraphController gc = gp.getGraphController();
            final GraphPane pane = gp;
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    // Layout is a bit stupid
                    LayoutTarget target = new BasicLayoutTarget(gc);
                    LevelLayout staticLayout = new LevelLayout(target);
                    staticLayout.setOrientation(LevelLayout.HORIZONTAL);
                    staticLayout.layout(layoutGraph.getRoot());
                    pane.repaint();
                }
            });
        } catch (Exception e) {
            System.out.println(e);
View Full Code Here

            // Action activated using an ActionInteractor.
            LayerEvent event = (LayerEvent) source;
            CanvasLayer layer = event.getLayerSource();
            GraphPane pane = (GraphPane) layer.getCanvasPane();
            GraphController controller = pane.getGraphController();
            GraphModel model = controller.getGraphModel();

            _figure = event.getFigureSource();

            // Set the target.
            if (_figure == null) {
                _target = (NamedObj) model.getRoot();
            } else {
                Object object = _figure.getUserObject();
                _target = (NamedObj) model.getSemanticObject(object);
            }

            // Set the position.
            _x = event.getX();
            _y = event.getY();

            // Set the parent.
            CanvasPane canvasPane = layer.getCanvasPane();
            parent = canvasPane.getCanvas();
        } else if (source instanceof JMenuItem) {
            // Action activated using a context menu or submenu.
            JMenuItem item = (JMenuItem) source;
            // Find the original context menu.
            Component contextMenu = item.getParent();
            if (!(contextMenu instanceof JContextMenu)) {
                // Probably a submenu.
                // FIXME: This only supports one level of submenus.
                if (contextMenu instanceof JPopupMenu) {
                    contextMenu = ((JPopupMenu) contextMenu).getInvoker();
                }
                if (contextMenu instanceof JMenu) {
                    contextMenu = contextMenu.getParent();
                }
            }
            if (contextMenu instanceof JContextMenu) {
                _sourceType = CONTEXTMENU_TYPE;
                JContextMenu menu = (JContextMenu) contextMenu;
                parent = menu.getInvoker();
                _target = (NamedObj) menu.getTarget();
                _x = item.getX();
                _y = item.getY();
            } else {
                // Not implicit location.. should there be?
                _sourceType = MENUBAR_TYPE;
            }
            /*
             } else if (source instanceof JMenuItem) {
             // Action activated using a context menu.
             JMenuItem item = (JMenuItem) source;

             if (item.getParent() instanceof JContextMenu) {
             _sourceType = CONTEXTMENU_TYPE;

             JContextMenu menu = (JContextMenu) item.getParent();
             parent = menu.getInvoker();
             _target = (NamedObj) menu.getTarget();
             _x = item.getX();
             _y = item.getY();
             } else {
             // Not implicit location.. should there be?
             _sourceType = MENUBAR_TYPE;
             }
             */
        } else if (source instanceof JButton) {
            // presumably we are in a toolbar...
            _sourceType = TOOLBAR_TYPE;
            _target = null;
            parent = ((Component) source).getParent();
        } else if (source instanceof JGraph) {
            // This is an absurdly convoluted way to get the info we need.
            // But there seems to be no other way.
            // This is an architectural flaw in vergil.
            GraphPane pane = ((JGraph) source).getGraphPane();
            FigureLayer layer = pane.getForegroundLayer();
            CanvasComponent currentFigure = layer.getCurrentFigure();
            GraphController controller = pane.getGraphController();
            GraphModel model = controller.getGraphModel();

            if (currentFigure != null) {
                _target = null;

                while ((_target == null) && (currentFigure != null)) {
                    Object object = currentFigure;

                    if (object instanceof Figure) {
                        object = ((Figure) currentFigure).getUserObject();
                    }

                    _target = (NamedObj) model.getSemanticObject(object);
                    currentFigure = currentFigure.getParent();
                }

                // NOTE: _target may end up null here!
                if (_target == null) {
                    throw new InternalErrorException(
                            "Internal error: Figure has no associated Ptolemy II object!");
                }
            } else {
                _target = (NamedObj) model.getRoot();
            }

            _sourceType = HOTKEY_TYPE;

            // FIXME: set _x and _y.  How to do this?
View Full Code Here

            newFigure.setUserObject(node);
            getController().setFigure(node, newFigure);
            return newFigure;
        } else {
            Figure nf = super._renderNode(node);
            GraphModel model = getController().getGraphModel();
            Object object = model.getSemanticObject(node);
            CompositeFigure cf = _getCompositeFigure(nf);

            if (_decoratable
                    && object instanceof NamedObj
                    && (((NamedObj) object).getDerivedLevel() < Integer.MAX_VALUE)
View Full Code Here

TOP

Related Classes of diva.graph.GraphModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.