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);
  }
  private void setVertexColor(Object vertex, Color color) {

    DefaultGraphCell cell = m_jgAdapter.getVertexCell(vertex);
    AttributeMap attr = cell.getAttributes();

    GraphConstants.setBackground(attr, color);

    AttributeMap cellAttr = new AttributeMap();

    cellAttr.put(cell, attr);

    m_jgAdapter.edit(cellAttr, null, null, null);
  }
Exemple #3
0
 public java.awt.Component getRendererComponent(JGraph jg, boolean b1, boolean b2, boolean b3) {
   CellViewRenderer renderer = null;
   try {
     ingenias.editor.entities.GTPursues ent =
         (ingenias.editor.entities.GTPursues) ((DefaultGraphCell) this.getCell()).getUserObject();
     this.renderer1.setEntity(ent);
     JPanel uop = (JPanel) this.renderer1.getRendererComponent(null, null, false, false, false);
     if (ent.getPrefs().getView() == ingenias.editor.entities.ViewPreferences.ViewType.LABEL) {
       NAryEdge naryedge = (NAryEdge) this.getCell();
       DefaultEdge[] edge = naryedge.getRepresentation();
       AttributeMap am = edge[0].getAttributes();
       GraphConstants.setLabelAlongEdge(am, true);
       GraphConstants.setExtraLabels(am, new Object[] {ent.getLabel()});
       GraphConstants.setExtraLabelPositions(
           am, new Point2D[] {new Point2D.Double(GraphConstants.PERMILLE * 7 / 8, -20)});
       edge[0].setAttributes(am);
     }
     return (Component) uop;
   } catch (Exception e) {
     e.printStackTrace();
     ingenias.editor.Log.getInstance().log("WARNING!!!" + e.getMessage());
   }
   return super.getRendererComponent(jg, b1, b2, b3);
 }
  /**
   * 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;
  }
  /**
   * Creates and returns a map of attributes to be used as defaults for edge attributes, depending
   * on the specified graph.
   *
   * @param jGraphTGraph the graph for which default edge attributes to be created.
   * @return a map of attributes to be used as default for edge attributes.
   */
  public static <V, E> AttributeMap createDefaultEdgeAttributes(Graph<V, E> jGraphTGraph) {
    AttributeMap map = new AttributeMap();

    if (jGraphTGraph instanceof DirectedGraph<?, ?>) {
      GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
      GraphConstants.setEndFill(map, true);
      GraphConstants.setEndSize(map, 10);
    }

    GraphConstants.setForeground(map, Color.decode("#25507C"));
    GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont(Font.BOLD, 12));
    GraphConstants.setLineColor(map, Color.decode("#7AA1E6"));

    return map;
  }