Package org.geomajas.geometry

Examples of org.geomajas.geometry.Coordinate


  }

  @Override
  public void onMouseUp(MouseUpEvent event) {
    if (dragging) {
      Coordinate newPosition = getWorldPosition(event);
      getOverviewMap()
          .panTargetMap(newPosition.getX() - oldPosition.getX(), newPosition.getY() - oldPosition.getY());
      dragging = false;
      mapWidget.setCursor(Cursor.DEFAULT);
    }
  }
View Full Code Here


      position.scale(scale, -scale);
      double translateX = -(mapView.getViewState().getX() * scale) + (mapView.getWidth() / 2);
      double translateY = (mapView.getViewState().getY() * scale) + (mapView.getHeight() / 2);
      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 view space equivalent of the given geometry.
   */
  public Geometry worldToView(Geometry geometry) {
    if (geometry != null) {
      if (geometry instanceof Point) {
        Coordinate transformed = worldToView(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] = worldToView(geometry.getCoordinates()[i]);
View Full Code Here

   *            The bounding box in world coordinates.
   * @returns The view space equivalent of the given bounding box.
   */
  public Bbox worldToView(Bbox bbox) {
    if (bbox != null) {
      Coordinate c1 = worldToView(bbox.getOrigin());
      Coordinate c2 = worldToView(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

        if (zoomType == ScrollZoomType.ZOOM_POSITION) {
          mapModel.getMapView().scale(
              2.0f,
              MapView.ZoomOption.LEVEL_CHANGE,
              mapModel.getMapView().getWorldViewTransformer()
                  .viewToWorld(new Coordinate(event.getX(), event.getY())));
        } else {
          mapModel.getMapView().scale(2.0f, MapView.ZoomOption.LEVEL_CHANGE);
        }
      } else {
        if (zoomType == ScrollZoomType.ZOOM_POSITION) {
          mapModel.getMapView().scale(
              0.5f,
              MapView.ZoomOption.LEVEL_CHANGE,
              mapModel.getMapView().getWorldViewTransformer()
                  .viewToWorld(new Coordinate(event.getX(), event.getY())));
        } else {
          mapModel.getMapView().scale(0.5f, MapView.ZoomOption.LEVEL_CHANGE);
        }
      }
    }
View Full Code Here

  public Coordinate worldToPan(Coordinate coordinate) {
    if (coordinate != null) {
      Vector2D position = new Vector2D(coordinate);
      double scale = mapView.getCurrentScale();
      position.scale(scale, -scale);
      Coordinate panOrigin = mapView.getPanOrigin();
      position.translate(-(panOrigin.getX() * scale), panOrigin.getY() * scale);
      // TODO: implement rotation support.
      return new Coordinate(position.getX(), position.getY());
    }
    return null;
  }
View Full Code Here

    return null;
  }

  public Bbox worldToPan(Bbox bbox) {
    if (bbox != null) {
      Coordinate c1 = worldToPan(bbox.getOrigin());
      Coordinate c2 = worldToPan(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

  }

  public Geometry worldToPan(Geometry geometry) {
    if (geometry != null) {
      if (geometry instanceof Point) {
        Coordinate transformed = worldToPan(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] = worldToPan(geometry.getCoordinates()[i]);
View Full Code Here

   */
  public Coordinate viewToPan(Coordinate coordinate) {
    if (coordinate != null) {
      Vector2D position = new Vector2D(coordinate);
      double scale = mapView.getCurrentScale();
      Coordinate panOrigin = mapView.getPanOrigin();
     
      double translateX = (mapView.getViewState().getX() - panOrigin.getX()) * scale - (mapView.getWidth() / 2);
      double translateY = -(mapView.getViewState().getY() - panOrigin.getY()) * scale - (mapView.getHeight() / 2);
      position.translate(translateX , translateY);
        // TODO: implement rotation support.
      return new Coordinate(position.getX(), position.getY());
    }
    return null;
  }
View Full Code Here

    return null;
  }

  public Bbox viewToPan(Bbox bbox) {
    if (bbox != null) {
      Coordinate c1 = viewToPan(bbox.getOrigin());
      Coordinate c2 = viewToPan(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

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.