Package diva.graph

Examples of diva.graph.GraphController


     * any deleted nodes.
     */
    public void actionPerformed(ActionEvent e) {
        JGraph jgraph = (JGraph) e.getSource();
        GraphPane graphPane = jgraph.getGraphPane();
        GraphController controller = graphPane.getGraphController();
        GraphModel graphModel = controller.getGraphModel();
        SelectionModel model = controller.getSelectionModel();
        Object[] selection = model.getSelectionAsArray();
        Object[] userObjects = new Object[selection.length];

        // First remove the selection.
        for (int i = 0; i < selection.length; i++) {
            userObjects[i] = ((Figure) selection[i]).getUserObject();
            model.removeSelection(selection[i]);
        }

        // Remove all the edges first, since if we remove the nodes first,
        // then removing the nodes might remove some of the edges.
        for (int i = 0; i < userObjects.length; i++) {
            Object userObject = userObjects[i];

            if (graphModel.isEdge(userObject)) {
                controller.removeEdge(userObject);
            }
        }

        for (int i = 0; i < selection.length; i++) {
            Object userObject = userObjects[i];

            if (graphModel.isNode(userObject)) {
                controller.removeNode(userObject);
            }
        }
    }
View Full Code Here


        getContentPane().add(_divaPanel);

        _graph = _constructDivaGraph();

        // display the graph.
        final GraphController gc = new LocalZenoGraphController();
        final GraphPane gp = new GraphPane(gc, _graph);
        _jgraph = new JGraph(gp);
        _divaPanel.add(_jgraph);

        StateListener listener = new StateListener((GraphPane) _jgraph
View Full Code Here

     */
    protected 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);
View Full Code Here

     *  and connections. The created typed composite actor is transparent.
     *  The resulting topology is the same in the sense
     *  of deep connectivities.
     */
    public void createHierarchy() {
        GraphController controller = _getGraphController();
        SelectionModel model = controller.getSelectionModel();
        AbstractBasicGraphModel graphModel = (AbstractBasicGraphModel) controller
                .getGraphModel();
        Object[] selection = model.getSelectionAsArray();

        // A set, because some objects may represent the same
        // ptolemy object.
View Full Code Here

     */
    public void delete() {
        // Note that we previously a delete was handled at the model level.
        // Now a delete is handled by generating MoML to carry out the delete
        // and handing that MoML to the parser
        GraphController controller = _getGraphController();
        SelectionModel model = controller.getSelectionModel();
        AbstractBasicGraphModel graphModel = (AbstractBasicGraphModel) controller
                .getGraphModel();
        Object[] selection = model.getSelectionAsArray();

        // Generate the MoML to carry out the deletion
        StringBuffer moml = _deleteMoML(graphModel, selection, model);
View Full Code Here

    }

    /** Layout the graph view.
     */
    public void layoutGraph() {
        GraphController controller = _getGraphController();
        AbstractBasicGraphModel model = _getGraphModel();
        LayoutTarget target = new PtolemyLayoutTarget(controller);
        PtolemyLayout layout = new PtolemyLayout(target);
        layout.setOrientation(LevelLayout.HORIZONTAL);
        layout.setRandomizedPlacement(false);
View Full Code Here

    /** Return the graph model associated with this frame.
     *  @return The graph model associated with this frame.
     */
    protected AbstractBasicGraphModel _getGraphModel() {
        GraphController controller = _getGraphController();
        return (AbstractBasicGraphModel) controller.getGraphModel();
    }
View Full Code Here

     *  defined by the container, then call sortContainedObjects()
     *  on the container to sort the result.
     *  @return The set of selected objects.
     */
    protected HashSet _getSelectionSet() {
        GraphController controller = _getGraphController();
        GraphModel graphModel = controller.getGraphModel();
        SelectionModel model = controller.getSelectionModel();
        Object[] selection = model.getSelectionAsArray();

        // A set, because some objects may represent the same
        // ptolemy object.
        HashSet namedObjSet = new HashSet();
View Full Code Here

                    // the graph model. Otherwise, this change request will
                    // trigger a redraw of the entire graph, which will result
                    // in another call to this very same method, which will
                    // result in creation of yet another figure before this
                    // method even returns!
                    GraphController controller = IconController.this
                            .getController();
                    GraphModel graphModel = controller.getGraphModel();
                    ChangeRequest request = new ChangeRequest(graphModel,
                            "Set the container of a new XMLIcon.") {
                        // NOTE: The KernelException should not be thrown,
                        // but if it is, it will be handled properly.
                        protected void _execute() throws KernelException {
View Full Code Here

        _ruleMenu.addSeparator();

        LayoutAction layoutAction = new LayoutAction();
        GUIUtilities.addMenuItem(_ruleMenu, layoutAction);

        GraphController controller = (GraphController) _getGraphController();
        if (getFrameController().hasTabs()) {
            if (controller instanceof ActorEditorGraphController) {
                _ruleMenu.addSeparator();
                Action newRelationAction =
                    ((ActorEditorGraphController) controller)
View Full Code Here

TOP

Related Classes of diva.graph.GraphController

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.