예제 #1
1
 static {
   if (Configuration.isMacOS()) {
     System.setProperty("apple.laf.useScreenMenuBar", "true");
     System.setProperty("com.apple.mrj.application.apple.menu.about.name", APP_NAME);
     System.setProperty("com.apple.mrj.application.growbox.intrudes", "false");
   }
 }
예제 #2
0
  /**
   * Initialize configuration options for WorldWind to operate correctly.
   *
   * @param globeTypeClass
   */
  protected void initconfig(Class<? extends Globe> globeTypeClass) {
    // Configuration.setValue(AVKey.GLOBE_CLASS_NAME, EarthFlat.class.getName());
    Configuration.setValue(AVKey.GLOBE_CLASS_NAME, globeTypeClass.getName());
    Configuration.setValue(AVKey.VIEW_CLASS_NAME, FlatOrbitView.class.getName());
    Configuration.setValue(
        AVKey.LAYERS_CLASS_NAMES,
        "gov.nasa.worldwind.layers.CompassLayer,"
            + "gov.nasa.worldwind.layers.Earth.NASAWFSPlaceNameLayer,"
            + "gov.nasa.worldwind.layers.Earth.CountryBoundariesLayer,"
            + "gov.nasa.worldwind.layers.Earth.BMNGOneImage,"
            + "gov.nasa.worldwind.layers.Earth.BMNGWMSLayer,"
            + "gov.nasa.worldwind.layers.Earth.LandsatI3WMSLayer,"
            + "gov.nasa.worldwind.layers.Earth.USGSUrbanAreaOrtho,"
            + "gov.nasa.worldwind.layers.Earth.MSVirtualEarthLayer");

    System.setProperty("java.net.useSystemProxies", "true");
    if (Configuration.isMacOS()) {
      System.setProperty("apple.laf.useScreenMenuBar", "true");
      System.setProperty(
          "com.apple.mrj.application.apple.menu.about.name", "World Wind Application");
      System.setProperty("com.apple.mrj.application.growbox.intrudes", "false");
      System.setProperty("apple.awt.brushMetalLook", "true");
    } else if (Configuration.isWindowsOS()) {
      // Prevent flashing during window resizing
      System.setProperty("sun.awt.noerasebackground", "true");
    }
  }
  protected static String determineSingleUserLocation() {
    String home = getUserHomeDir();
    if (home == null) {
      Logging.logger().warning("generic.UsersHomeDirectoryNotKnown");
      return null;
    }

    String path = null;

    if (gov.nasa.worldwind.Configuration.isMacOS()) {
      path = "/Library/Caches";
    } else if (gov.nasa.worldwind.Configuration.isWindowsOS()) {
      // This produces an incorrect path with duplicate parts,
      // like "C:\Users\PatC:\Users\Pat\Application Data".
      // path = System.getenv("USERPROFILE");
      // if (path == null)
      // {
      //    Logging.logger().fine("generic.UsersWindowsProfileNotKnown");
      //    return null;
      // }
      // path += "\\Application Data";

      path = "\\Application Data";
    } else if (gov.nasa.worldwind.Configuration.isLinuxOS()
        || gov.nasa.worldwind.Configuration.isUnixOS()
        || gov.nasa.worldwind.Configuration.isSolarisOS()) {
      path = "/var/cache/";
    } else {
      Logging.logger().fine("generic.UnknownOperatingSystem");
    }

    if (path == null) return null;

    return home + path;
  }
  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);
  }
예제 #5
0
  public static void main(String[] args) {
    Configuration.setValue(AVKey.INITIAL_LATITUDE, 49.05);
    Configuration.setValue(AVKey.INITIAL_LONGITUDE, -122.78);
    Configuration.setValue(AVKey.INITIAL_ALTITUDE, 8000);

    ApplicationTemplate.start("World Wind Multi Path", AppFrame.class);
  }
예제 #6
0
 public static void main(String[] args) {
   // Adjust configuration values before instantiation
   Configuration.setValue(AVKey.GLOBE_CLASS_NAME, EarthFlat.class.getName());
   Configuration.setValue(AVKey.INITIAL_ALTITUDE, 27e6);
   Configuration.setValue(AVKey.INITIAL_LATITUDE, 0);
   Configuration.setValue(AVKey.INITIAL_LONGITUDE, 88);
   ApplicationTemplate.start("World Wind Icon Picking", AppFrame.class);
 }
