Ejemplo n.º 1
0
  /**
   * Callback for the OsmMapControl. (Re-)Sets the start and end point of the selection rectangle.
   *
   * @param aStart
   * @param aEnd
   */
  public void setSelection(Point aStart, Point aEnd) {
    if (aStart == null || aEnd == null || aStart.x == aEnd.x || aStart.y == aEnd.y) return;

    Point p_max = new Point(Math.max(aEnd.x, aStart.x), Math.max(aEnd.y, aStart.y));
    Point p_min = new Point(Math.min(aEnd.x, aStart.x), Math.min(aEnd.y, aStart.y));

    Point tlc = getTopLeftCoordinates();
    int zoomDiff = MAX_ZOOM - zoom;
    Point pEnd = new Point(p_max.x + tlc.x, p_max.y + tlc.y);
    Point pStart = new Point(p_min.x + tlc.x, p_min.y + tlc.y);

    pEnd.x <<= zoomDiff;
    pEnd.y <<= zoomDiff;
    pStart.x <<= zoomDiff;
    pStart.y <<= zoomDiff;

    iSelectionRectStart = pStart;
    iSelectionRectEnd = pEnd;

    Coordinate l1 = getPosition(p_max);
    Coordinate l2 = getPosition(p_min);
    Bounds b =
        new Bounds(
            new LatLon(Math.min(l2.getLat(), l1.getLat()), Math.min(l1.getLon(), l2.getLon())),
            new LatLon(Math.max(l2.getLat(), l1.getLat()), Math.max(l1.getLon(), l2.getLon())));
    Bounds oldValue = this.bbox;
    this.bbox = b;
    firePropertyChange(BBOX_PROP, oldValue, this.bbox);
    repaint();
  }
  /**
   * Constructor
   *
   * @param flightCoords Coordinates of the flight
   * @param firstSegmentOffset Offset that will be added to the flight's coordinates for the first
   *     segment
   */
  public FlightCreateDialogController(
      final Coordinate flightCoords, final Coordinate firstSegmentOffset) {
    this.firstSegmentOffset = firstSegmentOffset;

    // Load all aircrafts
    OperationalZoneActions action = new OperationalZoneActions();

    final List<Aircraft> aircrafts = action.fetchAllAircrafts();

    // Make sure the dialog is created and populated in the EDT
    if (SwingUtilities.isEventDispatchThread()) {
      this.createDialog(aircrafts, flightCoords.getLat(), flightCoords.getLon());
    } else {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              FlightCreateDialogController.this.createDialog(
                  aircrafts, flightCoords.getLat(), flightCoords.getLon());
            }
          });
    }
  }