예제 #1
0
  /**
   * Build a shape for the entire subtree by joining together the shapes for each of its edges.
   * Vertices included since needed for FullTextPanel.
   */
  public Shape constructInternalShape(DiagramBase diagram, boolean includeVertices) {
    GeneralPath shape = new GeneralPath();
    Enumeration edges = m_edgeList.elements();
    while (edges.hasMoreElements()) {
      TreeEdge edge = (TreeEdge) edges.nextElement();
      Shape edgeShape = edge.getSchemeShape(diagram);
      PathIterator path = edgeShape.getPathIterator(null);
      shape.append(path, false);

      if (includeVertices) {
        Shape vertexShape;
        if (!edge.getSourceVertex().isVirtual()) {
          vertexShape = edge.getSourceVertex().getShape(diagram);
          path = vertexShape.getPathIterator(null);
          shape.append(path, false);
        }
        if (!edge.getDestVertex().isVirtual()) {
          vertexShape = edge.getDestVertex().getShape(diagram);
          path = vertexShape.getPathIterator(null);
          shape.append(path, false);
        }
      }
    }
    BasicStroke stroke =
        new BasicStroke(
            diagram.getSubtreeLineWidth() - DiagramBase.EDGE_OUTLINE_WIDTH + 1,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_MITER);
    internalShapeTable.put(diagram, stroke.createStrokedShape(shape));
    return (Shape) internalShapeTable.get(diagram);
  }
예제 #2
0
 private void writePathElement(IXMLElement parent, SVGPathFigure f) throws IOException {
     GrowStroke growStroke = new GrowStroke((float) (getStrokeTotalWidth(f) / 2d), (float) getStrokeTotalWidth(f));
     BasicStroke basicStroke = new BasicStroke((float) getStrokeTotalWidth(f));
     for (Figure child : f.getChildren()) {
         SVGBezierFigure bezier = (SVGBezierFigure) child;
         IXMLElement elem = parent.createElement("area");
         if (bezier.isClosed()) {
             writePolyAttributes(elem, f, growStroke.
                     createStrokedShape(bezier.getBezierPath())
                     );
         } else {
             writePolyAttributes(elem, f, basicStroke.
                     createStrokedShape(bezier.getBezierPath())
                     );
         }
         parent.addChild(elem);
     }
 }
예제 #3
0
 /** Build a shape for the entire subtree by joining together the shapes for each of its edges. */
 public Shape constructShape(DiagramBase diagram) {
   GeneralPath shape = new GeneralPath();
   Enumeration edges = m_edgeList.elements();
   while (edges.hasMoreElements()) {
     TreeEdge edge = (TreeEdge) edges.nextElement();
     if (!edge.visible) {
       continue;
     }
     Shape edgeShape = edge.getSchemeShape(diagram);
     PathIterator path = edgeShape.getPathIterator(null);
     shape.append(path, false);
   }
   BasicStroke stroke =
       new BasicStroke(
           diagram.getSubtreeLineWidth(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER);
   shapeTable.put(diagram, stroke.createStrokedShape(shape));
   return (Shape) shapeTable.get(diagram);
 }
예제 #4
0
 public void drawDashedLine(int d, int x1, int y1, int x2, int y2) {
   Stroke s = getStroke();
   float w = 1;
   int c = BasicStroke.CAP_BUTT;
   int j = BasicStroke.JOIN_MITER;
   float ml = 0;
   float[] dp = {d, d};
   if (s instanceof BasicStroke) {
     BasicStroke b = (BasicStroke) s;
     w = b.getLineWidth();
     c = b.getEndCap();
     j = b.getLineJoin();
     ml = b.getMiterLimit();
   }
   setStroke(new BasicStroke(w, c, j, ml, dp, 0));
   drawLine(x1, y1, x2, y2);
   setStroke(s);
 }
예제 #5
0
 /*
  * Creates a line of width EDGE_SELECT_WIDTH for each edge
  * and tests if mouse click was in that Shape's boundary.
  * Returns the edge if one was selected, null otherwise.
  */
 public TreeEdge testEdgeShapes(MouseEvent event) {
   if (argument == null || argument.getTree() == null) return null;
   double x = event.getX();
   double y = event.getY();
   BasicStroke edgeWidth = new BasicStroke(EDGE_SELECT_WIDTH);
   if (argument.getBreadthFirstTraversal() == null) return null;
   Enumeration nodeList = argument.getBreadthFirstTraversal().elements();
   while (nodeList.hasMoreElements()) {
     TreeVertex vertex = (TreeVertex) nodeList.nextElement();
     if (argument.isMultiRoots() && vertex.getLayer() == 0) continue;
     Enumeration edges = vertex.getEdgeList().elements();
     while (edges.hasMoreElements()) {
       TreeEdge edge = (TreeEdge) edges.nextElement();
       Shape shape = edge.getShape(this);
       Shape wideEdge = edgeWidth.createStrokedShape(shape);
       TreeVertex child = edge.getDestVertex();
       if (wideEdge.contains(x, y)) {
         edge.setSelected(!edge.isSelected());
         return edge;
       }
     }
   }
   return null;
 }
예제 #6
0
 /** Build a shape for the entire subtree by joining together the shapes for each of its edges. */
 public Shape constructFullTextShape(DiagramBase diagram) {
   GeneralPath shape = new GeneralPath();
   Enumeration edges = m_edgeList.elements();
   while (edges.hasMoreElements()) {
     TreeEdge edge = (TreeEdge) edges.nextElement();
     if (!edge.visible) {
       continue;
     }
     Shape edgeShape = edge.getSchemeShape(diagram);
     PathIterator path = edgeShape.getPathIterator(null);
     shape.append(path, false);
     TreeVertex vertex = edge.getSourceVertex();
     if (!vertex.isVirtual()) {
       shape.append(vertex.getShape(diagram).getPathIterator(null), false);
     }
     vertex = edge.getDestVertex();
     if (!vertex.isVirtual()) {
       shape.append(vertex.getShape(diagram).getPathIterator(null), false);
     }
   }
   BasicStroke stroke = new BasicStroke(20, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER);
   shapeTable.put(diagram, stroke.createStrokedShape(shape));
   return (Shape) shapeTable.get(diagram);
 }
예제 #7
0
  /** [Internal] */
  public String obj2str(Object o) {
    if (o == null) return "-null-";
    String s = "";
    if (o instanceof Object[]) {
      Object[] a = (Object[]) o;
      for (Object ox : a) s = s + " " + ox;
    } else if (o instanceof BasicStroke) {
      BasicStroke o1 = (BasicStroke) o;
      s =
          "BasicStroke("
              + o1.getLineWidth()
              + ","
              + o1.getDashPhase()
              + ","
              + o1.getLineJoin()
              + ","
              + o1.getMiterLimit()
              + ","
              + o1.getEndCap();

    } else s = "" + o;
    return s;
  }