Package org.geomajas.geometry

Examples of org.geomajas.geometry.Coordinate


  }

  public Geometry viewToPan(Geometry geometry) {
    if (geometry != null) {
      if (geometry instanceof Point) {
        Coordinate transformed = viewToPan(geometry.getCoordinate());
        return geometry.getGeometryFactory().createPoint(transformed);
      } else if (geometry instanceof LinearRing) {
        Coordinate[] coordinates = new Coordinate[geometry.getNumPoints()];
        for (int i = 0; i < coordinates.length; i++) {
          coordinates[i] = viewToPan(geometry.getCoordinates()[i]);
View Full Code Here


      // -cam: center X axis around cam. +bbox.w/2: to place the origin in the center of the screen
      double translateX = -mapView.getViewState().getX() + (bounds.getWidth() / 2);
      double translateY = -mapView.getViewState().getY() - (bounds.getHeight() / 2); // Inverted Y-axis here...
      position.translate(-translateX, -translateY);
      // TODO: implement rotation support.
      return new Coordinate(position.getX(), position.getY());
    }
    return null;
  }
View Full Code Here

   * @return Returns a new geometry that is the world space equivalent of the given geometry.
   */
  public Geometry viewToWorld(Geometry geometry) {
    if (geometry != null) {
      if (geometry instanceof Point) {
        Coordinate transformed = viewToWorld(geometry.getCoordinate());
        return geometry.getGeometryFactory().createPoint(transformed);
      } else if (geometry instanceof LinearRing) {
        Coordinate[] coordinates = new Coordinate[geometry.getNumPoints()];
        for (int i = 0; i < coordinates.length; i++) {
          coordinates[i] = viewToWorld(geometry.getCoordinates()[i]);
View Full Code Here

   *            The bounding box in view coordinates.
   * @returns The world space equivalent of the given bounding box.
   */
  public Bbox viewToWorld(Bbox bbox) {
    if (bbox != null) {
      Coordinate c1 = viewToWorld(bbox.getOrigin());
      Coordinate c2 = viewToWorld(bbox.getEndPoint());
      double x = (c1.getX() < c2.getX()) ? c1.getX() : c2.getX();
      double y = (c1.getY() < c2.getY()) ? c1.getY() : c2.getY();
      return new Bbox(x, y, Math.abs(c1.getX() - c2.getX()), Math.abs(c1.getY() - c2.getY()));
    }
    return null;
  }
View Full Code Here

   *            The transformation matrix.
   * @return Returns a transformed bounding box, or null if one of the given parameters was null.
   */
  public Bbox transform(Bbox bbox, Matrix matrix) {
    if (bbox != null) {
      Coordinate c1 = transform(bbox.getOrigin(), matrix);
      Coordinate c2 = transform(bbox.getEndPoint(), matrix);
      double x = (c1.getX() < c2.getX()) ? c1.getX() : c2.getX();
      double y = (c1.getY() < c2.getY()) ? c1.getY() : c2.getY();
      return new Bbox(x, y, Math.abs(c1.getX() - c2.getX()), Math.abs(c1.getY() - c2.getY()));
    }
    return null;
  }
View Full Code Here

  }

  /** Set a new point on the distance-line. */
  public void onMouseUp(MouseUpEvent event) {
    if (event.getNativeButton() != NativeEvent.BUTTON_RIGHT) {
      Coordinate coordinate = getWorldPosition(event);
      if (distanceLine.getOriginalLocation() == null) {
        distanceLine.setGeometry(getFactory().createLineString(new Coordinate[] { coordinate }));
        mapWidget.registerWorldPaintable(distanceLine);
        mapWidget.registerWorldPaintable(lineSegment);
        label = new DistanceLabel();
View Full Code Here

  /** Update the drawing while moving the mouse. */
  public void onMouseMove(MouseMoveEvent event) {
    if (isMeasuring() && distanceLine.getOriginalLocation() != null) {
      Geometry geometry = (Geometry) distanceLine.getOriginalLocation();
      Coordinate coordinate1 = geometry.getCoordinates()[distanceLine.getGeometry().getNumPoints() - 1];
      Coordinate coordinate2 = getWorldPosition(event);
      lineSegment.setGeometry(getFactory().createLineString(new Coordinate[] { coordinate1, coordinate2 }));
      mapWidget.render(mapWidget.getMapModel(), RenderGroup.VECTOR, RenderStatus.UPDATE);
      label.setDistance(tempLength, (float) ((Geometry) lineSegment.getOriginalLocation()).getLength());
    }
  }
View Full Code Here

   */
  public Coordinate transform(Coordinate coordinate, Matrix matrix) {
    if (coordinate != null && matrix != null) {
      double x = matrix.getXx() * coordinate.getX() + matrix.getXy() * coordinate.getY() + matrix.getDx();
      double y = matrix.getYx() * coordinate.getX() + matrix.getYy() * coordinate.getY() + matrix.getDy();
      return new Coordinate(x, y);
    }
    return null;
  }
View Full Code Here

  }

  public Geometry transform(Geometry geometry, Matrix matrix) {
    if (geometry != null) {
      if (geometry instanceof Point) {
        Coordinate transformed = transform(geometry.getCoordinate(), matrix);
        return geometry.getGeometryFactory().createPoint(transformed);
      } else if (geometry instanceof LinearRing) {
        Coordinate[] coordinates = new Coordinate[geometry.getNumPoints()];
        for (int i = 0; i < coordinates.length; i++) {
          coordinates[i] = transform(geometry.getCoordinates()[i], matrix);
View Full Code Here

      updateView(event);
    }
  }

  private void updateView(MouseEvent<?> event) {
    Coordinate end = getScreenPosition(event);
    Coordinate beginWorld = getTransformer().viewToWorld(begin);
    Coordinate endWorld = getTransformer().viewToWorld(end);
    mapWidget.getMapModel().getMapView().translate(beginWorld.getX() - endWorld.getX(),
        beginWorld.getY() - endWorld.getY());
    begin = end;
  }
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.