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);
  }
Example #2
0
 public void save() {
   Configuration config = Configuration.getInstance();
   Properties props = config.props;
   props.setProperty("mx", maxMemory.tf.getText().trim());
   props.setProperty("ms", initMemory.tf.getText().trim());
   props.setProperty("ss", stackSize.tf.getText().trim());
   props.setProperty("ext", extDirs.tf.getText().trim());
   props.setProperty("clr", (clearLogs.cb.isSelected() ? "yes" : "no"));
   props.setProperty("ssl", (debugSSL.cb.isSelected() ? "yes" : "no"));
   props.setProperty("mon", (javaMonitor.cb.isSelected() ? "yes" : "no"));
   config.save();
 }
  public JungGraphObserver(String name) {
    this.name = name;
    this.hyphadataPid = Configuration.getPid(PAR_HYPHADATA_PROTO);
    this.hyphalinkPid = Configuration.getPid(PAR_HYPHALINK_PROTO);
    this.mycocastPid = Configuration.getPid(PAR_MYCOCAST_PROTO);
    this.period = Configuration.getInt(name + "." + PAR_PERIOD);

    this.walkDelay = Configuration.getInt(name + "." + PAR_WALK_DELAY);
    mainThread = Thread.currentThread();
    this.changeListeners = new HashSet<ChangeListener>();

    visualizer = null;

    // HyphaData.addHyphaDataListener(this);
    // HyphaLink.addHyphaLinkListener(this);
  }
Example #4
0
 private void run() {
   int port = Util.getInt(serverPort.tf.getText().trim(), config.port);
   if (port != config.port) {
     try {
       Element server = Util.getFirstNamedChild(config.configXML, "Server");
       server.setAttribute("port", Integer.toString(port));
       config.saveXML();
       config.port = port;
     } catch (Exception unable) {
     }
     serverPort.tf.setText(Integer.toString(config.port));
   }
   save();
   if (!running) {
     runner = Util.startup();
     Util.wait(500);
     running = runner.isAlive();
     if (running) {
       monitor = new Monitor(runner);
       monitor.start();
     }
   }
   setStatus();
 }
Example #5
0
 public void actionPerformed(ActionEvent event) {
   if (event.getSource().equals(launchBrowser)) {
     Configuration config = Configuration.getInstance();
     String ip = Util.getIPAddress();
     String protocol = "http" + (config.ssl ? "s" : "");
     String url = protocol + "://" + ip + ":" + config.port;
     Util.openURL(url);
   } else if (event.getSource().equals(stop)) {
     Util.shutdown();
     running = Util.isRunning();
     setStatus();
   } else if (event.getSource().equals(start)) {
     clearLogsDir();
     run();
     launchBrowser.requestFocusInWindow();
   }
 }
Example #6
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);
 }
    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();
    }
Example #9
0
  public JavaPanel() {
    super();
    setLayout(new BorderLayout());
    config = Configuration.getInstance();
    Properties props = config.props;
    running = false;
    Util.isRunning();

    JPanel main = new JPanel();
    main.setLayout(new BorderLayout());
    main.setBackground(bgColor);

    // North Panel
    JPanel np = new JPanel();
    np.setBackground(bgColor);
    JLabel title = new JLabel(config.programName);
    title.setFont(new Font("SansSerif", Font.BOLD, 24));
    title.setForeground(Color.BLUE);
    np.add(title);
    np.setBorder(BorderFactory.createEmptyBorder(10, 0, 20, 0));
    main.add(np, BorderLayout.NORTH);

    // Center Panel
    RowPanel javaPanel = new RowPanel("Java Parameters");
    javaPanel.setBackground(bgColor);
    javaPanel.addRow(initMemory = new Row("Initial memory pool:", props.getProperty("ms", "")));
    javaPanel.addRow(maxMemory = new Row("Maximum memory pool:", props.getProperty("mx", "")));
    javaPanel.addRow(stackSize = new Row("Thread stack size:", props.getProperty("ss", "")));
    javaPanel.addRow(extDirs = new Row("Extensions directory:", props.getProperty("ext", "")));
    javaPanel.addRow(
        debugSSL = new CBRow("Enable SSL debugging:", props.getProperty("ssl", "").equals("yes")));
    javaPanel.addRow(
        javaMonitor =
            new CBRow("Enable Java monitoring:", props.getProperty("mon", "").equals("yes")));

    RowPanel serverPanel = new RowPanel("Server Parameters");
    serverPanel.setBackground(bgColor);
    serverPanel.addRow(serverPort = new Row("Server port:", Integer.toString(config.port)));
    serverPanel.addRow(
        clearLogs = new CBRow("Clear logs on start:", props.getProperty("clr", "").equals("yes")));

    JPanel cp = new JPanel();
    cp.setLayout(new RowLayout());
    cp.setBackground(bgColor);

    cp.add(serverPanel);
    cp.add(RowLayout.crlf());
    cp.add(Box.createVerticalStrut(20));
    cp.add(RowLayout.crlf());
    cp.add(javaPanel);
    cp.add(RowLayout.crlf());

    JPanel ccp = new JPanel(new FlowLayout());
    ccp.setBackground(bgColor);
    ccp.add(cp);
    main.add(ccp, BorderLayout.CENTER);

    // South Panel
    JPanel sp = new JPanel();
    sp.setBorder(BorderFactory.createEmptyBorder(10, 0, 20, 0));
    sp.setBackground(bgColor);

    start = new JButton("Start");
    sp.add(start);
    start.addActionListener(this);
    sp.add(Box.createHorizontalStrut(15));

    stop = new JButton("Stop");
    sp.add(stop);
    stop.addActionListener(this);
    sp.add(Box.createHorizontalStrut(70));

    launchBrowser = new JButton(config.browserButtonName + " Home Page");
    sp.add(launchBrowser);
    launchBrowser.addActionListener(this);

    main.add(sp, BorderLayout.SOUTH);

    this.add(main, BorderLayout.CENTER);
    this.add(new StatusPanel(status), BorderLayout.SOUTH);

    running = Util.isRunning();
    setStatus();
  }
  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());
  }
 public void actionPerformed(ActionEvent event) {
   ProjectBrowser.TheInstance.saveScreenConfiguration();
   if (!Configuration.save()) Configuration.save(true);
 }