Package org.jgraph.graph

Examples of org.jgraph.graph.AttributeMap$SerializableRectangle2D


   */
  public static void addSampleData(GraphModel model) {
    ConnectionSet cs = new ConnectionSet();
    Map attributes = new Hashtable();
    // Styles For Implement/Extend/Aggregation
    AttributeMap implementStyle = new AttributeMap();
    GraphConstants.setLineBegin(implementStyle,
        GraphConstants.ARROW_TECHNICAL);
    GraphConstants.setBeginSize(implementStyle, 10);
    GraphConstants.setDashPattern(implementStyle, new float[] { 3, 3 });
    GraphConstants.setFont(implementStyle, GraphConstants.DEFAULTFONT
        .deriveFont(10));
    AttributeMap extendStyle = new AttributeMap();
    GraphConstants
        .setLineBegin(extendStyle, GraphConstants.ARROW_TECHNICAL);
    GraphConstants.setBeginFill(extendStyle, true);
    GraphConstants.setBeginSize(extendStyle, 10);
    GraphConstants.setFont(extendStyle, GraphConstants.DEFAULTFONT
        .deriveFont(10));
    AttributeMap aggregateStyle = new AttributeMap();
    GraphConstants.setLineBegin(aggregateStyle,
        GraphConstants.ARROW_DIAMOND);
    GraphConstants.setBeginFill(aggregateStyle, true);
    GraphConstants.setBeginSize(aggregateStyle, 6);
    GraphConstants.setLineEnd(aggregateStyle, GraphConstants.ARROW_SIMPLE);
    GraphConstants.setEndSize(aggregateStyle, 8);
    GraphConstants.setLabelPosition(aggregateStyle, new Point(500, 1200));
    GraphConstants.setFont(aggregateStyle, GraphConstants.DEFAULTFONT
        .deriveFont(10));
    //
    // The Swing MVC Pattern
    //
    // Model Column
    DefaultGraphCell gm = new DefaultGraphCell("GraphModel");
    attributes.put(gm,
        createBounds(new AttributeMap(), 20, 100, Color.blue));
    gm.add(new DefaultPort("GraphModel/Center"));
    DefaultGraphCell dgm = new DefaultGraphCell("DefaultGraphModel");
    attributes.put(dgm, createBounds(new AttributeMap(), 20, 180,
        Color.blue));
    dgm.add(new DefaultPort("DefaultGraphModel/Center"));
    DefaultEdge dgmImplementsGm = new DefaultEdge("implements");
    cs.connect(dgmImplementsGm, gm.getChildAt(0), dgm.getChildAt(0));
    attributes.put(dgmImplementsGm, implementStyle);
    DefaultGraphCell modelGroup = new DefaultGraphCell("ModelGroup");
    modelGroup.add(gm);
    modelGroup.add(dgm);
    modelGroup.add(dgmImplementsGm);
    // JComponent Column
    DefaultGraphCell jc = new DefaultGraphCell("JComponent");
    attributes.put(jc, createBounds(new AttributeMap(), 150, 20,
        Color.green));
    jc.add(new DefaultPort("JComponent/Center"));
    DefaultGraphCell jg = new DefaultGraphCell("JGraph");
    attributes.put(jg, createBounds(new AttributeMap(), 150, 100,
        Color.green));
    jg.add(new DefaultPort("JGraph/Center"));
    DefaultEdge jgExtendsJc = new DefaultEdge("extends");
    cs.connect(jgExtendsJc, jc.getChildAt(0), jg.getChildAt(0));
    attributes.put(jgExtendsJc, extendStyle);
    // UI Column
    DefaultGraphCell cu = new DefaultGraphCell("ComponentUI");
    attributes
        .put(cu, createBounds(new AttributeMap(), 280, 20, Color.red));
    cu.add(new DefaultPort("ComponentUI/Center"));
    DefaultGraphCell gu = new DefaultGraphCell("GraphUI");
    attributes.put(gu,
        createBounds(new AttributeMap(), 280, 100, Color.red));
    gu.add(new DefaultPort("GraphUI/Center"));
    DefaultGraphCell dgu = new DefaultGraphCell("BasicGraphUI");
    attributes.put(dgu, createBounds(new AttributeMap(), 280, 180,
        Color.red));
    dgu.add(new DefaultPort("BasicGraphUI/Center"));
    DefaultEdge guExtendsCu = new DefaultEdge("extends");
    cs.connect(guExtendsCu, cu.getChildAt(0), gu.getChildAt(0));
    attributes.put(guExtendsCu, extendStyle);
View Full Code Here


  public void updateAutoSize(CellView view) {
    if (view != null && !isEditing()) {
      Rectangle2D bounds = (view.getAttributes() != null) ? GraphConstants
          .getBounds(view.getAttributes())
          : null;
      AttributeMap attrs = getModel().getAttributes(view.getCell());
      if (bounds == null)
        bounds = GraphConstants.getBounds(attrs);
      if (bounds != null) {
        boolean autosize = GraphConstants.isAutoSize(view
            .getAllAttributes());
        boolean resize = GraphConstants.isResize(view
            .getAllAttributes());
        if (autosize || resize) {
          Dimension2D d = getUI().getPreferredSize(this, view);
          bounds.setFrame(bounds.getX(), bounds.getY(), d.getWidth(),
              d.getHeight());
          // Remove resize attribute
          snap(bounds);
          if (resize) {
            if (view.getAttributes() != null)
              view.getAttributes().remove(GraphConstants.RESIZE);
            attrs.remove(GraphConstants.RESIZE);
          }
          view.refresh(getModel(), getGraphLayoutCache(), false);
        }
      }
    }
View Full Code Here

   * Returns the attributes for the specified cell. If the layout cache
   * returns a view for the cell then this method returns allAttributes,
   * otherwise the method returns model.getAttributes(cell).
   */
  public AttributeMap getAttributes(Object cell) {
    AttributeMap attrs;
    CellView cellView = getGraphLayoutCache().getMapping(cell, false);
    if (cellView != null) {
      attrs = cellView.getAllAttributes();
    } else {
      attrs = getModel().getAttributes(cell);
View Full Code Here

   
    //jGraphMain.set
    DefaultGraphCell wsCell=findNode(name);
    jGraphMain.startEditingAtCell(wsCell);
    if(wsCell!=null){
      AttributeMap attribs = wsCell.getAttributes();
      attribs.put("gradientColor",color);
      wsCell.changeAttributes(attribs);
      System.err.println("SetColor "+name+" "+color);
    }
    jGraphMain.stopEditing();
    jGraphMain.clearSelection();
View Full Code Here

   * @param x x coordinate
   * @param y y coordinate
   */
  protected void positionVertexAt(Object vertex, int x, int y) {
    DefaultGraphCell cell = jgAdapter.getVertexCell(vertex);
    AttributeMap attr = cell.getAttributes();
    Rectangle2D bounds = GraphConstants.getBounds(attr);

    positionVertexAt(vertex, x, y, bounds.getWidth(), bounds.getHeight());
  }
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  protected void positionVertexAt(Object vertex, int x, int y, double width,
      double height) {
    DefaultGraphCell cell = jgAdapter.getVertexCell(vertex);
    AttributeMap attr = cell.getAttributes();

    Rectangle2D newBounds = new Rectangle2D.Double(x, y, width, height);

    GraphConstants.setBounds(attr, newBounds);

    // TODO: Clean up generics once JGraph goes generic
    AttributeMap cellAttr = new AttributeMap();
    cellAttr.put(cell, attr);
    jgAdapter.edit(cellAttr, null, null, null);
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private void addAgentToVis(String name, String host) {
   
    directedGraph.addVertex(name);
    DefaultGraphCell dgc = jgAdapter.getVertexCell(host);
    AttributeMap cellAttr = dgc.getAttributes();
    Rectangle2D rect = GraphConstants.getBounds(cellAttr);
    positionVertexAt(name, (int) (rect.getX() + (agentsOnVis - 1)
        * agentWidth), (int) rect.getCenterY(), agentWidth, 20);
  }
View Full Code Here

    }

    private void positionVertexAt(Object vertex, int x, int y)
    {
        DefaultGraphCell cell = jgAdapter.getVertexCell(vertex);
        AttributeMap attr = cell.getAttributes();
        Rectangle2D bounds = GraphConstants.getBounds(attr);

        Rectangle2D newBounds =
                new Rectangle2D.Double(
                x,
                y,
                bounds.getWidth() + 50,
                bounds.getHeight());

        GraphConstants.setBounds(attr, newBounds);



        // TODO: Clean up generics once JGraph goes generic
        AttributeMap cellAttr = new AttributeMap();
        cellAttr.put(cell, attr);
        jgAdapter.edit(cellAttr, null, null, null);
    }
View Full Code Here

   */
  public static void addSampleData(GraphModel model) {
    ConnectionSet cs = new ConnectionSet();
    Map attributes = new Hashtable();
    // Styles For Implement/Extend/Aggregation
    AttributeMap implementStyle = new AttributeMap();
    GraphConstants.setLineBegin(implementStyle,
        GraphConstants.ARROW_TECHNICAL);
    GraphConstants.setBeginSize(implementStyle, 10);
    GraphConstants.setDashPattern(implementStyle, new float[] { 3, 3 });
    GraphConstants.setFont(implementStyle, GraphConstants.DEFAULTFONT
        .deriveFont(10));
    AttributeMap extendStyle = new AttributeMap();
    GraphConstants
        .setLineBegin(extendStyle, GraphConstants.ARROW_TECHNICAL);
    GraphConstants.setBeginFill(extendStyle, true);
    GraphConstants.setBeginSize(extendStyle, 10);
    GraphConstants.setFont(extendStyle, GraphConstants.DEFAULTFONT
        .deriveFont(10));
    AttributeMap aggregateStyle = new AttributeMap();
    GraphConstants.setLineBegin(aggregateStyle,
        GraphConstants.ARROW_DIAMOND);
    GraphConstants.setBeginFill(aggregateStyle, true);
    GraphConstants.setBeginSize(aggregateStyle, 6);
    GraphConstants.setLineEnd(aggregateStyle, GraphConstants.ARROW_SIMPLE);
    GraphConstants.setEndSize(aggregateStyle, 8);
    GraphConstants.setLabelPosition(aggregateStyle, new Point2D.Double(500,
        0));
    GraphConstants.setFont(aggregateStyle, GraphConstants.DEFAULTFONT
        .deriveFont(10));
    //
    // The Swing MVC Pattern
    //
    // Model Column
    DefaultGraphCell gm = new DefaultGraphCell("GraphModel");
    attributes.put(gm,
        createBounds(new AttributeMap(), 20, 100, Color.blue));
    gm.add(new DefaultPort("GraphModel/Center"));
    DefaultGraphCell dgm = new DefaultGraphCell("DefaultGraphModel");
    attributes.put(dgm, createBounds(new AttributeMap(), 20, 180,
        Color.blue));
    dgm.add(new DefaultPort("DefaultGraphModel/Center"));
    DefaultEdge dgmImplementsGm = new DefaultEdge("implements");
    cs.connect(dgmImplementsGm, gm.getChildAt(0), dgm.getChildAt(0));
    attributes.put(dgmImplementsGm, implementStyle);
    DefaultGraphCell modelGroup = new DefaultGraphCell("ModelGroup");
    modelGroup.add(gm);
    modelGroup.add(dgm);
    modelGroup.add(dgmImplementsGm);
    // JComponent Column
    DefaultGraphCell jc = new DefaultGraphCell("JComponent");
    attributes.put(jc, createBounds(new AttributeMap(), 180, 20,
        Color.green));
    jc.add(new DefaultPort("JComponent/Center"));
    DefaultGraphCell jg = new DefaultGraphCell("JGraph");
    attributes.put(jg, createBounds(new AttributeMap(), 180, 100,
        Color.green));
    jg.add(new DefaultPort("JGraph/Center"));
    DefaultEdge jgExtendsJc = new DefaultEdge("extends");
    cs.connect(jgExtendsJc, jc.getChildAt(0), jg.getChildAt(0));
    attributes.put(jgExtendsJc, extendStyle);
    // UI Column
    DefaultGraphCell cu = new DefaultGraphCell("ComponentUI");
    attributes
        .put(cu, createBounds(new AttributeMap(), 340, 20, Color.red));
    cu.add(new DefaultPort("ComponentUI/Center"));
    DefaultGraphCell gu = new DefaultGraphCell("GraphUI");
    attributes.put(gu,
        createBounds(new AttributeMap(), 340, 100, Color.red));
    gu.add(new DefaultPort("GraphUI/Center"));
    DefaultGraphCell dgu = new DefaultGraphCell("BasicGraphUI");
    attributes.put(dgu, createBounds(new AttributeMap(), 340, 180,
        Color.red));
    dgu.add(new DefaultPort("BasicGraphUI/Center"));
    DefaultEdge guExtendsCu = new DefaultEdge("extends");
    cs.connect(guExtendsCu, cu.getChildAt(0), gu.getChildAt(0));
    attributes.put(guExtendsCu, extendStyle);
View Full Code Here

  public void updateAutoSize(CellView view) {
    if (view != null && !isEditing()) {
      Rectangle2D bounds = (view.getAttributes() != null) ? GraphConstants
          .getBounds(view.getAttributes())
          : null;
      AttributeMap attrs = getModel().getAttributes(view.getCell());
      if (bounds == null)
        bounds = GraphConstants.getBounds(attrs);
      if (bounds != null) {
        boolean autosize = GraphConstants.isAutoSize(view
            .getAllAttributes());
        boolean resize = GraphConstants.isResize(view
            .getAllAttributes());
        if (autosize || resize) {
          Dimension2D d = getUI().getPreferredSize(this, view);
          bounds.setFrame(bounds.getX(), bounds.getY(), d.getWidth(),
              d.getHeight());
          // Remove resize attribute
          snap(bounds);
          if (resize) {
            if (view.getAttributes() != null)
              view.getAttributes().remove(GraphConstants.RESIZE);
            attrs.remove(GraphConstants.RESIZE);
          }
          view.refresh(getModel(), getGraphLayoutCache(), false);
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.jgraph.graph.AttributeMap$SerializableRectangle2D

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.