Examples of TogglePropertyItem


Examples of com.mxgraph.examples.swing.editor.EditorActions.TogglePropertyItem

        .getEditAction()));

    // Creates the view menu
    menu = add(new JMenu(mxResources.get("view")));

    JMenuItem item = menu.add(new TogglePropertyItem(graphComponent,
        mxResources.get("pageLayout"), "PageVisible", true,
        new ActionListener()
        {
          /**
           *
           */
          public void actionPerformed(ActionEvent e)
          {
            if (graphComponent.isPageVisible()
                && graphComponent.isCenterPage())
            {
              graphComponent.zoomAndCenter();
            }
            else
            {
              graphComponent.getGraphControl()
                  .updatePreferredSize();
            }
          }
        }));

    item.addActionListener(new ActionListener()
    {
      /*
       * (non-Javadoc)
       * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
       */
      public void actionPerformed(ActionEvent e)
      {
        if (e.getSource() instanceof TogglePropertyItem)
        {
          final mxGraphComponent graphComponent = editor
              .getGraphComponent();
          TogglePropertyItem toggleItem = (TogglePropertyItem) e
              .getSource();

          if (toggleItem.isSelected())
          {
            // Scrolls the view to the center
            SwingUtilities.invokeLater(new Runnable()
            {
              /*
               * (non-Javadoc)
               * @see java.lang.Runnable#run()
               */
              public void run()
              {
                graphComponent.scrollToCenter(true);
                graphComponent.scrollToCenter(false);
              }
            });
          }
          else
          {
            // Resets the translation of the view
            mxPoint tr = graphComponent.getGraph().getView()
                .getTranslate();

            if (tr.getX() != 0 || tr.getY() != 0)
            {
              graphComponent.getGraph().getView().setTranslate(
                  new mxPoint());
            }
          }
        }
      }
    });

    menu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("antialias"), "AntiAlias", true));

    menu.addSeparator();

    menu.add(new ToggleGridItem(editor, mxResources.get("grid")));
    menu.add(new ToggleRulersItem(editor, mxResources.get("rulers")));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("zoom")));

    submenu.add(editor.bind("400%", new ScaleAction(4)));
    submenu.add(editor.bind("200%", new ScaleAction(2)));
    submenu.add(editor.bind("150%", new ScaleAction(1.5)));
    submenu.add(editor.bind("100%", new ScaleAction(1)));
    submenu.add(editor.bind("75%", new ScaleAction(0.75)));
    submenu.add(editor.bind("50%", new ScaleAction(0.5)));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("custom"), new ScaleAction(0)));

    menu.addSeparator();

    menu.add(editor.bind(mxResources.get("zoomIn"), mxGraphActions
        .getZoomInAction()));
    menu.add(editor.bind(mxResources.get("zoomOut"), mxGraphActions
        .getZoomOutAction()));

    menu.addSeparator();

    menu.add(editor.bind(mxResources.get("page"), new ZoomPolicyAction(
        mxGraphComponent.ZOOM_POLICY_PAGE)));
    menu.add(editor.bind(mxResources.get("width"), new ZoomPolicyAction(
        mxGraphComponent.ZOOM_POLICY_WIDTH)));

    menu.addSeparator();

    menu.add(editor.bind(mxResources.get("actualSize"), mxGraphActions
        .getZoomActualAction()));

    // Creates the format menu
    menu = add(new JMenu(mxResources.get("format")));

    populateFormatMenu(menu, editor);

    // Creates the shape menu
    menu = add(new JMenu(mxResources.get("shape")));

    populateShapeMenu(menu, editor);

    // Creates the diagram menu
    menu = add(new JMenu(mxResources.get("diagram")));

    menu.add(new ToggleOutlineItem(editor, mxResources.get("outline")));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("background")));

    submenu.add(editor.bind(mxResources.get("backgroundColor"),
        new BackgroundAction()));
    submenu.add(editor.bind(mxResources.get("backgroundImage"),
        new BackgroundImageAction()));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("pageBackground"),
        new PageBackgroundAction()));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("grid")));

    submenu.add(editor.bind(mxResources.get("gridSize"),
        new PromptPropertyAction(graph, "Grid Size", "GridSize")));
    submenu.add(editor.bind(mxResources.get("gridColor"),
        new GridColorAction()));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("dashed"), new GridStyleAction(
        mxGraphComponent.GRID_STYLE_DASHED)));
    submenu.add(editor.bind(mxResources.get("dot"), new GridStyleAction(
        mxGraphComponent.GRID_STYLE_DOT)));
    submenu.add(editor.bind(mxResources.get("line"), new GridStyleAction(
        mxGraphComponent.GRID_STYLE_LINE)));
    submenu.add(editor.bind(mxResources.get("cross"), new GridStyleAction(
        mxGraphComponent.GRID_STYLE_CROSS)));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("layout")));

    submenu.add(editor.graphLayout("verticalHierarchical", true));
    submenu.add(editor.graphLayout("horizontalHierarchical", true));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("verticalPartition", false));
    submenu.add(editor.graphLayout("horizontalPartition", false));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("verticalStack", false));
    submenu.add(editor.graphLayout("horizontalStack", false));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("verticalTree", true));
    submenu.add(editor.graphLayout("horizontalTree", true));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("placeEdgeLabels", false));
    submenu.add(editor.graphLayout("parallelEdges", false));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("organicLayout", true));
    submenu.add(editor.graphLayout("circleLayout", true));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("selection")));

    submenu.add(editor.bind(mxResources.get("selectPath"),
        new SelectShortestPathAction(false)));
    submenu.add(editor.bind(mxResources.get("selectDirectedPath"),
        new SelectShortestPathAction(true)));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("selectTree"),
        new SelectSpanningTreeAction(false)));
    submenu.add(editor.bind(mxResources.get("selectDirectedTree"),
        new SelectSpanningTreeAction(true)));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("stylesheet")));

    submenu
        .add(editor
            .bind(
                mxResources.get("basicStyle"),
                new StylesheetAction(
                    "/com/mxgraph/examples/swing/resources/basic-style.xml")));
    submenu
        .add(editor
            .bind(
                mxResources.get("defaultStyle"),
                new StylesheetAction(
                    "/com/mxgraph/examples/swing/resources/default-style.xml")));

    // Creates the options menu
    menu = add(new JMenu(mxResources.get("options")));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("display")));
    submenu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("buffering"), "TripleBuffered", true));

    submenu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("preferPageSize"), "PreferPageSize", true,
        new ActionListener()
        {
          /**
           *
           */
          public void actionPerformed(ActionEvent e)
          {
            graphComponent.zoomAndCenter();
          }
        }));

    // TODO: This feature is not yet implemented
    //submenu.add(new TogglePropertyItem(graphComponent, mxResources
    //    .get("pageBreaks"), "PageBreaksVisible", true));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("tolerance"),
        new PromptPropertyAction(graphComponent, "Tolerance")));

    submenu.add(editor.bind(mxResources.get("dirty"),
        new ToggleDirtyAction()));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("zoom")));

    submenu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("centerZoom"), "CenterZoom", true));
    submenu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("zoomToSelection"), "KeepSelectionVisibleOnZoom", true));

    submenu.addSeparator();

    submenu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("centerPage"), "CenterPage", true, new ActionListener()
    {
      /**
       *
       */
      public void actionPerformed(ActionEvent e)
      {
        if (graphComponent.isPageVisible()
            && graphComponent.isCenterPage())
        {
          graphComponent.zoomAndCenter();
        }
      }
    }));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("dragAndDrop")));

    submenu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("dragEnabled"), "DragEnabled"));
    submenu.add(new TogglePropertyItem(graph, mxResources
        .get("dropEnabled"), "DropEnabled"));

    submenu.addSeparator();

    submenu.add(new TogglePropertyItem(graphComponent.getGraphHandler(),
        mxResources.get("imagePreview"), "ImagePreview"));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("labels")));

    submenu.add(new TogglePropertyItem(graph,
        mxResources.get("htmlLabels"), "HtmlLabels", true));
    submenu.add(new TogglePropertyItem(graph,
        mxResources.get("showLabels"), "LabelsVisible", true));

    submenu.addSeparator();

    submenu.add(new TogglePropertyItem(graph, mxResources
        .get("moveEdgeLabels"), "EdgeLabelsMovable"));
    submenu.add(new TogglePropertyItem(graph, mxResources
        .get("moveVertexLabels"), "VertexLabelsMovable"));

    submenu.addSeparator();

    submenu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("handleReturn"), "EnterStopsCellEditing"));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("connections")));

    submenu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("connectable"), "Connectable"));
    submenu.add(new TogglePropertyItem(graph, mxResources
        .get("connectableEdges"), "ConnectableEdges"));

    submenu.addSeparator();

    submenu.add(new ToggleCreateTargetItem(editor, mxResources
        .get("createTarget")));
    submenu.add(new TogglePropertyItem(graph, mxResources
        .get("disconnectOnMove"), "DisconnectOnMove"));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("connectMode"),
        new ToggleConnectModeAction()));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("validation")));

    submenu.add(new TogglePropertyItem(graph, mxResources
        .get("allowDanglingEdges"), "AllowDanglingEdges"));
    submenu.add(new TogglePropertyItem(graph, mxResources
        .get("cloneInvalidEdges"), "CloneInvalidEdges"));

    submenu.addSeparator();

    submenu.add(new TogglePropertyItem(graph,
        mxResources.get("allowLoops"), "AllowLoops"));
    submenu.add(new TogglePropertyItem(graph,
        mxResources.get("multigraph"), "Multigraph"));

    // Creates the window menu
    menu = add(new JMenu(mxResources.get("window")));

