Examples of GeneralPath


Examples of java.awt.geom.GeneralPath

    // Check pieces rotation
    assertEquals("Piece angle is wrong", angle, piece1.getAngle());
    assertEquals("Piece angle is wrong", angle, piece2.getAngle());
    assertEquals("Group angle is wrong", angle, group.getAngle());
    // Check surrounding rectangles
    Rectangle2D rotatedGroupRectangle = new GeneralPath(groupRectangle).createTransformedShape(
        AffineTransform.getRotateInstance(angle, groupRectangle.getCenterX(), groupRectangle.getCenterY())).getBounds2D();
    groupRectangle = getSurroundingRectangle(group);
    assertEquals("Surrounding rectangle is incorrect", rotatedGroupRectangle, groupRectangle);
    piecesRectangle = getSurroundingRectangle(piece1);
    piecesRectangle.add(getSurroundingRectangle(piece2));
View Full Code Here

Examples of java.awt.geom.GeneralPath

    if (this.roomPathsCache == null) {
      // Iterate over all the paths the walls area contains
      List<GeneralPath> roomPaths = new ArrayList<GeneralPath>();
      Area wallsArea = getWallsArea();
      Area insideWallsArea = new Area(wallsArea);
      GeneralPath roomPath = new GeneralPath();
      for (PathIterator it = wallsArea.getPathIterator(null, 0.5f); !it.isDone(); ) {
        float [] roomPoint = new float[2];
        switch (it.currentSegment(roomPoint)) {
          case PathIterator.SEG_MOVETO :
            roomPath.moveTo(roomPoint [0], roomPoint [1]);
            break;
          case PathIterator.SEG_LINETO :
            roomPath.lineTo(roomPoint [0], roomPoint [1]);
            break;
          case PathIterator.SEG_CLOSE :
            roomPath.closePath();
            insideWallsArea.add(new Area(roomPath));             
            roomPaths.add(roomPath);
            roomPath = new GeneralPath();
            break;
        }
        it.next();       
      }
     
View Full Code Here

Examples of java.awt.geom.GeneralPath

 
  /**
   * Returns the shape matching the coordinates in <code>points</code> array.
   */
  private GeneralPath getPath(float [][] points) {
    GeneralPath path = new GeneralPath();
    path.moveTo(points [0][0], points [0][1]);
    for (int i = 1; i < points.length; i++) {
      path.lineTo(points [i][0], points [i][1]);
    }
    path.closePath();
    return path;
  }
View Full Code Here

Examples of java.awt.geom.GeneralPath

  /**
   * Returns the path matching a given area.
   */
  private GeneralPath getPath(Area area) {
    GeneralPath path = new GeneralPath();
    float [] point = new float [2];
    for (PathIterator it = area.getPathIterator(null, 0.5f); !it.isDone(); ) {
      switch (it.currentSegment(point)) {
        case PathIterator.SEG_MOVETO :
          path.moveTo(point [0], point [1]);
          break;
        case PathIterator.SEG_LINETO :
          path.lineTo(point [0], point [1]);
          break;
      }
      it.next();
    }
    return path;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.