Beispiel #1
0
  public int getIndexOfNewPoint(int x, int y, int tol) {
    Rectangle rect = new Rectangle(x - tol / 2, y - tol / 2, tol, tol);
    List<mxPoint> pts = getAbsolutePoints();

    int length = pts.size();
    mxPoint start, end;
    start = pts.get(0);
    for (int i = 1; i < length; i++) {
      end = pts.get(i);
      if (rect.intersectsLine(start.getX(), start.getY(), end.getX(), end.getY())) return i;
      start = end;
    }
    return -1;
  }
Beispiel #2
0
 @Override
 public mxPoint paintMarker(
     mxGraphics2DCanvas canvas,
     mxCellState state,
     String type,
     mxPoint pe,
     double nx,
     double ny,
     double size,
     boolean source) {
   //		Polygon poly = new Polygon();
   //        poly.addPoint((int) Math.round(pe.getX()), (int) Math.round(pe.getY()));
   //        poly.addPoint((int) Math.round(pe.getX() - nx - ny / 2), (int) Math.round(pe.getY() -
   // ny + nx / 2));
   //        poly.addPoint((int) Math.round(pe.getX() + ny / 2 - nx), (int) Math.round(pe.getY() -
   // ny - nx / 2));
   //        canvas.getGraphics().draw(poly);
   //		Color prev = canvas.getGraphics().getColor();
   //		canvas.getGraphics().setColor(Color.white);
   //		canvas.getGraphics().fillOval( (int)(pe.getX() -nx - RADIUS), (int)(pe.getY() -ny - RADIUS),
   // RADIUS * 2 , RADIUS * 2);
   //		canvas.getGraphics().setColor(prev);
   System.out.println("RENDERING !!!");
   canvas
       .getGraphics()
       .drawOval(
           (int) (pe.getX() - nx - RADIUS),
           (int) (pe.getY() - ny - RADIUS),
           RADIUS * 2,
           RADIUS * 2);
   return new mxPoint(-nx, -ny);
 }
Beispiel #3
0
  /**
   * Draws the given lines as segments between all points of the given list of mxPoints.
   *
   * @param pts List of points that define the line.
   * @param style Style to be used for painting the line.
   */
  public void drawLine(List<mxPoint> pts, Map<String, Object> style) {
    String strokeColor = mxUtils.getString(style, mxConstants.STYLE_STROKECOLOR);
    int strokeWidth = (int) (mxUtils.getInt(style, mxConstants.STYLE_STROKEWIDTH, 1) * scale);

    if (strokeColor != null && strokeWidth > 0) {

      mxPoint last = pts.get(0);

      for (int i = 1; i < pts.size(); i++) {
        mxPoint pt = pts.get(i);

        drawSegment(
            (int) last.getX(),
            (int) last.getY(),
            (int) pt.getX(),
            (int) pt.getY(),
            strokeColor,
            strokeWidth);

        last = pt;
      }
    }
  }