View Full Code Here

Examples of com.mxgraph.examples.swing.editor.EditorActions.TogglePropertyItem

        .getEditAction()));

    // Creates the view menu
    menu = add(new JMenu(mxResources.get("view")));

    JMenuItem item = menu.add(new TogglePropertyItem(graphComponent,
        mxResources.get("pageLayout"), "PageVisible", true,
        new ActionListener()
        {
          /**
           *
           */
          public void actionPerformed(ActionEvent e)
          {
            if (graphComponent.isPageVisible()
                && graphComponent.isCenterPage())
            {
              graphComponent.zoomAndCenter();
            }
          }
        }));

    item.addActionListener(new ActionListener()
    {
      /*
       * (non-Javadoc)
       * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
       */
      public void actionPerformed(ActionEvent e)
      {
        if (e.getSource() instanceof TogglePropertyItem)
        {
          final mxGraphComponent graphComponent = editor
              .getGraphComponent();
          TogglePropertyItem toggleItem = (TogglePropertyItem) e
              .getSource();

          if (toggleItem.isSelected())
          {
            // Scrolls the view to the center
            SwingUtilities.invokeLater(new Runnable()
            {
              /*
               * (non-Javadoc)
               * @see java.lang.Runnable#run()
               */
              public void run()
              {
                graphComponent.scrollToCenter(true);
                graphComponent.scrollToCenter(false);
              }
            });
          }
          else
          {
            // Resets the translation of the view
            mxPoint tr = graphComponent.getGraph().getView()
                .getTranslate();

            if (tr.getX() != 0 || tr.getY() != 0)
            {
              graphComponent.getGraph().getView().setTranslate(
                  new mxPoint());
            }
          }
        }
      }
    });

    menu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("antialias"), "AntiAlias", true));

    menu.addSeparator();

    menu.add(new ToggleGridItem(editor, mxResources.get("grid")));
    menu.add(new ToggleRulersItem(editor, mxResources.get("rulers")));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("zoom")));

    submenu.add(editor.bind("400%", new ScaleAction(4)));
    submenu.add(editor.bind("200%", new ScaleAction(2)));
    submenu.add(editor.bind("150%", new ScaleAction(1.5)));
    submenu.add(editor.bind("100%", new ScaleAction(1)));
    submenu.add(editor.bind("75%", new ScaleAction(0.75)));
    submenu.add(editor.bind("50%", new ScaleAction(0.5)));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("custom"), new ScaleAction(0)));

    menu.addSeparator();

    menu.add(editor.bind(mxResources.get("zoomIn"), mxGraphActions
        .getZoomInAction()));
    menu.add(editor.bind(mxResources.get("zoomOut"), mxGraphActions
        .getZoomOutAction()));

    menu.addSeparator();

    menu.add(editor.bind(mxResources.get("page"), new ZoomPolicyAction(
        mxGraphComponent.ZOOM_POLICY_PAGE)));
    menu.add(editor.bind(mxResources.get("width"), new ZoomPolicyAction(
        mxGraphComponent.ZOOM_POLICY_WIDTH)));

    menu.addSeparator();

    menu.add(editor.bind(mxResources.get("actualSize"), mxGraphActions
        .getZoomActualAction()));

    // Creates the diagram menu
    menu = add(new JMenu(mxResources.get("diagram")));

    menu.add(new ToggleOutlineItem(editor, mxResources.get("outline")));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("background")));

    submenu.add(editor.bind(mxResources.get("backgroundColor"),
        new BackgroundAction()));
    submenu.add(editor.bind(mxResources.get("backgroundImage"),
        new BackgroundImageAction()));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("pageBackground"),
        new PageBackgroundAction()));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("grid")));

    submenu.add(editor.bind(mxResources.get("gridSize"),
        new PromptPropertyAction(graph, "Grid Size", "GridSize")));
    submenu.add(editor.bind(mxResources.get("gridColor"),
        new GridColorAction()));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("dashed"), new GridStyleAction(
        mxGraphComponent.GRID_STYLE_DASHED)));
    submenu.add(editor.bind(mxResources.get("dot"), new GridStyleAction(
        mxGraphComponent.GRID_STYLE_DOT)));
    submenu.add(editor.bind(mxResources.get("line"), new GridStyleAction(
        mxGraphComponent.GRID_STYLE_LINE)));
    submenu.add(editor.bind(mxResources.get("cross"), new GridStyleAction(
        mxGraphComponent.GRID_STYLE_CROSS)));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("layout")));

    submenu.add(editor.graphLayout("verticalHierarchical", true));
    submenu.add(editor.graphLayout("horizontalHierarchical", true));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("verticalPartition", false));
    submenu.add(editor.graphLayout("horizontalPartition", false));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("verticalStack", false));
    submenu.add(editor.graphLayout("horizontalStack", false));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("verticalTree", true));
    submenu.add(editor.graphLayout("horizontalTree", true));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("parallelEdges", false));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("organicLayout", true));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("selection")));

    submenu.add(editor.bind(mxResources.get("selectPath"),
        new SelectShortestPathAction(false)));
    submenu.add(editor.bind(mxResources.get("selectDirectedPath"),
        new SelectShortestPathAction(true)));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("selectTree"),
        new SelectSpanningTreeAction(false)));
    submenu.add(editor.bind(mxResources.get("selectDirectedTree"),
        new SelectSpanningTreeAction(true)));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("stylesheet")));

    submenu
        .add(editor
            .bind(
                mxResources.get("basicStyle"),
                new StylesheetAction(
                    "/com/mxgraph/examples/swing/resources/basic-style.xml")));
    submenu
        .add(editor
            .bind(
                mxResources.get("defaultStyle"),
                new StylesheetAction(
                    "/com/mxgraph/examples/swing/resources/default-style.xml")));

    // Creates the options menu
    menu = add(new JMenu(mxResources.get("options")));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("display")));
    submenu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("buffering"), "TripleBuffered", true));
    submenu.add(editor.bind(mxResources.get("dirty"),
        new ToggleDirtyAction()));

    submenu.addSeparator();

    item = submenu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("centerPage"), "CenterPage", true, new ActionListener()
    {
      /**
       *
       */
      public void actionPerformed(ActionEvent e)
      {
        if (graphComponent.isPageVisible()
            && graphComponent.isCenterPage())
        {
          graphComponent.zoomAndCenter();
        }
      }
    }));

    submenu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("centerZoom"), "CenterZoom", true));
    submenu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("zoomToSelection"), "KeepSelectionVisibleOnZoom", true));

    submenu.addSeparator();

    submenu.add(new TogglePropertyItem(graphComponent, mxResources
        .get("preferPagesize"), "PreferPageSize", true));

    // This feature is not yet implemented
    //submenu.add(new TogglePropertyItem(graphComponent, mxResources
    //    .get("pageBreaks"), "PageBreaksVisible", true));