예제 #7
0
 public static void main(String[] args) {
   // Set the initial configurations of your NASA World Wind App
   // Altitute, logitude and latitute, and window caption.
   Configuration.setValue(AVKey.INITIAL_LATITUDE, 54);
   Configuration.setValue(AVKey.INITIAL_LONGITUDE, 13);
   Configuration.setValue(AVKey.INITIAL_ALTITUDE, 190e4);
   ApplicationTemplate.start("NASA World Wind Tutorial - Simple Polygons", 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);
  }
예제 #9
0
  protected static String makeFullLibName(String libName) {
    if (WWUtil.isEmpty(libName)) return null;

    if (gov.nasa.worldwind.Configuration.isWindowsOS()) {
      if (!libName.toLowerCase().endsWith(".dll")) return libName + ".dll";
    } else if (gov.nasa.worldwind.Configuration.isMacOS()) {
      if (!libName.toLowerCase().endsWith(".jnilib") && !libName.toLowerCase().startsWith("lib"))
        return "lib" + libName + ".jnilib";
    } else if (gov.nasa.worldwind.Configuration.isUnixOS()) // covers Solaris and Linux
    {
      if (!libName.toLowerCase().endsWith(".so") && !libName.toLowerCase().startsWith("lib"))
        return "lib" + libName + ".so";
    }
    return libName;
  }
