Beispiel #1
0
  /**
   * 创建连接线的相关属性
   *
   * @return
   */
  public Map createEdgeAttributes() {
    Map map = new Hashtable();
    // Add a Line End Attribute
    GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
    // Add a label along edge attribute
    GraphConstants.setLabelAlongEdge(map, false);
    GraphConstants.setEndFill(map, true);
    GraphConstants.setLineWidth(map, 1.0f);
    GraphConstants.setLineColor(map, Color.black);
    GraphConstants.setEditable(map, false);

    return map;
  }
  @Override
  public AttributeMap getDefaultEdgeAttributes() {
    AttributeMap map = new AttributeMap();

    GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
    GraphConstants.setEndFill(map, true);
    GraphConstants.setLabelAlongEdge(map, true);

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

    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;
  }