View Full Code Here

Examples of com.mxgraph.examples.swing.editor.EditorActions.TogglePropertyItem

    menu.add(editor.bind(mxResources.get("edit"), mxGraphActions.getEditAction()));

    // Creates the view menu
    menu = add(new JMenu(mxResources.get("view")));

    JMenuItem item = menu.add(new TogglePropertyItem(graphComponent, mxResources.get("pageLayout"), "PageVisible", true,
        new ActionListener()
        {
          /**
           *
           */
          public void actionPerformed(ActionEvent e)
          {
            if (graphComponent.isPageVisible() && graphComponent.isCenterPage())
            {
              graphComponent.zoomAndCenter();
            }
            else
            {
              graphComponent.getGraphControl().updatePreferredSize();
            }
          }
        }));

    item.addActionListener(new ActionListener()
    {
      /*
       * (non-Javadoc)
       * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
       */
      public void actionPerformed(ActionEvent e)
      {
        if (e.getSource() instanceof TogglePropertyItem)
        {
          final mxGraphComponent graphComponent = editor.getGraphComponent();
          TogglePropertyItem toggleItem = (TogglePropertyItem) e.getSource();

          if (toggleItem.isSelected())
          {
            // Scrolls the view to the center
            SwingUtilities.invokeLater(new Runnable()
            {
              /*
               * (non-Javadoc)
               * @see java.lang.Runnable#run()
               */
              public void run()
              {
                graphComponent.scrollToCenter(true);
                graphComponent.scrollToCenter(false);
              }
            });
          }
          else
          {
            // Resets the translation of the view
            mxPoint tr = graphComponent.getGraph().getView().getTranslate();

            if (tr.getX() != 0 || tr.getY() != 0)
            {
              graphComponent.getGraph().getView().setTranslate(new mxPoint());
            }
          }
        }
      }
    });

    menu.add(new TogglePropertyItem(graphComponent, mxResources.get("antialias"), "AntiAlias", true));

    menu.addSeparator();

    menu.add(new ToggleGridItem(editor, mxResources.get("grid")));
    menu.add(new ToggleRulersItem(editor, mxResources.get("rulers")));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("zoom")));

    submenu.add(editor.bind("400%", new ScaleAction(4)));
    submenu.add(editor.bind("200%", new ScaleAction(2)));
    submenu.add(editor.bind("150%", new ScaleAction(1.5)));
    submenu.add(editor.bind("100%", new ScaleAction(1)));
    submenu.add(editor.bind("75%", new ScaleAction(0.75)));
    submenu.add(editor.bind("50%", new ScaleAction(0.5)));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("custom"), new ScaleAction(0)));

    menu.addSeparator();

    menu.add(editor.bind(mxResources.get("zoomIn"), mxGraphActions.getZoomInAction()));
    menu.add(editor.bind(mxResources.get("zoomOut"), mxGraphActions.getZoomOutAction()));

    menu.addSeparator();

    menu.add(editor.bind(mxResources.get("page"), new ZoomPolicyAction(mxGraphComponent.ZOOM_POLICY_PAGE)));
    menu.add(editor.bind(mxResources.get("width"), new ZoomPolicyAction(mxGraphComponent.ZOOM_POLICY_WIDTH)));

    menu.addSeparator();

    menu.add(editor.bind(mxResources.get("actualSize"), mxGraphActions.getZoomActualAction()));

    // Creates the format menu
    menu = add(new JMenu(mxResources.get("format")));

    populateFormatMenu(menu, editor);

    // Creates the shape menu
    menu = add(new JMenu(mxResources.get("shape")));

    populateShapeMenu(menu, editor);

    // Creates the diagram menu
    menu = add(new JMenu(mxResources.get("diagram")));

    menu.add(new ToggleOutlineItem(editor, mxResources.get("outline")));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("background")));

    submenu.add(editor.bind(mxResources.get("backgroundColor"), new BackgroundAction()));
    submenu.add(editor.bind(mxResources.get("backgroundImage"), new BackgroundImageAction()));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("pageBackground"), new PageBackgroundAction()));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("grid")));

    submenu.add(editor.bind(mxResources.get("gridSize"), new PromptPropertyAction(graph, "Grid Size", "GridSize")));
    submenu.add(editor.bind(mxResources.get("gridColor"), new GridColorAction()));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("dashed"), new GridStyleAction(mxGraphComponent.GRID_STYLE_DASHED)));
    submenu.add(editor.bind(mxResources.get("dot"), new GridStyleAction(mxGraphComponent.GRID_STYLE_DOT)));
    submenu.add(editor.bind(mxResources.get("line"), new GridStyleAction(mxGraphComponent.GRID_STYLE_LINE)));
    submenu.add(editor.bind(mxResources.get("cross"), new GridStyleAction(mxGraphComponent.GRID_STYLE_CROSS)));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("layout")));

    submenu.add(editor.graphLayout("verticalHierarchical", true));
    submenu.add(editor.graphLayout("horizontalHierarchical", true));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("verticalPartition", false));
    submenu.add(editor.graphLayout("horizontalPartition", false));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("verticalStack", false));
    submenu.add(editor.graphLayout("horizontalStack", false));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("verticalTree", true));
    submenu.add(editor.graphLayout("horizontalTree", true));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("placeEdgeLabels", false));
    submenu.add(editor.graphLayout("parallelEdges", false));

    submenu.addSeparator();

    submenu.add(editor.graphLayout("organicLayout", true));
    submenu.add(editor.graphLayout("circleLayout", true));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("selection")));

    submenu.add(editor.bind(mxResources.get("selectPath"), new SelectShortestPathAction(false)));
    submenu.add(editor.bind(mxResources.get("selectDirectedPath"), new SelectShortestPathAction(true)));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("selectTree"), new SelectSpanningTreeAction(false)));
    submenu.add(editor.bind(mxResources.get("selectDirectedTree"), new SelectSpanningTreeAction(true)));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("stylesheet")));

    submenu.add(editor.bind(mxResources.get("basicStyle"),
        new StylesheetAction("/com/mxgraph/examples/swing/resources/basic-style.xml")));
    submenu.add(editor.bind(mxResources.get("defaultStyle"), new StylesheetAction(
        "/com/mxgraph/examples/swing/resources/default-style.xml")));

    // Creates the options menu
    menu = add(new JMenu(mxResources.get("options")));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("display")));
    submenu.add(new TogglePropertyItem(graphComponent, mxResources.get("buffering"), "TripleBuffered", true));

    submenu.add(new TogglePropertyItem(graphComponent, mxResources.get("preferPageSize"), "PreferPageSize", true, new ActionListener()
    {
      /**
       *
       */
      public void actionPerformed(ActionEvent e)
      {
        graphComponent.zoomAndCenter();
      }
    }));

    // TODO: This feature is not yet implemented
    //submenu.add(new TogglePropertyItem(graphComponent, mxResources
    //    .get("pageBreaks"), "PageBreaksVisible", true));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("tolerance"), new PromptPropertyAction(graphComponent, "Tolerance")));

    submenu.add(editor.bind(mxResources.get("dirty"), new ToggleDirtyAction()));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("zoom")));

    submenu.add(new TogglePropertyItem(graphComponent, mxResources.get("centerZoom"), "CenterZoom", true));
    submenu.add(new TogglePropertyItem(graphComponent, mxResources.get("zoomToSelection"), "KeepSelectionVisibleOnZoom", true));

    submenu.addSeparator();

    submenu.add(new TogglePropertyItem(graphComponent, mxResources.get("centerPage"), "CenterPage", true, new ActionListener()
    {
      /**
       *
       */
      public void actionPerformed(ActionEvent e)
      {
        if (graphComponent.isPageVisible() && graphComponent.isCenterPage())
        {
          graphComponent.zoomAndCenter();
        }
      }
    }));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("dragAndDrop")));

    submenu.add(new TogglePropertyItem(graphComponent, mxResources.get("dragEnabled"), "DragEnabled"));
    submenu.add(new TogglePropertyItem(graph, mxResources.get("dropEnabled"), "DropEnabled"));

    submenu.addSeparator();

    submenu.add(new TogglePropertyItem(graphComponent.getGraphHandler(), mxResources.get("imagePreview"), "ImagePreview"));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("labels")));

    submenu.add(new TogglePropertyItem(graph, mxResources.get("htmlLabels"), "HtmlLabels", true));
    submenu.add(new TogglePropertyItem(graph, mxResources.get("showLabels"), "LabelsVisible", true));

    submenu.addSeparator();

    submenu.add(new TogglePropertyItem(graph, mxResources.get("moveEdgeLabels"), "EdgeLabelsMovable"));
    submenu.add(new TogglePropertyItem(graph, mxResources.get("moveVertexLabels"), "VertexLabelsMovable"));

    submenu.addSeparator();

    submenu.add(new TogglePropertyItem(graphComponent, mxResources.get("handleReturn"), "EnterStopsCellEditing"));

    menu.addSeparator();

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("connections")));

    submenu.add(new TogglePropertyItem(graphComponent, mxResources.get("connectable"), "Connectable"));
    submenu.add(new TogglePropertyItem(graph, mxResources.get("connectableEdges"), "ConnectableEdges"));

    submenu.addSeparator();

    submenu.add(new ToggleCreateTargetItem(editor, mxResources.get("createTarget")));
    submenu.add(new TogglePropertyItem(graph, mxResources.get("disconnectOnMove"), "DisconnectOnMove"));

    submenu.addSeparator();

    submenu.add(editor.bind(mxResources.get("connectMode"), new ToggleConnectModeAction()));

    submenu = (JMenu) menu.add(new JMenu(mxResources.get("validation")));

    submenu.add(new TogglePropertyItem(graph, mxResources.get("allowDanglingEdges"), "AllowDanglingEdges"));
    submenu.add(new TogglePropertyItem(graph, mxResources.get("cloneInvalidEdges"), "CloneInvalidEdges"));

    submenu.addSeparator();

    submenu.add(new TogglePropertyItem(graph, mxResources.get("allowLoops"), "AllowLoops"));
    submenu.add(new TogglePropertyItem(graph, mxResources.get("multigraph"), "Multigraph"));

    // Creates the window menu
    menu = add(new JMenu(mxResources.get("window")));

    UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.