コード例 #1
0
ファイル: Circle.java プロジェクト: rorro2112/udig-community
 /**
  * The contains test whether the coordinate p is within the circle. Triangle contains coordinate
  * if the distance between center and p is smaller then the radius that is reduced by tolerance.
  * This is used for triangulation when there are four points on one circle to avoid neverending
  * loop.
  *
  * @param p - the point to be tested
  * @return True if the circle contais p, False if not.
  */
 protected boolean contains(DirectPosition p) {
   if (center.distance(new DirectPosition2D(p)) < (this.radius - tolerance)) {
     return true;
   } else {
     return false;
   }
 }
コード例 #2
0
ファイル: ZoomOutTool.java プロジェクト: Geodan/geotools
  /**
   * Zoom out by the currently set increment, with the map centred at the location (in world coords)
   * of the mouse click
   *
   * @param ev the mouse event
   */
  @Override
  public void onMouseClicked(MapMouseEvent ev) {

    if (!isTriggerMouseButton(ev)) {
      return;
    }

    Rectangle paneArea = getMapPane().getBounds();
    DirectPosition2D mapPos = ev.getMapPosition();

    double scale = getMapPane().getWorldToScreenTransform().getScaleX();
    double newScale = scale / zoom;

    DirectPosition2D corner =
        new DirectPosition2D(
            mapPos.getX() - 0.5d * paneArea.width / newScale,
            mapPos.getY() + 0.5d * paneArea.height / newScale);

    Envelope2D newMapArea = new Envelope2D();
    newMapArea.setFrameFromCenter(mapPos, corner);
    getMapPane().setDisplayArea(newMapArea);
  }