예제 #10
0
  /**
   * @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);
    }
  }
  /**
   * @param url the "file:" URL of the file to remove from the file store. Only files in the
   *     writable World Wind disk cache or temp file directory are removed by this method.
   * @throws IllegalArgumentException if <code>url</code> is null
   */
  @SuppressWarnings({"ResultOfMethodCallIgnored"})
  public void removeFile(java.net.URL url) {
    if (url == null) {
      String msg = Logging.getMessage("nullValue.URLIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    try {
      java.io.File file = new java.io.File(url.toURI());

      // This block of code must be synchronized for proper operation. A thread may check that the
      // file exists,
      // and become immediately suspended. A second thread may then delete that file. When the first
      // thread
      // wakes up, file.delete() fails.
      synchronized (this.fileLock) {
        if (file.exists()) {
          // Don't remove files outside the cache or temp directory.
          String parent = file.getParent();
          if (!(parent.startsWith(this.getWriteLocation().getPath())
              || parent.startsWith(Configuration.getSystemTempDirectory()))) return;

          file.delete();
        }
      }
    } catch (java.net.URISyntaxException e) {
      Logging.logger()
          .log(
              Level.SEVERE,
              Logging.getMessage("FileStore.ExceptionRemovingFile", url.toString()),
              e);
    }
  }
예제 #12
0
 static {
   if (gov.nasa.worldwind.Configuration.isMacOS()) {
     System.setProperty("apple.laf.useScreenMenuBar", "true");
     System.setProperty(
         "com.apple.mrj.application.apple.menu.about.name", "World Wind Multi-Window Analysis");
     System.setProperty("com.apple.mrj.application.growbox.intrudes", "false");
   }
 }
  public DownloaderRetrievalService() {
    Integer poolSize = Configuration.getIntegerValue(AVKey.RETRIEVAL_POOL_SIZE, DEFAULT_POOL_SIZE);

    // this.executor runs the retrievers, each in their own thread
    this.executor = new RetrievalExecutor(poolSize);

    // this.activeTasks holds the list of currently executing tasks (*not* those pending on the
    // queue)
    this.activeTasks = new ConcurrentLinkedQueue<RetrievalTask>();
  }
예제 #14
0
    public void showOpenDialog() {
      JFileChooser fc = new JFileChooser(Configuration.getUserHomeDirectory());
      fc.addChoosableFileFilter(new VPFFileFilter());

      int retVal = fc.showOpenDialog(this);
      if (retVal != JFileChooser.APPROVE_OPTION) return;

      File file = fc.getSelectedFile();
      this.addVPFLayer(file);
    }
예제 #15
0
  public static void main(String[] args) {
    // MeasureRenderTime.enable(true);
    // MeasureRenderTime.setMesureGpu(true);

    Configuration.insertConfigurationDocument("si/xlab/gaea/examples/gaea-example-config.xml");
    appFrame =
        (GaeaAppFrame)
            ApplicationTemplate.start("Gaea+ Open Source Example Application", GaeaAppFrame.class);
    insertBeforeCompass(appFrame.getWwd(), RenderToTextureLayer.getInstance());
    appFrame.getWwd().addSelectListener(new FeatureSelectListener(appFrame.getWwd()));
    makeMenu(appFrame);
  }
 GLFrame(JTextArea outputArea) {
   this.outputArea = outputArea;
   GLCapabilities caps = new GLCapabilities(Configuration.getMaxCompatibleGLProfile());
   caps.setAlphaBits(8);
   caps.setRedBits(8);
   caps.setGreenBits(8);
   caps.setBlueBits(8);
   GLCanvas glCanvas = new GLCanvas(caps);
   glCanvas.addGLEventListener(this);
   this.add(glCanvas);
   this.setSize(200, 200);
 }
  /**
   * Create a new WebView.
   *
   * @param frameSize The size of the WebView rectangle.
   * @throws UnsupportedOperationException if this class is instantiated on a non-Windows operating
   *     system.
   * @throws WWRuntimeException if creating the native web browser window fails for any reason. For
   *     example, because the process has run out of User Object handles (see documentation <a
   *     href="#limits">above</a>).
   */
  public WindowsWebView(Dimension frameSize) {
    if (frameSize == null) {
      String message = Logging.getMessage("nullValue.SizeIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (!Configuration.isWindowsOS()) {
      String message =
          Logging.getMessage(
              "NativeLib.UnsupportedOperatingSystem",
              "Windows WebView",
              System.getProperty("os.name"));
      Logging.logger().severe(message);
      throw new UnsupportedOperationException(message);
    }

    this.frameSize = frameSize;

    try {
      // Increment the instance counter
      instances.incrementAndGet();

      // Make sure that the message loop thread is running
      this.ensureMessageLoopRunning();

      // Create the web view
      this.webViewWindowPtr = WindowsWebViewJNI.newWebViewWindow(webViewMessageLoop);
      if (this.webViewWindowPtr == 0) {
        String message = Logging.getMessage("WebView.NativeExceptionInitializingWebView");
        Logging.logger().severe(message);
        throw new WWRuntimeException(message);
      }

      WindowsWebViewJNI.setFrameSize(
          this.webViewWindowPtr, this.frameSize.width, this.frameSize.height);

      this.observerPtr = WindowsWebViewJNI.newNotificationAdapter(this);

      WindowsWebViewJNI.addWindowUpdateObserver(this.webViewWindowPtr, observerPtr);
    } catch (RuntimeException e) {
      // If the WebView was not created successfully do not increment the instance counter.
      instances.decrementAndGet();
      this.handleWebViewCreationError();
      throw e;
    } catch (Error e) {
      // If the WebView was not created successfully do not increment the instance counter.
      instances.decrementAndGet();
      this.handleWebViewCreationError();
      throw e;
    }
  }
예제 #18
0
  public static void main(String[] args) {
    if (Configuration.isMacOS()) {
      System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Hello World Wind");
    }

    java.awt.EventQueue.invokeLater(
        new Runnable() {
          public void run() {
            // Create an AppFrame and immediately make it visible. As per Swing convention, this
            // is done within an invokeLater call so that it executes on an AWT thread.
            new AppFrame().setVisible(true);
          }
        });
  }
  @Before
  public void setup() {
    Configuration.setValue(AVKey.OFFLINE_MODE, true);

    BasicModel model = new BasicModel();
    model.setLayers(new SectionListLayerList());
    model.getGlobe().setElevationModel(new SectionListCompoundElevationModel());

    worldWindow = new WorldWindowTestImpl();
    worldWindow.setModel(model);

    LayerTree tree = new LayerTree(worldWindow, new FolderNode("Root", null, null, true));
    classUnderTest = tree.getLayerModel();

    treeListener = new TreeModelTestListener();
    classUnderTest.addTreeModelListener(treeListener);
  }
  /**
   * Determines and stores the network sites to test for public network connectivity. The sites are
   * drawn from the JVM's gov.nasa.worldwind.avkey.NetworkStatusTestSites property ({@link
   * AVKey#NETWORK_STATUS_TEST_SITES}). If that property is not defined, the sites are drawn from
   * the same property in the World Wind or application configuration file. If the sites are not
   * specified there, the set of sites specified in {@link #DEFAULT_NETWORK_TEST_SITES} are used. To
   * indicate an empty list in the JVM property or configuration file property, specify an empty
   * site list, "".
   */
  protected void establishNetworkTestSites() {
    String testSites = System.getProperty(AVKey.NETWORK_STATUS_TEST_SITES);

    if (testSites == null)
      testSites = Configuration.getStringValue(AVKey.NETWORK_STATUS_TEST_SITES);

    if (testSites == null) {
      this.networkTestSites.addAll(Arrays.asList(DEFAULT_NETWORK_TEST_SITES));
    } else {
      String[] sites = testSites.split(",");
      List<String> actualSites = new ArrayList<String>(sites.length);

      for (String site : sites) {
        site = WWUtil.removeWhiteSpace(site);
        if (!WWUtil.isEmpty(site)) actualSites.add(site);
      }

      this.setNetworkTestSites(actualSites);
    }
  }
예제 #21
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 static String determineAllUserLocation() {
   if (gov.nasa.worldwind.Configuration.isMacOS()) {
     return "/Library/Caches";
   } else if (gov.nasa.worldwind.Configuration.isWindowsOS()) {
     String path = System.getenv("ALLUSERSPROFILE");
     if (path == null) {
       Logging.logger().severe("generic.AllUsersWindowsProfileNotKnown");
       return null;
     }
     return path + (Configuration.isWindows7OS() ? "" : "\\Application Data");
   } else if (gov.nasa.worldwind.Configuration.isLinuxOS()
       || gov.nasa.worldwind.Configuration.isUnixOS()
       || gov.nasa.worldwind.Configuration.isSolarisOS()) {
     return "/var/cache/";
   } else {
     Logging.logger().warning("generic.UnknownOperatingSystem");
     return null;
   }
 }
  public BasicNetworkStatus() {
    String oms = Configuration.getStringValue(AVKey.OFFLINE_MODE, "false");
    this.offlineMode = oms.startsWith("t") || oms.startsWith("T");

    this.establishNetworkTestSites();
  }
예제 #24
0
 public static void main(String[] args) {
   Configuration.setValue(AVKey.INITIAL_LATITUDE, 37.8432);
   Configuration.setValue(AVKey.INITIAL_LONGITUDE, -105.0527);
   Configuration.setValue(AVKey.INITIAL_ALTITUDE, 7000);
   ApplicationTemplate.start("World Wind Video on Terrain", AppFrame.class);
 }
예제 #25
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));
 }
