Package org.geomajas.geometry

Examples of org.geomajas.geometry.Coordinate


      return this.c2;
    } else {
      // Intersecting point is on the line, use the formula: P = P1 + u (P2 - P1)
      double x1 = this.c1.getX() + u * (this.c2.getX() - this.c1.getX());
      double y1 = this.c1.getY() + u * (this.c2.getY() - this.c1.getY());
      return new Coordinate(x1, y1);
    }
  }
View Full Code Here


  }

  /** Return the circle's radius in world length units. */
  protected double getWorldRadius() {
    if (center != null) {
      Coordinate screenEndPoint = new Coordinate(center.getX() + radius, center.getY());
      Coordinate worldEndPoint = mapWidget.getMapModel().getMapView().getWorldViewTransformer().viewToWorld(
          screenEndPoint);
      double deltaX = worldEndPoint.getX() - getWorldCenter().getX();
      double deltaY = worldEndPoint.getY() - getWorldCenter().getY();
      return (float) Math.sqrt((deltaX * deltaX) + (deltaY * deltaY));
    }
    return 0;
  }
View Full Code Here

      radius = 0;
    }
  }

  private void updateGraphics(MouseEvent<?> event) {
    Coordinate position = getScreenPosition(event);
    double deltaX = position.getX() - getScreenCenter().getX();
    double deltaY = position.getY() - getScreenCenter().getY();
    radius = Math.sqrt((deltaX * deltaX) + (deltaY * deltaY));

    LineString radiusLine = mapWidget.getMapModel().getGeometryFactory().createLineString(
        new Coordinate[] { center, position });
    mapWidget.getVectorContext().drawCircle(circleGroup, "outer", center, radius, circleStyle);
View Full Code Here

      mapWidget.render(rectangle, RenderGroup.SCREEN, RenderStatus.DELETE);
    }
  }

  private void updateRectangle(MouseEvent<?> event) {
    Coordinate pos = getScreenPosition(event);
    double x = begin.getX();
    double y = begin.getY();
    double width = pos.getX() - x;
    double height = pos.getY() - y;
    if (width < 0) {
      x = pos.getX();
      width = -width;
    }
    if (height < 0) {
      y = pos.getY();
      height = -height;
    }
    bounds.setX(x);
    bounds.setY(y);
    bounds.setWidth(width);
View Full Code Here

   *            coordinate.
   * @return Returns the eventual snapped coordinate, or null if no snapping occurred.
   */
  Coordinate getSnappingPoint(Coordinate original, double threshold) {
    minimumDistance = Double.MAX_VALUE;
    Coordinate snappingPoint = null;
    double currThreshold = threshold;

    List<Coordinate> coordinates = getPossibleCoordinates(original);
    for (Coordinate coordinate : coordinates) {
      double distance = Mathlib.distance(original, coordinate);
View Full Code Here

   * Return a possible list of coordinates that are within range of the given coordinate. This function is very fast
   * as it uses binary search, and it returns a small subset of coordinates. The perfect set to start calculating
   * from.
   */
  private List<Coordinate> getPossibleCoordinates(Coordinate coordinate) {
    int xMin = Collections.binarySearch(sortedX, new Coordinate(coordinate.getX() - ruleDistance, 0),
        new XComparator());
    int xMax = Collections.binarySearch(sortedX, new Coordinate(coordinate.getX() + ruleDistance, 0),
        new XComparator());
    int yMin = Collections.binarySearch(sortedY, new Coordinate(0, coordinate.getY() - ruleDistance),
        new YComparator());
    int yMax = Collections.binarySearch(sortedY, new Coordinate(0, coordinate.getY() + ruleDistance),
        new YComparator());
    if (xMin < 0) {
      xMin = Math.abs(xMin) - 1;
    }
    if (xMax < 0) {
View Full Code Here

          if (rule.getType() == SnappingType.CLOSEST_ENDPOINT) {
            algorithm = new ClosestPointAlgorithm(currentGeometries, rule.getDistance());
          } else {
            algorithm = new NearestAlgorithm(currentGeometries, rule.getDistance());
          }
          Coordinate snapPointIfFound = algorithm.getSnappingPoint(coordinate, intersectDistance);
          if (snapPointIfFound != null) {
            snappedCoordinate = snapPointIfFound;
            intersectSnappedCoordinate = snappedCoordinate;
            intersectDistance = algorithm.getMinimumDistance();
          }
        } else {
          geometries.addAll(currentGeometries);
        }
      }
    }

    if (intersectSnappedCoordinate == null && !geometries.isEmpty()) {
      SnappingAlgorithm algorithm;
      if (rule.getType() == SnappingType.CLOSEST_ENDPOINT) {
        algorithm = new ClosestPointAlgorithm(geometries, rule.getDistance());
      } else {
        algorithm = new NearestAlgorithm(geometries, rule.getDistance());
      }
      Coordinate snapPointIfFound = algorithm.getSnappingPoint(coordinate, intersectDistance);
      if (snapPointIfFound != null) {
        snappedCoordinate = snapPointIfFound;
        distance = algorithm.getMinimumDistance();
      }
    }
View Full Code Here

  // ------------------------------------------------------------------------

  private Path toPath(LineString lineString) {
    Path path = new Path((int) lineString.getCoordinate().getX(), (int) lineString.getCoordinate().getY());
    for (int i = 1; i < lineString.getNumPoints(); i++) {
      Coordinate coordinate = lineString.getCoordinateN(i);
      path.lineTo((int) coordinate.getX(), (int) coordinate.getY());
    }
    return path;
  }
View Full Code Here

  }

  private Path toPath(LinearRing linearRing) {
    Path path = new Path((int) linearRing.getCoordinate().getX(), (int) linearRing.getCoordinate().getY());
    for (int i = 1; i < linearRing.getNumPoints() - 1; i++) {
      Coordinate coordinate = linearRing.getCoordinateN(i);
      path.lineTo((int) coordinate.getX(), (int) coordinate.getY());
    }
    path.close();
    return path;
  }
View Full Code Here

    Path path = toPath(polygon.getExteriorRing());
    for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
      LinearRing interiorRing = polygon.getInteriorRingN(i);
      path.moveTo((int) interiorRing.getCoordinate().getX(), (int) interiorRing.getCoordinate().getY());
      for (int j = 1; j < interiorRing.getNumPoints() - 1; j++) {
        Coordinate coordinate = interiorRing.getCoordinateN(j);
        path.lineTo((int) coordinate.getX(), (int) coordinate.getY());
      }
      path.close();
    }
    return path;
  }
View Full Code Here

TOP

Related Classes of org.geomajas.geometry.Coordinate

Copyright © 2018 www.massapicom. 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.