コード例 #1
0
ファイル: AreaMeta.java プロジェクト: edwardcd/maptool
  public void addPoint(float x, float y) {
    PointNode pointNode = new PointNode(new Point2D.Double(x, y));

    // Don't add if we haven't moved
    if (lastPointNode != null) {
      if (lastPointNode.point.equals(pointNode.point)) {
        return;
      }
    }
    if (path == null) {
      path = new GeneralPath();
      path.moveTo(x, y);

      pointNodeList = pointNode;
    } else {
      path.lineTo(x, y);

      lastPointNode.next = pointNode;
      pointNode.previous = lastPointNode;
    }
    lastPointNode = pointNode;
  }
コード例 #2
0
ファイル: AreaMeta.java プロジェクト: edwardcd/maptool
  public void close() {
    area = new Area(path);

    // Close the circle
    lastPointNode.next = pointNodeList;
    pointNodeList.previous = lastPointNode;
    lastPointNode = null;

    // For some odd reason, sometimes the first and last point are the same, which causes
    // bugs in the way areas are calculated
    if (pointNodeList.point.equals(pointNodeList.previous.point)) {
      // Pull out the dupe node
      PointNode trueLastPoint = pointNodeList.previous.previous;
      trueLastPoint.next = pointNodeList;
      pointNodeList.previous = trueLastPoint;
    }
    computeIsHole();
    computeFaces();

    // Don't need point list anymore
    pointNodeList = null;
    path = null;
  }