Esempio n. 1
0
  protected int determineAdjustmentSide(Movable dragObject, double factor) {
    if (dragObject instanceof SurfaceSector) {
      SurfaceSector quad = (SurfaceSector) dragObject;
      Sector s = quad.getSector(); // TODO: go over all sectors
      Position p = this.getWwd().getCurrentPosition();

      if (p == null) {
        return NONE;
      }

      double dN = abs(s.getMaxLatitude().subtract(p.getLatitude()).degrees);
      double dS = abs(s.getMinLatitude().subtract(p.getLatitude()).degrees);
      double dW = abs(s.getMinLongitude().subtract(p.getLongitude()).degrees);
      double dE = abs(s.getMaxLongitude().subtract(p.getLongitude()).degrees);

      double sLat = factor * s.getDeltaLatDegrees();
      double sLon = factor * s.getDeltaLonDegrees();

      if (dN < sLat && dW < sLon) return NORTHWEST;
      if (dN < sLat && dE < sLon) return NORTHEAST;
      if (dS < sLat && dW < sLon) return SOUTHWEST;
      if (dS < sLat && dE < sLon) return SOUTHEAST;
      if (dN < sLat) return NORTH;
      if (dS < sLat) return SOUTH;
      if (dW < sLon) return WEST;
      if (dE < sLon) return EAST;
    }

    return NONE;
  }
Esempio n. 2
0
  protected Sector resizeShape(Movable dragObject, int side) {
    if (dragObject instanceof SurfaceSector) {
      SurfaceSector quad = (SurfaceSector) dragObject;
      Sector s = quad.getSector(); // TODO: go over all sectors
      Position p = this.getWwd().getCurrentPosition();

      if (p == null || this.getPreviousPosition() == null) {
        return null;
      }

      Angle dLat = p.getLatitude().subtract(this.getPreviousPosition().getLatitude());
      Angle dLon = p.getLongitude().subtract(this.getPreviousPosition().getLongitude());

      Angle newMinLat = s.getMinLatitude();
      Angle newMinLon = s.getMinLongitude();
      Angle newMaxLat = s.getMaxLatitude();
      Angle newMaxLon = s.getMaxLongitude();

      if (side == NORTH) {
        newMaxLat = s.getMaxLatitude().add(dLat);
      } else if (side == SOUTH) {
        newMinLat = s.getMinLatitude().add(dLat);
      } else if (side == EAST) {
        newMaxLon = s.getMaxLongitude().add(dLon);
      } else if (side == WEST) {
        newMinLon = s.getMinLongitude().add(dLon);
      } else if (side == NORTHWEST) {
        newMaxLat = s.getMaxLatitude().add(dLat);
        newMinLon = s.getMinLongitude().add(dLon);
      } else if (side == NORTHEAST) {
        newMaxLat = s.getMaxLatitude().add(dLat);
        newMaxLon = s.getMaxLongitude().add(dLon);
      } else if (side == SOUTHWEST) {
        newMinLat = s.getMinLatitude().add(dLat);
        newMinLon = s.getMinLongitude().add(dLon);
      } else if (side == SOUTHEAST) {
        newMinLat = s.getMinLatitude().add(dLat);
        newMaxLon = s.getMaxLongitude().add(dLon);
      }

      return new Sector(newMinLat, newMaxLat, newMinLon, newMaxLon);
    }

    return null;
  }