private void positionVertexAt(Object vertex, int x, int y) {

    DefaultGraphCell cell = m_jgAdapter.getVertexCell(vertex);
    AttributeMap attr = cell.getAttributes();
    Rectangle2D b = GraphConstants.getBounds(attr);

    Rectangle2D newBounds = new Rectangle2D.Double(x, y, 5, 5);
    GraphConstants.setBounds(attr, newBounds);

    AttributeMap cellAttr = new AttributeMap();

    cellAttr.put(cell, attr);

    m_jgAdapter.edit(cellAttr, null, null, null);
  }
Example #2
0
  /**
   * Creates and returns a map of attributes to be used as defaults for vertex attributes.
   *
   * @return a map of attributes to be used as defaults for vertex attributes.
   */
  public static AttributeMap createDefaultVertexAttributes() {
    AttributeMap map = new AttributeMap();
    Color c = Color.decode("#FF9900");

    GraphConstants.setBounds(map, new Rectangle2D.Double(50, 50, 90, 30));
    GraphConstants.setBorder(map, BorderFactory.createRaisedBevelBorder());
    GraphConstants.setBackground(map, c);
    GraphConstants.setForeground(map, Color.white);
    GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont(Font.BOLD, 12));
    GraphConstants.setOpaque(map, true);

    return map;
  }