Examples of Area


Examples of java.awt.geom.Area

      textureCoords.add(new TexCoord2f(this.width / groundTexture.getWidth(), 0));
    }
    stripCounts.add(4);

    // Compute the union of the rooms
    Area roomsArea = new Area();
    for (Room room : home.getRooms()) {
      if (room.isFloorVisible()) {
        float [][] points = room.getPoints();
        if (points.length > 2) {
          roomsArea.add(new Area(getShape(points)));
        }
      }
    }

    // Retrieve points
    List<float [][]> roomParts = new ArrayList<float [][]>();
    List<float []>   roomPart  = new ArrayList<float[]>();
    float [] previousRoomPoint = null;
    for (PathIterator it = roomsArea.getPathIterator(null); !it.isDone(); ) {
      float [] roomPoint = new float[2];
      if (it.currentSegment(roomPoint) == PathIterator.SEG_CLOSE) {
        if (roomPart.get(0) [0] == previousRoomPoint [0]
            && roomPart.get(0) [1] == previousRoomPoint [1]) {
          roomPart.remove(roomPart.size() - 1);
View Full Code Here

Examples of java.awt.geom.Area

  /**
   * Returns the area of this room.
   */
  public float getArea() {
    if (this.areaCache == null) {
      Area roomArea = new Area(getShape());
      if (roomArea.isSingular()) {
        this.areaCache = Math.abs(getSignedArea(getPoints()));
      } else {
        // Add the surface of the different polygons of this room
        float area = 0;
        List<float []> currentPathPoints = new ArrayList<float[]>();
        for (PathIterator it = roomArea.getPathIterator(null); !it.isDone(); ) {
          float [] roomPoint = new float[2];
          switch (it.currentSegment(roomPoint)) {
            case PathIterator.SEG_MOVETO :
              currentPathPoints.add(roomPoint);
              break;
View Full Code Here

Examples of java.awt.geom.Area

 
  /**
   * Returns <code>true</code> if this room is comprised of only one polygon.
   */
  public boolean isSingular() {
    return new Area(getShape()).isSingular();
  }
View Full Code Here

Examples of java.awt.geom.Area

     */
    private Room createAndSelectRoom(float xStart, float yStart,
                                     float xEnd, float yEnd) {
      Room newRoom = createRoom(new float [][] {{xStart, yStart}, {xEnd, yEnd}});
      // Let's consider that points outside of home will create  by default a room with no ceiling
      Area insideWallsArea = getInsideWallsArea();
      newRoom.setCeilingVisible(insideWallsArea.contains(xStart, yStart));
      selectItem(newRoom);
      return newRoom;
    }
View Full Code Here

Examples of java.awt.geom.Area

              }               
            }
            if (intersectionCount == 2
                && doorPoints.length == 4) {
              // Find the intersection of the door with home walls
              Area wallsDoorIntersection = new Area(getWallsArea());
              wallsDoorIntersection.intersect(new Area(getPath(doorPoints)));
              // Reduce the size of intersection to its half
              float [][] intersectionPoints = getPathPoints(getPath(wallsDoorIntersection), false);
              Shape halfDoorPath = null;
              if (intersectionPoints.length == 4) {
                float epsilon = 0.05f;
                for (int i = 0; i < intersectionPoints.length; i++) {
                  // Check point in room with rectangle intersection test otherwise we miss some points
                  if (roomPath.intersects(intersectionPoints [i][0] - epsilon / 2,
                      intersectionPoints [i][1] - epsilon / 2, epsilon, epsilon)) {
                    int inPoint1 = i;
                    int inPoint2;
                    int outPoint1;
                    int outPoint2;
                    if (roomPath.intersects(intersectionPoints [i + 1][0] - epsilon / 2,
                             intersectionPoints [i + 1][1] - epsilon / 2, epsilon, epsilon)) {
                      inPoint2 = i + 1;
                      outPoint2 = (i + 2) % 4;
                      outPoint1 = (i + 3) % 4;
                    } else {
                      outPoint1 = (i + 1) % 4;
                      outPoint2 = (i + 2) % 4;
                      inPoint2 = (i + 3) % 4;
                    }
                    intersectionPoints [outPoint1][0] = (intersectionPoints [outPoint1][0]
                        + intersectionPoints [inPoint1][0]) / 2;
                    intersectionPoints [outPoint1][1] = (intersectionPoints [outPoint1][1]
                        + intersectionPoints [inPoint1][1]) / 2;
                    intersectionPoints [outPoint2][0] = (intersectionPoints [outPoint2][0]
                        + intersectionPoints [inPoint2][0]) / 2;
                    intersectionPoints [outPoint2][1] = (intersectionPoints [outPoint2][1]
                        + intersectionPoints [inPoint2][1]) / 2;
                   
                    GeneralPath path = getPath(intersectionPoints);
                    // Enlarge the intersection path to ensure its union with room builds only one path
                    AffineTransform transform = new AffineTransform();
                    Rectangle2D bounds2D = path.getBounds2D();                   
                    transform.translate(bounds2D.getCenterX(), bounds2D.getCenterY());
                    double min = Math.min(bounds2D.getWidth(), bounds2D.getHeight());
                    double scale = (min + epsilon) / min;
                    transform.scale(scale, scale);
                    transform.translate(-bounds2D.getCenterX(), -bounds2D.getCenterY());
                    halfDoorPath = path.createTransformedShape(transform);
                    break;
                  }
                }
              }               
             
              if (halfDoorPath != null) {
                Area halfDoorRoomUnion = new Area(halfDoorPath);
                halfDoorRoomUnion.add(new Area(roomPath));
                roomPath = getPath(halfDoorRoomUnion);
              }
            }
          }
         
View Full Code Here

Examples of java.awt.geom.Area

 
  /**
   * Returns an area matching the union of all <code>walls</code> shapes.
   */
  private Area getWallsArea(Collection<Wall> walls) {
    Area wallsArea = new Area();
    for (Wall wall : walls) {
      wallsArea.add(new Area(getShape(wall.getPoints())));
    }
    return wallsArea;
  }
View Full Code Here

Examples of java.awt.geom.Area

      float [][] points = camera.getPoints();
      double yScale = Point2D.distance(points [0][0], points [0][1], points [3][0], points [3][1]);
      double xScale = Point2D.distance(points [0][0], points [0][1], points [1][0], points [1][1]);
      cameraTransform.scale(xScale, yScale);   
      Shape scaledCameraBody =
          new Area(CAMERA_BODY).createTransformedArea(cameraTransform);
      Shape scaledCameraHead =
          new Area(CAMERA_HEAD).createTransformedArea(cameraTransform);
     
      // Paint body
      g2D.setPaint(backgroundColor);
      g2D.fill(scaledCameraBody);
      g2D.setPaint(foregroundColor);
      BasicStroke stroke = new BasicStroke(BORDER_STROKE_WIDTH / planScale);
      g2D.setStroke(stroke);
      g2D.draw(scaledCameraBody);
 
      if (selectedItems.contains(camera)
          && this.selectedItemsOutlinePainted) {
        g2D.setPaint(selectionOutlinePaint);
        g2D.setStroke(selectionOutlineStroke);
        Area cameraOutline = new Area(scaledCameraBody);
        cameraOutline.add(new Area(scaledCameraHead));
        g2D.draw(cameraOutline);     
      }
     
      // Paint head
      g2D.setPaint(backgroundColor);
View Full Code Here

Examples of java.awt.geom.Area

  /**
   * Returns the 2D area of the 3D shapes children of the given <code>node</code>
   * projected on the floor (plan y = 0).
   */
  public Area getAreaOnFloor(Node node) {
    Area modelAreaOnFloor;
    int vertexCount = getVertexCount(node);
    if (vertexCount < 10000) {
      modelAreaOnFloor = new Area();
      computeAreaOnFloor(node, modelAreaOnFloor, new Transform3D());
    } else {
      List<float []> vertices = new ArrayList<float[]>(vertexCount);
      computeVerticesOnFloor(node, vertices, new Transform3D());
      float [][] surroundingPolygon = getSurroundingPolygon(vertices.toArray(new float [vertices.size()][]));
      GeneralPath generalPath = new GeneralPath(GeneralPath.WIND_NON_ZERO, surroundingPolygon.length);
      generalPath.moveTo(surroundingPolygon [0][0], surroundingPolygon [0][1]);
      for (int i = 0; i < surroundingPolygon.length; i++) {
        generalPath.lineTo(surroundingPolygon [i][0], surroundingPolygon [i][1]);
      }
      generalPath.closePath();
      modelAreaOnFloor = new Area(generalPath);
    }
    return modelAreaOnFloor;
  }
View Full Code Here

Examples of java.awt.geom.Area

          }
        }
      }
     
      if (geometryPath != null) {
        nodeArea.add(new Area(geometryPath));
      }
    }
  }
View Full Code Here

Examples of java.awt.geom.Area

    float xVertex3 = vertices [2 * vertexIndex3];
    float yVertex3 = vertices [2 * vertexIndex3 + 1];
    if ((xVertex2 - xVertex1) * (yVertex3 - yVertex2) - (yVertex2 - yVertex1) * (xVertex3 - xVertex2) > 0) {
      if (triangleIndex > 0 && triangleIndex % 1000 == 0) {
        // Add now current path to area otherwise area gets too slow
        nodeArea.add(new Area(geometryPath));
        geometryPath.reset();
      }
      geometryPath.moveTo(xVertex1, yVertex1);     
      geometryPath.lineTo(xVertex2, yVertex2);     
      geometryPath.lineTo(xVertex3, yVertex3);
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.