Package com.mxgraph.swing

Examples of com.mxgraph.swing.mxGraphComponent


     */
    public void actionPerformed(ActionEvent e)
    {
      if (e.getSource() instanceof mxGraphComponent)
      {
        mxGraphComponent graphComponent = (mxGraphComponent) e
            .getSource();
        String value = (String) JOptionPane.showInputDialog(
            graphComponent, mxResources.get("backgroundImage"),
            "URL", JOptionPane.PLAIN_MESSAGE, null, null,
            "http://www.callatecs.com/images/background2.JPG");

        if (value != null)
        {
          if (value.length() == 0)
          {
            graphComponent.setBackgroundImage(null);
          }
          else
          {
            Image background = mxUtils.loadImage(value);
            // Incorrect URLs will result in no image.
            // TODO provide feedback that the URL is not correct
            if (background != null)
            {
              graphComponent.setBackgroundImage(new ImageIcon(
                  background));
            }
          }

          // Forces a repaint of the outline
          graphComponent.getGraph().repaint();
        }
      }
    }
View Full Code Here


     */
    public void actionPerformed(ActionEvent e)
    {
      if (e.getSource() instanceof mxGraphComponent)
      {
        mxGraphComponent graphComponent = (mxGraphComponent) e
            .getSource();
        Color newColor = JColorChooser.showDialog(graphComponent,
            mxResources.get("background"), null);

        if (newColor != null)
        {
          graphComponent.getViewport().setOpaque(true);
          graphComponent.getViewport().setBackground(newColor);
        }

        // Forces a repaint of the outline
        graphComponent.getGraph().repaint();
      }
    }
View Full Code Here

     */
    public void actionPerformed(ActionEvent e)
    {
      if (e.getSource() instanceof mxGraphComponent)
      {
        mxGraphComponent graphComponent = (mxGraphComponent) e
            .getSource();
        mxGraph graph = graphComponent.getGraph();
        mxIGraphModel model = graph.getModel();

        Object parent = graph.getDefaultParent();
        Object[] cells = graph.getSelectionCells();

View Full Code Here

     */
    public void actionPerformed(ActionEvent e)
    {
      if (e.getSource() instanceof mxGraphComponent)
      {
        mxGraphComponent graphComponent = (mxGraphComponent) e
            .getSource();
        graphComponent.showDirtyRectangle = !graphComponent.showDirtyRectangle;
      }
    }
View Full Code Here

     */
    public void actionPerformed(ActionEvent e)
    {
      if (e.getSource() instanceof mxGraphComponent)
      {
        mxGraphComponent graphComponent = (mxGraphComponent) e
            .getSource();
        mxConnectionHandler handler = graphComponent
            .getConnectionHandler();
        handler.setHandleEnabled(!handler.isHandleEnabled());
      }
    }
View Full Code Here

        /**
         *
         */
        public void actionPerformed(ActionEvent e)
        {
          mxGraphComponent graphComponent = editor
              .getGraphComponent();

          if (graphComponent != null)
          {
            mxConnectionHandler handler = graphComponent
                .getConnectionHandler();
            handler.setCreateTarget(!handler.isCreateTarget());
            setSelected(handler.isCreateTarget());
          }
        }
View Full Code Here

      }

      // Repaints the graph component
      if (e.getSource() instanceof mxGraphComponent)
      {
        mxGraphComponent graphComponent = (mxGraphComponent) e
            .getSource();
        graphComponent.repaint();
      }
    }
View Full Code Here

     */
    public void actionPerformed(ActionEvent e)
    {
      if (e.getSource() instanceof mxGraphComponent)
      {
        mxGraphComponent graphComponent = (mxGraphComponent) e
            .getSource();
        Component editorComponent = null;

        if (graphComponent.getCellEditor() instanceof mxCellEditor)
        {
          editorComponent = ((mxCellEditor) graphComponent
              .getCellEditor()).getEditor();
        }

        if (editorComponent instanceof JEditorPane)
        {
          JEditorPane editorPane = (JEditorPane) editorComponent;
          int start = editorPane.getSelectionStart();
          int ende = editorPane.getSelectionEnd();
          String text = editorPane.getSelectedText();

          if (text == null)
          {
            text = "";
          }

          try
          {
            HTMLEditorKit editorKit = new HTMLEditorKit();
            HTMLDocument document = (HTMLDocument) editorPane
                .getDocument();
            document.remove(start, (ende - start));
            editorKit.insertHTML(document, start, ((bold) ? "<b>"
                : "<i>") + text + ((bold) ? "</b>" : "</i>"),
                0, 0, (bold) ? HTML.Tag.B : HTML.Tag.I);
          }
          catch (Exception ex)
          {
            ex.printStackTrace();
          }

          editorPane.requestFocus();
          editorPane.select(start, ende);
        }
        else
        {
          mxIGraphModel model = graphComponent.getGraph().getModel();
          model.beginUpdate();
          try
          {
            graphComponent.stopEditing(false);
            graphComponent.getGraph().toggleCellStyleFlags(
                mxConstants.STYLE_FONTSTYLE,
                (bold) ? mxConstants.FONT_BOLD
                    : mxConstants.FONT_ITALIC);
          }
          finally
View Full Code Here

     */
    public void actionPerformed(ActionEvent e)
    {
      if (e.getSource() instanceof mxGraphComponent)
      {
        mxGraphComponent graphComponent = (mxGraphComponent) e
            .getSource();
        Object[] cells = graphComponent.getGraph().getSelectionCells();

        if (cells != null && cells.length > 0)
        {
          String warning = JOptionPane.showInputDialog(mxResources
              .get("enterWarningMessage"));

          for (int i = 0; i < cells.length; i++)
          {
            graphComponent.setCellWarning(cells[i], warning);
          }
        }
        else
        {
          JOptionPane.showMessageDialog(graphComponent,
View Full Code Here

    finally
    {
      graph.getModel().endUpdate();
    }

    mxGraphComponent graphComponent = new mxGraphComponent(graph);
   
    return graphComponent;
  }
View Full Code Here

TOP

Related Classes of com.mxgraph.swing.mxGraphComponent

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.