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);
  }
  protected static void makeMenu(final AppFrame appFrame) {
    JMenuBar menuBar = new JMenuBar();
    appFrame.setJMenuBar(menuBar);
    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);

    JMenuItem openWfsItem =
        new JMenuItem(
            new AbstractAction("Add WFS layer...") {
              @Override
              public void actionPerformed(ActionEvent actionEvent) {
                JDialog dialog = new JDialog(appFrame, "Import WFS layer", true);
                WfsPanel wfsPanel = new WfsPanel();
                wfsPanel.setDialog(dialog);
                Dimension dimension = wfsPanel.getPreferredSize();
                dimension.setSize(dimension.getWidth() + 10, dimension.getHeight() + 25);
                dialog.getContentPane().add(wfsPanel);
                dialog.setSize(dimension);
                dialog.setModal(true);
                dialog.setVisible(true);

                if (wfsPanel.isConfirmed()) {
                  String url = wfsPanel.getUrl();
                  String name = wfsPanel.getFeatureName();
                  Sector sector = wfsPanel.getSector();
                  double dist = wfsPanel.getVisibleDistance();
                  Angle tile = wfsPanel.getTileDelta();
                  Color color = wfsPanel.getColor();
                  String lineLabelTag = wfsPanel.getFeatureLableTypeName();

                  try {
                    addWfsLayer(url, name, sector, tile, dist * 1000, color, lineLabelTag);
                  } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Error: " + e.getMessage());
                  }
                }

                dialog.dispose();
              }
            });

    fileMenu.add(openWfsItem);

    JMenuItem quitItem =
        new JMenuItem(
            new AbstractAction("Quit") {
              @Override
              public void actionPerformed(ActionEvent e) {
                System.exit(0);
              }
            });
    fileMenu.add(quitItem);

    JMenu optionsMenu = new JMenu("Shading");
    menuBar.add(optionsMenu);
    ButtonGroup optionsGroup = new ButtonGroup();

    JMenuItem wwShading =
        new ShadingItem(new boolean[] {false, false, false, false}, "Default World Wind");
    optionsMenu.add(wwShading);
    optionsGroup.add(wwShading);
    JMenuItem gaeaShading =
        new ShadingItem(new boolean[] {true, true, true, false}, "Advanced Gaea+ shading");
    optionsMenu.add(gaeaShading);
    optionsGroup.add(gaeaShading);
    JMenuItem shadows =
        new ShadingItem(
            new boolean[] {true, true, true, true}, "Advanced Gaea+ shading with shadows");
    optionsMenu.add(shadows);
    optionsGroup.add(shadows);

    // depending on support for advanced shading, enable/disable menu items and select appropriate
    // shading model
    boolean gaeaShadingSupported = isGaeaShadingSupported(appFrame.getWwd());

    gaeaShading.setEnabled(gaeaShadingSupported);
    shadows.setEnabled(gaeaShadingSupported);
    if (gaeaShadingSupported) gaeaShading.doClick();
    else {
      wwShading.doClick();
      // if gaea shading is not supported by GPU/driver, we also have to remove the run-time
      // calculated layers
      ArrayList<Layer> unsupportedLayers = new ArrayList<Layer>();
      for (Layer layer : appFrame.getWwd().getModel().getLayers()) {
        if (layer instanceof SlopeLayer || layer instanceof ElevationLayer)
          unsupportedLayers.add(layer);
      }
      appFrame.getWwd().getModel().getLayers().removeAll(unsupportedLayers);
      if (appFrame instanceof GaeaAppFrame) ((GaeaAppFrame) appFrame).updateLayerPanel();
    }

    JMenu helpMenu = new JMenu("Help");
    menuBar.add(helpMenu);
    String licenseMsg =
        "This application, together with the NASA World Wind Java SDK and the modifications to the SDK done by XLAB d.o.o.,"
            + "are distributed under the terms of NASA Open Source Agreement license.\n"
            + "You should have received this license together with this application. If not, please contact [email protected] or visit http://www.gaeaplus.eu.\n\n"
            + "The data layers included in this application are either licensed for use in World Wind, owned by XLAB d.o.o., or available for free from servers intended for public use.";
    helpMenu.add(new MessageItem(licenseMsg, "Terms of use"));
    String aboutMsg =
        "This is a demonstration of features that Gaea+ Open Source adds to NASA World Wind Java SDK.\n"
            + "For more information, visit http://www.gaeaplus.eu/en/, https://github.com/gaeaplus/gaeaplus, and http://worldwind.arc.nasa.gov/java/.";
    helpMenu.add(new MessageItem(aboutMsg, "About..."));
  }