예제 #26
0
    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();
    }
예제 #27
0
    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());
  }
예제 #29
0
  protected void setDeviceModifierActionMaps() {
    // Mouse Wheel Vertical Translation Event
    if (Configuration.isMacOS()) {
      this.addAction(
          DEVICE_MOUSE_WHEEL,
          ActionAttributes.NO_MODIFIER,
          VIEW_VERTICAL_TRANSLATE,
          new ActionAttributes(
              verticalTransMouseWheelEvents,
              ActionAttributes.ActionTrigger.ON_DRAG,
              DEFAULT_MOUSE_WHEEL_VERTICAL_TRANSLATE_VALUE_OSX,
              DEFAULT_MOUSE_WHEEL_VERTICAL_TRANSLATE_VALUE_OSX,
              DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_ENABLED,
              DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_VALUE));
    } else {
      this.addAction(
          DEVICE_MOUSE_WHEEL,
          ActionAttributes.NO_MODIFIER,
          VIEW_VERTICAL_TRANSLATE,
          new ActionAttributes(
              verticalTransMouseWheelEvents,
              ActionAttributes.ActionTrigger.ON_DRAG,
              DEFAULT_MOUSE_WHEEL_VERTICAL_TRANSLATE_VALUE,
              DEFAULT_MOUSE_WHEEL_VERTICAL_TRANSLATE_VALUE,
              DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_ENABLED,
              DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_VALUE));
    }

    // Mouse Button Move To Events
    this.addAction(
        DEVICE_MOUSE,
        ActionAttributes.NO_MODIFIER,
        VIEW_MOVE_TO,
        new ActionAttributes(
            moveToMouseEvents,
            ActionAttributes.ActionTrigger.ON_PRESS,
            DEFAULT_MOUSE_MOVE_TO_MIN_VALUE,
            DEFAULT_MOUSE_MOVE_TO_MAX_VALUE,
            DEFAULT_MOVE_TO_SMOOTHING_ENABLED,
            DEFAULT_MOVE_TO_SMOOTHING_VALUE));
    this.addAction(
        DEVICE_MOUSE,
        KeyEvent.ALT_DOWN_MASK,
        VIEW_MOVE_TO_SLOW,
        this.makeSlowActionAttributes(
            this.getActionAttributes(DEVICE_MOUSE, VIEW_MOVE_TO), DEFAULT_SLOW_VALUE));

    // Mouse Button Rotate Events
    this.addAction(
        DEVICE_MOUSE,
        ActionAttributes.NO_MODIFIER,
        VIEW_ROTATE,
        new ActionAttributes(
            rotateMouseEvents,
            ActionAttributes.ActionTrigger.ON_DRAG,
            DEFAULT_MOUSE_ROTATE_MIN_VALUE,
            DEFAULT_MOUSE_ROTATE_MAX_VALUE,
            DEFAULT_ROTATE_SMOOTHING_ENABLED,
            DEFAULT_ROTATE_SMOOTHING_VALUE));
    this.addAction(
        DEVICE_MOUSE,
        KeyEvent.SHIFT_DOWN_MASK,
        VIEW_ROTATE_SHIFT,
        new ActionAttributes(
            rotateMouseEventsShift,
            ActionAttributes.ActionTrigger.ON_DRAG,
            DEFAULT_MOUSE_ROTATE_MIN_VALUE,
            DEFAULT_MOUSE_ROTATE_MAX_VALUE,
            DEFAULT_ROTATE_SMOOTHING_ENABLED,
            DEFAULT_ROTATE_SMOOTHING_VALUE));

    // Mouse Button Horizontal Translate Events
    this.addAction(
        DEVICE_MOUSE,
        ActionAttributes.NO_MODIFIER,
        VIEW_HORIZONTAL_TRANSLATE,
        new ActionAttributes(
            horizontalTransMouseEvents,
            ActionAttributes.ActionTrigger.ON_DRAG,
            DEFAULT_MOUSE_HORIZONTAL_TRANSLATE_MIN_VALUE,
            DEFAULT_MOUSE_HORIZONTAL_TRANSLATE_MAX_VALUE,
            DEFAULT_HORIZONTAL_TRANSLATE_SMOOTHING_ENABLED,
            DEFAULT_HORIZONTAL_TRANSLATE_SMOOTHING_VALUE));

    // Mouse Button Vertical Translate Events
    this.addAction(
        DEVICE_MOUSE,
        ActionAttributes.NO_MODIFIER,
        VIEW_VERTICAL_TRANSLATE,
        new ActionAttributes(
            verticalTransMouseEvents,
            ActionAttributes.ActionTrigger.ON_DRAG,
            DEFAULT_MOUSE_VERTICAL_TRANSLATE_VALUE,
            DEFAULT_MOUSE_VERTICAL_TRANSLATE_VALUE,
            DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_ENABLED,
            DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_VALUE));
    this.addAction(
        DEVICE_MOUSE,
        KeyEvent.CTRL_DOWN_MASK,
        VIEW_VERTICAL_TRANSLATE_CTRL,
        new ActionAttributes(
            verticalTransMouseEventsCtrl,
            ActionAttributes.ActionTrigger.ON_DRAG,
            DEFAULT_MOUSE_VERTICAL_TRANSLATE_VALUE,
            DEFAULT_MOUSE_VERTICAL_TRANSLATE_VALUE,
            DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_ENABLED,
            DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_VALUE));
    this.addAction(
        DEVICE_MOUSE,
        KeyEvent.META_DOWN_MASK,
        VIEW_VERTICAL_TRANSLATE_CTRL,
        new ActionAttributes(
            verticalTransMouseEventsCtrl,
            ActionAttributes.ActionTrigger.ON_DRAG,
            DEFAULT_MOUSE_VERTICAL_TRANSLATE_VALUE,
            DEFAULT_MOUSE_VERTICAL_TRANSLATE_VALUE,
            DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_ENABLED,
            DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_VALUE));

    // Keyboard Rotation Actions
    this.addAction(
        DEVICE_KEYBOARD,
        KeyEvent.SHIFT_DOWN_MASK,
        VIEW_ROTATE_KEYS_SHIFT,
        new ActionAttributes(
            rotationKeyEvents,
            ActionAttributes.ActionTrigger.ON_KEY_DOWN,
            KeyEvent.SHIFT_DOWN_MASK,
            DEFAULT_KEY_ROTATE_MIN_VALUE,
            DEFAULT_KEY_ROTATE_MAX_VALUE,
            DEFAULT_ROTATE_SMOOTHING_ENABLED,
            DEFAULT_ROTATE_SMOOTHING_VALUE));

    this.addAction(
        DEVICE_KEYBOARD,
        ActionAttributes.NO_MODIFIER,
        VIEW_ROTATE_KEYS,
        new ActionAttributes(
            rotationKeyEventsPage,
            ActionAttributes.ActionTrigger.ON_KEY_DOWN,
            ActionAttributes.NO_MODIFIER,
            DEFAULT_KEY_ROTATE_MIN_VALUE,
            DEFAULT_KEY_ROTATE_MAX_VALUE,
            DEFAULT_ROTATE_SMOOTHING_ENABLED,
            DEFAULT_ROTATE_SMOOTHING_VALUE));

    this.addAction(
        DEVICE_KEYBOARD,
        KeyEvent.SHIFT_DOWN_MASK | KeyEvent.ALT_DOWN_MASK,
        VIEW_ROTATE_KEYS_SHIFT_SLOW,
        this.makeSlowActionAttributes(
            this.getActionAttributes(DEVICE_KEYBOARD, VIEW_ROTATE_KEYS_SHIFT), DEFAULT_SLOW_VALUE));
    this.addAction(
        DEVICE_KEYBOARD,
        KeyEvent.ALT_DOWN_MASK,
        VIEW_ROTATE_SLOW,
        this.makeSlowActionAttributes(
            this.getActionAttributes(DEVICE_KEYBOARD, VIEW_ROTATE_KEYS), DEFAULT_SLOW_VALUE));

    // Keyboard Roll Actions
    this.addAction(
        DEVICE_KEYBOARD,
        KeyEvent.CTRL_DOWN_MASK,
        VIEW_ROLL_KEYS,
        new ActionAttributes(
            rollKeyEvents,
            ActionAttributes.ActionTrigger.ON_KEY_DOWN,
            KeyEvent.CTRL_DOWN_MASK,
            DEFAULT_KEY_ROLL_MIN_VALUE,
            DEFAULT_KEY_ROLL_MAX_VALUE,
            DEFAULT_ROLL_SMOOTHING_ENABLED,
            DEFAULT_ROLL_SMOOTHING_VALUE));

    // Keyboard Horizontal Translation Actions
    this.addAction(
        DEVICE_KEYBOARD,
        ActionAttributes.NO_MODIFIER,
        VIEW_HORIZONTAL_TRANS_KEYS,
        new ActionAttributes(
            horizontalTransKeyEvents,
            ActionAttributes.ActionTrigger.ON_KEY_DOWN,
            0,
            DEFAULT_KEY_HORIZONTAL_TRANSLATE_MIN_VALUE,
            DEFAULT_KEY_HORIZONTAL_TRANSLATE_MAX_VALUE,
            DEFAULT_HORIZONTAL_TRANSLATE_SMOOTHING_ENABLED,
            DEFAULT_HORIZONTAL_TRANSLATE_SMOOTHING_VALUE));
    this.addAction(
        DEVICE_KEYBOARD,
        KeyEvent.ALT_DOWN_MASK,
        VIEW_HORIZONTAL_TRANSLATE_SLOW,
        this.makeSlowActionAttributes(
            this.getActionAttributes(DEVICE_KEYBOARD, VIEW_HORIZONTAL_TRANS_KEYS),
            DEFAULT_SLOW_VALUE));

    // Vertical Translation Actions
    this.addAction(
        DEVICE_KEYBOARD,
        ActionAttributes.NO_MODIFIER,
        VIEW_VERTICAL_TRANS_KEYS,
        new ActionAttributes(
            verticalTransKeyEvents,
            ActionAttributes.ActionTrigger.ON_KEY_DOWN,
            0,
            DEFAULT_KEY_VERTICAL_TRANSLATE_VALUE,
            DEFAULT_KEY_VERTICAL_TRANSLATE_VALUE,
            DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_ENABLED,
            DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_VALUE));
    this.addAction(
        DEVICE_KEYBOARD,
        KeyEvent.ALT_DOWN_MASK,
        VIEW_VERTICAL_TRANS_KEYS_SLOW,
        this.makeSlowActionAttributes(
            this.getActionAttributes(DEVICE_KEYBOARD, VIEW_VERTICAL_TRANS_KEYS),
            DEFAULT_SLOW_VALUE));

    this.addAction(
        DEVICE_KEYBOARD,
        KeyEvent.CTRL_DOWN_MASK,
        VIEW_VERTICAL_TRANS_KEYS_CTRL,
        new ActionAttributes(
            verticalTransKeyEventsCtrl,
            ActionAttributes.ActionTrigger.ON_KEY_DOWN,
            (KeyEvent.CTRL_DOWN_MASK),
            DEFAULT_KEY_VERTICAL_TRANSLATE_VALUE,
            DEFAULT_KEY_VERTICAL_TRANSLATE_VALUE,
            DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_ENABLED,
            DEFAULT_VERTICAL_TRANSLATE_SMOOTHING_VALUE));
    this.addAction(
        DEVICE_KEYBOARD,
        KeyEvent.META_DOWN_MASK,
        VIEW_VERTICAL_TRANS_KEYS_META,
        this.getActionAttributes(DEVICE_KEYBOARD, VIEW_VERTICAL_TRANS_KEYS));
    this.addAction(
        DEVICE_KEYBOARD,
        KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK,
        VIEW_VERTICAL_TRANS_KEYS_SLOW_CTRL,
        this.makeSlowActionAttributes(
            this.getActionAttributes(DEVICE_KEYBOARD, VIEW_VERTICAL_TRANS_KEYS_CTRL),
            DEFAULT_SLOW_VALUE));
    this.addAction(
        DEVICE_KEYBOARD,
        KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK,
        VIEW_VERTICAL_TRANS_KEYS_SLOW_META,
        this.makeSlowActionAttributes(
            this.getActionAttributes(DEVICE_KEYBOARD, VIEW_VERTICAL_TRANS_KEYS_CTRL),
            DEFAULT_SLOW_VALUE));

    // Reset Heading Action
    this.addAction(
        DEVICE_KEYBOARD,
        ActionAttributes.NO_MODIFIER,
        VIEW_RESET_HEADING,
        new ActionAttributes(
            resetHeadingEvents,
            ActionAttributes.ActionTrigger.ON_PRESS,
            0,
            DEFAULT_KEY_ROTATE_MIN_VALUE,
            DEFAULT_KEY_ROTATE_MAX_VALUE,
            DEFAULT_ROTATE_SMOOTHING_ENABLED,
            DEFAULT_ROTATE_SMOOTHING_VALUE));
    // Reset Heading, Pitch, and Roll Action
    this.addAction(
        DEVICE_KEYBOARD,
        ActionAttributes.NO_MODIFIER,
        VIEW_RESET_HEADING_PITCH_ROLL,
        new ActionAttributes(
            resetHeadingPitchRollEvents,
            ActionAttributes.ActionTrigger.ON_PRESS,
            0,
            DEFAULT_KEY_ROTATE_MIN_VALUE,
            DEFAULT_KEY_ROTATE_MAX_VALUE,
            DEFAULT_ROTATE_SMOOTHING_ENABLED,
            DEFAULT_ROTATE_SMOOTHING_VALUE));
    // Stop View Action
    this.addAction(
        DEVICE_KEYBOARD,
        ActionAttributes.NO_MODIFIER,
        VIEW_STOP_VIEW,
        new ActionAttributes(
            stopViewEvents, ActionAttributes.ActionTrigger.ON_PRESS, 0, 0.1, 0.1, false, 0.1));
  }