Esempio n. 1
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);
 }
Esempio n. 2
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;
 }
 private void drawScreenFrame(Graphics2D g2d, int scrId) {
   g2d.setColor(screenFrameColor);
   g2d.setStroke(strokeScreenFrame);
   if (screenFrame == null) {
     screenFrame = Screen.getBounds(scrId);
     Rectangle ubound = scrOCP.getBounds();
     screenFrame.x -= ubound.x;
     screenFrame.y -= ubound.y;
     int sw = (int) (strokeScreenFrame.getLineWidth() / 2);
     screenFrame.x += sw;
     screenFrame.y += sw;
     screenFrame.width -= sw * 2;
     screenFrame.height -= sw * 2;
   }
   g2d.draw(screenFrame);
 }
Esempio n. 4
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;
  }