public static void main(String[] args) {
    Configuration.setValue(AVKey.INITIAL_LATITUDE, 49.06);
    Configuration.setValue(AVKey.INITIAL_LONGITUDE, -122.77);
    Configuration.setValue(AVKey.INITIAL_ALTITUDE, 22000);

    ApplicationTemplate.start("World Wind Paths With Direction", AppFrame.class);
  }
  public static void main(String[] args) {
    // zoom to San Francisco downtown
    Configuration.setValue(AVKey.INITIAL_ALTITUDE, 34e3);
    Configuration.setValue(AVKey.INITIAL_LATITUDE, 37.9521d);
    Configuration.setValue(AVKey.INITIAL_LONGITUDE, -119.7761d);

    // Adjust configuration values before instantiation
    ApplicationTemplate.start("World Wind Terrain Intersections", AppFrame.class);
  }
  /**
   * @param placeNameServiceSet the set of PlaceNameService objects that PlaceNameLayer will render.
   * @throws IllegalArgumentException if {@link
   *     gov.nasa.worldwind.layers.placename.PlaceNameServiceSet} is null
   */
  public PlaceNameLayer(PlaceNameServiceSet placeNameServiceSet) {
    if (placeNameServiceSet == null) {
      String message = Logging.getMessage("nullValue.PlaceNameServiceSetIsNull");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    //
    this.placeNameServiceSet = placeNameServiceSet.deepCopy();
    for (int i = 0; i < this.placeNameServiceSet.getServiceCount(); i++) {
      // todo do this for long as well and pick min
      int calc1 =
          (int)
              (PlaceNameService.TILING_SECTOR.getDeltaLatDegrees()
                  / this.placeNameServiceSet
                      .getService(i)
                      .getTileDelta()
                      .getLatitude()
                      .getDegrees());
      int numLevels = (int) Math.log(calc1);
      navTiles.add(
          new NavigationTile(
              this.placeNameServiceSet.getService(i),
              PlaceNameService.TILING_SECTOR,
              numLevels,
              "top"));
    }

    if (!WorldWind.getMemoryCacheSet().containsCache(Tile.class.getName())) {
      long size = Configuration.getLongValue(AVKey.PLACENAME_LAYER_CACHE_SIZE, 2000000L);
      MemoryCache cache = new BasicMemoryCache((long) (0.85 * size), size);
      cache.setName("Placename Tiles");
      WorldWind.getMemoryCacheSet().addCache(Tile.class.getName(), cache);
    }
  }
示例#4
0
  public void start(String appConfigurationLocation, Dimension appSize) throws Exception {
    this.appTitle = Configuration.getStringValue(Constants.APPLICATION_DISPLAY_NAME);
    this.appSize = appSize;

    this.unitsFormat = new WWOUnitsFormat();
    this.unitsFormat.setShowUTM(true);
    this.unitsFormat.setShowWGS84(true);

    this.appConfigurationLocation = appConfigurationLocation;
    final AppConfiguration appConfig = new AppConfiguration();
    appConfig.initialize(this);

    appConfig.configure(this.appConfigurationLocation);

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            redraw();
          }
        });
  }
    protected void saveToFile() {
      if (this.fileChooser == null) {
        this.fileChooser = new JFileChooser();
        this.fileChooser.setCurrentDirectory(new File(Configuration.getUserHomeDirectory()));
      }

      this.fileChooser.setDialogTitle("Choose Directory to Place Airspaces");
      this.fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      this.fileChooser.setMultiSelectionEnabled(false);
      int status = this.fileChooser.showSaveDialog(null);
      if (status != JFileChooser.APPROVE_OPTION) return;

      final File dir = this.fileChooser.getSelectedFile();
      if (dir == null) return;

      if (!dir.exists()) {
        //noinspection ResultOfMethodCallIgnored
        dir.mkdirs();
      }

      final Iterable<AirspaceEntry> entries = this.getModel().getEntries();

      Thread t =
          new Thread(
              new Runnable() {
                public void run() {
                  try {
                    java.text.DecimalFormat f = new java.text.DecimalFormat("####");
                    f.setMinimumIntegerDigits(4);
                    int counter = 0;

                    for (AirspaceEntry entry : entries) {
                      Airspace a = entry.getAirspace();
                      AirspaceAttributes currentAttribs = a.getAttributes();
                      a.setAttributes(entry.getAttributes());

                      String xmlString = a.getRestorableState();
                      if (xmlString != null) {
                        try {
                          PrintWriter of =
                              new PrintWriter(
                                  new File(
                                      dir,
                                      a.getClass().getName()
                                          + "-"
                                          + entry.getName()
                                          + "-"
                                          + f.format(counter++)
                                          + ".xml"));
                          of.write(xmlString);
                          of.flush();
                          of.close();
                        } catch (Exception e) {
                          e.printStackTrace();
                        }
                      }

                      a.setAttributes(currentAttribs);
                    }
                  } finally {
                    SwingUtilities.invokeLater(
                        new Runnable() {
                          public void run() {
                            setEnabled(true);
                            getApp().setCursor(null);
                            getApp().getWwd().redraw();
                          }
                        });
                  }
                }
              });
      this.setEnabled(false);
      getApp().setCursor(new Cursor(Cursor.WAIT_CURSOR));
      t.start();
    }
    protected void openFromFile() {
      if (this.fileChooser == null) {
        this.fileChooser = new JFileChooser();
        this.fileChooser.setCurrentDirectory(new File(Configuration.getUserHomeDirectory()));
      }

      this.fileChooser.setDialogTitle("Choose Airspace File Directory");
      this.fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      this.fileChooser.setMultiSelectionEnabled(false);
      int status = this.fileChooser.showOpenDialog(null);
      if (status != JFileChooser.APPROVE_OPTION) return;

      final File dir = this.fileChooser.getSelectedFile();
      if (dir == null) return;

      Thread t =
          new Thread(
              new Runnable() {
                public void run() {
                  final ArrayList<Airspace> airspaces = new ArrayList<Airspace>();
                  try {
                    File[] files =
                        dir.listFiles(
                            new FilenameFilter() {
                              public boolean accept(File dir, String name) {
                                return name.startsWith("gov.nasa.worldwind.render.airspaces")
                                    && name.endsWith(".xml");
                              }
                            });

                    for (File file : files) {
                      String[] name = file.getName().split("-");
                      try {
                        Class c = Class.forName(name[0]);
                        Airspace airspace = (Airspace) c.newInstance();
                        BufferedReader input = new BufferedReader(new FileReader(file));
                        String s = input.readLine();
                        airspace.restoreState(s);
                        airspaces.add(airspace);

                        if (name.length >= 2) {
                          airspace.setValue(AVKey.DISPLAY_NAME, name[1]);
                        }
                      } catch (Exception e) {
                        e.printStackTrace();
                      }
                    }
                  } finally {
                    SwingUtilities.invokeLater(
                        new Runnable() {
                          public void run() {
                            setAirspaces(airspaces);
                            setEnabled(true);
                            getApp().setCursor(null);
                            getApp().getWwd().redraw();
                          }
                        });
                  }
                }
              });
      this.setEnabled(false);
      getApp().setCursor(new Cursor(Cursor.WAIT_CURSOR));
      t.start();
    }
  public FlyViewInputHandler() {
    // Mouse Button Horizontal Translate Events
    // Button 1
    this.getAttributes()
        .setValues(
            ViewInputAttributes.DEVICE_MOUSE,
            ViewInputAttributes.VIEW_HORIZONTAL_TRANSLATE,
            DEFAULT_MOUSE_HORIZONTAL_TRANSLATE_MIN_VALUE,
            DEFAULT_MOUSE_HORIZONTAL_TRANSLATE_MAX_VALUE);
    this.getAttributes()
        .setActionTrigger(
            ViewInputAttributes.DEVICE_MOUSE,
            ViewInputAttributes.VIEW_HORIZONTAL_TRANSLATE,
            ViewInputAttributes.ActionAttributes.ActionTrigger.ON_KEY_DOWN);

    // Mouse Button Rotate Events
    // Button 1 + SHIFT
    this.getAttributes()
        .setValues(
            ViewInputAttributes.DEVICE_MOUSE,
            ViewInputAttributes.VIEW_ROTATE_SHIFT,
            DEFAULT_MOUSE_ROTATE_MIN_VALUE,
            DEFAULT_MOUSE_ROTATE_MAX_VALUE);
    this.getAttributes()
        .setActionTrigger(
            ViewInputAttributes.DEVICE_MOUSE,
            ViewInputAttributes.VIEW_ROTATE_SHIFT,
            ViewInputAttributes.ActionAttributes.ActionTrigger.ON_KEY_DOWN);
    // Button 3
    this.getAttributes()
        .setValues(
            ViewInputAttributes.DEVICE_MOUSE,
            ViewInputAttributes.VIEW_ROTATE,
            DEFAULT_MOUSE_ROTATE_MIN_VALUE,
            DEFAULT_MOUSE_ROTATE_MAX_VALUE);
    this.getAttributes()
        .setActionTrigger(
            ViewInputAttributes.DEVICE_MOUSE,
            ViewInputAttributes.VIEW_ROTATE,
            ViewInputAttributes.ActionAttributes.ActionTrigger.ON_KEY_DOWN);

    // Mouse Vertical Translate
    // Button 2
    this.getAttributes()
        .setValues(
            ViewInputAttributes.DEVICE_MOUSE,
            ViewInputAttributes.VIEW_VERTICAL_TRANSLATE,
            DEFAULT_MOUSE_VERTICAL_TRANSLATE_MIN_VALUE,
            DEFAULT_MOUSE_VERTICAL_TRANSLATE_MAX_VALUE);
    this.getAttributes()
        .setActionTrigger(
            ViewInputAttributes.DEVICE_MOUSE,
            ViewInputAttributes.VIEW_VERTICAL_TRANSLATE,
            ViewInputAttributes.ActionAttributes.ActionTrigger.ON_KEY_DOWN);
    // Button 1 + CTRL
    this.getAttributes()
        .setValues(
            ViewInputAttributes.DEVICE_MOUSE,
            ViewInputAttributes.VIEW_VERTICAL_TRANSLATE_CTRL,
            DEFAULT_MOUSE_VERTICAL_TRANSLATE_MIN_VALUE,
            DEFAULT_MOUSE_VERTICAL_TRANSLATE_MAX_VALUE);
    this.getAttributes()
        .setActionTrigger(
            ViewInputAttributes.DEVICE_MOUSE,
            ViewInputAttributes.VIEW_VERTICAL_TRANSLATE_CTRL,
            ViewInputAttributes.ActionAttributes.ActionTrigger.ON_KEY_DOWN);

    // Arrow keys rotate

    // ----------------------------------Key Roll --------------------------------------------
    RollActionListener rollActionListener = new RollActionListener();
    this.getAttributes()
        .setActionListener(
            ViewInputAttributes.DEVICE_KEYBOARD,
            ViewInputAttributes.VIEW_ROLL_KEYS,
            rollActionListener);

    // Arrow Keys horizontal translate
    this.getAttributes()
        .setValues(
            ViewInputAttributes.DEVICE_KEYBOARD,
            ViewInputAttributes.VIEW_HORIZONTAL_TRANS_KEYS,
            DEFAULT_KEY_HORIZONTAL_TRANSLATE_MIN_VALUE,
            DEFAULT_KEY_HORIZONTAL_TRANSLATE_MAX_VALUE);
    this.getAttributes()
        .getActionAttributes(
            ViewInputAttributes.DEVICE_KEYBOARD, ViewInputAttributes.VIEW_HORIZONTAL_TRANS_KEYS)
        .setSmoothingValue(DEFAULT_KEY_TRANSLATE_SMOOTHING_VALUE);

    this.getAttributes()
        .setValues(
            ViewInputAttributes.DEVICE_KEYBOARD,
            ViewInputAttributes.VIEW_HORIZONTAL_TRANSLATE_SLOW,
            DEFAULT_KEY_HORIZONTAL_TRANSLATE_MIN_VALUE_SLOW,
            DEFAULT_KEY_HORIZONTAL_TRANSLATE_MAX_VALUE_SLOW);
    /*
    this.getAttributes().setActionTrigger(ViewInputAttributes.DEVICE_KEYBOARD,
        ViewInputAttributes.VIEW_HORIZONTAL_TRANSLATE_SLOW,
        ViewInputAttributes.ActionAttributes.ActionTrigger.ON_KEY_DOWN);
    */

    // +- Keys vertical translate
    this.getAttributes()
        .setValues(
            ViewInputAttributes.DEVICE_KEYBOARD,
            ViewInputAttributes.VIEW_VERTICAL_TRANS_KEYS,
            DEFAULT_KEY_VERTICAL_TRANSLATE_MIN_VALUE,
            DEFAULT_KEY_VERTICAL_TRANSLATE_MAX_VALUE);
    // Arrow keys vertical translate
    this.getAttributes()
        .setValues(
            ViewInputAttributes.DEVICE_KEYBOARD,
            ViewInputAttributes.VIEW_VERTICAL_TRANS_KEYS_META,
            DEFAULT_KEY_VERTICAL_TRANSLATE_MIN_VALUE,
            DEFAULT_KEY_VERTICAL_TRANSLATE_MAX_VALUE);
    this.getAttributes()
        .setValues(
            ViewInputAttributes.DEVICE_KEYBOARD,
            ViewInputAttributes.VIEW_VERTICAL_TRANS_KEYS_CTRL,
            DEFAULT_KEY_VERTICAL_TRANSLATE_MIN_VALUE,
            DEFAULT_KEY_VERTICAL_TRANSLATE_MAX_VALUE);

    // Mouse Wheel vertical translate
    if (Configuration.isMacOS()) {
      this.getAttributes()
          .setValues(
              ViewInputAttributes.DEVICE_MOUSE_WHEEL,
              ViewInputAttributes.VIEW_VERTICAL_TRANSLATE,
              DEFAULT_MOUSE_WHEEL_VERTICAL_TRANSLATE_VALUE_MIN_OSX,
              DEFAULT_MOUSE_WHEEL_VERTICAL_TRANSLATE_VALUE_MAX_OSX);
    } else {
      this.getAttributes()
          .setValues(
              ViewInputAttributes.DEVICE_MOUSE_WHEEL,
              ViewInputAttributes.VIEW_VERTICAL_TRANSLATE,
              DEFAULT_MOUSE_WHEEL_VERTICAL_TRANSLATE_VALUE_MIN,
              DEFAULT_MOUSE_WHEEL_VERTICAL_TRANSLATE_VALUE_MAX);
    }

    // P Key Reset Pitch
    this.getAttributes()
        .addAction(
            ViewInputAttributes.DEVICE_KEYBOARD,
            ViewInputAttributes.ActionAttributes.NO_MODIFIER,
            ACTION_RESET_PITCH,
            new ViewInputAttributes.ActionAttributes(
                resetPitchEvents,
                ViewInputAttributes.ActionAttributes.ActionTrigger.ON_PRESS,
                0,
                0.1,
                0.1,
                false,
                0.1));
    // Reset Pitch
    ViewInputAttributes.ActionAttributes actionAttrs =
        this.getAttributes()
            .getActionMap(ViewInputAttributes.DEVICE_KEYBOARD)
            .getActionAttributes(ACTION_RESET_PITCH);
    actionAttrs.setActionListener(new ResetPitchActionListener());
  }
示例#8
0
 /** Displays a world map overlay with a current position crosshair in a screen corner */
 public WorldMapLayer() {
   this.setOpacity(0.6);
   this.setIconFilePath(Configuration.getStringValue(AVKey.WORLD_MAP_IMAGE_PATH));
 }