Пример #1
0
  private void makeActionsToolbars() {

    navToolbarAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            Boolean state = (Boolean) getValue(BAMutil.STATE);
            if (state.booleanValue()) toolPanel.add(navToolbar);
            else toolPanel.remove(navToolbar);
          }
        };
    BAMutil.setActionProperties(
        navToolbarAction, "MagnifyPlus", "show Navigate toolbar", true, 'M', 0);
    navToolbarAction.putValue(
        BAMutil.STATE, new Boolean(store.getBoolean("navToolbarAction", true)));

    moveToolbarAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            Boolean state = (Boolean) getValue(BAMutil.STATE);
            if (state.booleanValue()) toolPanel.add(moveToolbar);
            else toolPanel.remove(moveToolbar);
          }
        };
    BAMutil.setActionProperties(moveToolbarAction, "Up", "show Move toolbar", true, 'M', 0);
    moveToolbarAction.putValue(
        BAMutil.STATE, new Boolean(store.getBoolean("moveToolbarAction", true)));
  }
Пример #2
0
  public GridUI(
      PreferencesExt pstore, RootPaneContainer root, FileManager fileChooser, int defaultHeight) {
    // this.topUI = topUI;
    this.store = pstore;
    this.fileChooser = fileChooser;

    try {
      choosers = new ArrayList();
      fieldChooser = new SuperComboBox(root, "field", true, null);
      choosers.add(new Chooser("field", fieldChooser, true));
      levelChooser = new SuperComboBox(root, "level", false, null);
      choosers.add(new Chooser("level", levelChooser, false));
      timeChooser = new SuperComboBox(root, "time", false, null);
      choosers.add(new Chooser("time", timeChooser, false));
      ensembleChooser = new SuperComboBox(root, "ensemble", false, null);
      choosers.add(new Chooser("ensemble", ensembleChooser, false));
      runtimeChooser = new SuperComboBox(root, "runtime", false, null);
      choosers.add(new Chooser("runtime", runtimeChooser, false));

      makeActionsDataset();
      makeActionsToolbars();

      gridTable = new GridTable("field");
      gtWindow =
          new IndependentWindow(
              "Grid Table Information", BAMutil.getImage("GDVs"), gridTable.getPanel());

      PreferencesExt dsNode = (PreferencesExt) pstore.node("DatasetTable");
      dsTable = new GeoGridTable(dsNode, true);
      dsDialog = dsTable.makeDialog(root, "NetcdfDataset Info", false);
      // dsDialog.setIconImage( BAMutil.getImage( "GDVs"));
      Rectangle bounds =
          (Rectangle) dsNode.getBean("DialogBounds", new Rectangle(50, 50, 800, 450));
      dsDialog.setBounds(bounds);

      controller = new GridController(this, store);
      makeUI(defaultHeight);
      controller.finishInit();

      // other components
      geotiffFileChooser = new FileManager(parent);
      geotiffFileChooser.setCurrentDirectory(store.get(GEOTIFF_FILECHOOSER_DEFAULTDIR, "."));

    } catch (Exception e) {
      System.out.println("UI creation failed");
      e.printStackTrace();
    }
  }
Пример #3
0
 LoopControlAction(SuperComboBox cbox) {
   this.scbox = cbox;
   BAMutil.setActionProperties(this, null, cbox.getName(), false, 0, 0);
 }
Пример #4
0
  void addActionsToMenus(JMenu datasetMenu, JMenu configMenu, JMenu toolMenu) {
    // Info
    BAMutil.addActionToMenu(datasetMenu, showGridTableAction);
    BAMutil.addActionToMenu(datasetMenu, showDatasetInfoAction);
    BAMutil.addActionToMenu(datasetMenu, showNcMLAction);
    BAMutil.addActionToMenu(datasetMenu, showGridDatasetInfoAction);
    BAMutil.addActionToMenu(datasetMenu, showNetcdfDatasetAction);
    // BAMutil.addActionToMenu( datasetMenu, geotiffAction);
    // BAMutil.addActionToMenu( infoMenu, showNetcdfXMLAction);

    /// Configure
    JMenu toolbarMenu = new JMenu("Toolbars");
    toolbarMenu.setMnemonic('T');
    configMenu.add(toolbarMenu);
    BAMutil.addActionToMenu(toolbarMenu, navToolbarAction);
    BAMutil.addActionToMenu(toolbarMenu, moveToolbarAction);

    BAMutil.addActionToMenu(configMenu, chooseProjectionAction);
    BAMutil.addActionToMenu(configMenu, saveCurrentProjectionAction);

    /* BAMutil.addActionToMenu( configMenu, chooseColorScaleAction);
    BAMutil.addActionToMenu( configMenu, controller.dataProjectionAction);
    */

    //// tools menu
    JMenu displayMenu = new JMenu("Display control");
    displayMenu.setMnemonic('D');

    BAMutil.addActionToMenu(displayMenu, controller.showGridAction);
    BAMutil.addActionToMenu(displayMenu, controller.showContoursAction);
    BAMutil.addActionToMenu(displayMenu, controller.showContourLabelsAction);
    BAMutil.addActionToMenu(displayMenu, redrawAction);
    toolMenu.add(displayMenu);

    // Loop Control
    JMenu loopMenu = new JMenu("Loop control");
    loopMenu.setMnemonic('L');

    BAMutil.addActionToMenu(loopMenu, fieldLoopAction);
    BAMutil.addActionToMenu(loopMenu, levelLoopAction);
    BAMutil.addActionToMenu(loopMenu, timeLoopAction);
    toolMenu.add(loopMenu);

    // MinMax Control
    JMenu mmMenu = new JMenu("ColorScale min/max");
    mmMenu.setMnemonic('C');
    BAMutil.addActionToMenu(mmMenu, minmaxHorizAction);
    BAMutil.addActionToMenu(mmMenu, minmaxLogAction);
    BAMutil.addActionToMenu(mmMenu, minmaxHoldAction);
    toolMenu.add(mmMenu);

    // Zoom/Pan
    JMenu zoomMenu = new JMenu("Zoom/Pan");
    zoomMenu.setMnemonic('Z');
    panz.addActionsToMenu(zoomMenu); // items are added by NavigatedPanelToolbar
    toolMenu.add(zoomMenu);
  }
Пример #5
0
  private void makeUI(int defaultHeight) {

    datasetNameLabel = new JLabel();
    /* gridPP = new PrefPanel("GridView", (PreferencesExt) store.node("GridViewPrefs"));
    gridUrlIF = gridPP.addTextComboField("url", "Gridded Data URL", null, 10, false);
    gridPP.addButton( BAMutil.makeButtconFromAction( chooseLocalDatasetAction ));
    gridPP.finish(true, BorderLayout.EAST);
    gridPP.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        InvDatasetImpl ds = new InvDatasetImpl( gridUrlIF.getText(), thredds.catalog.DataType.GRID, ServiceType.NETCDF);
        setDataset( ds);
      }
    }); */

    // top tool panel
    toolPanel = new JPanel();
    toolPanel.setBorder(new EtchedBorder());
    toolPanel.setLayout(new MFlowLayout(FlowLayout.LEFT, 0, 0));

    // menus
    JMenu dataMenu = new JMenu("Dataset");
    dataMenu.setMnemonic('D');
    configMenu = new JMenu("Configure");
    configMenu.setMnemonic('C');
    JMenu toolMenu = new JMenu("Controls");
    toolMenu.setMnemonic('T');
    addActionsToMenus(dataMenu, configMenu, toolMenu);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(dataMenu);
    menuBar.add(configMenu);
    menuBar.add(toolMenu);
    toolPanel.add(menuBar);

    // field choosers
    fieldPanel = new JPanel();
    fieldPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    toolPanel.add(fieldPanel);

    // stride
    toolPanel.add(controller.strideSpinner);

    // buttcons
    BAMutil.addActionToContainer(toolPanel, controller.drawHorizAction);
    BAMutil.addActionToContainer(toolPanel, controller.drawVertAction);
    mapBeanMenu = MapBean.makeMapSelectButton();
    toolPanel.add(mapBeanMenu.getParentComponent());

    // the Navigated panel and its toolbars
    panz.setLayout(new FlowLayout());
    navToolbar = panz.getNavToolBar();
    moveToolbar = panz.getMoveToolBar();
    if (((Boolean) navToolbarAction.getValue(BAMutil.STATE)).booleanValue())
      toolPanel.add(navToolbar);
    if (((Boolean) moveToolbarAction.getValue(BAMutil.STATE)).booleanValue())
      toolPanel.add(moveToolbar);

    BAMutil.addActionToContainer(toolPanel, panz.setReferenceAction);
    BAMutil.addActionToContainer(toolPanel, controller.dataProjectionAction);
    BAMutil.addActionToContainer(toolPanel, controller.showGridAction);
    BAMutil.addActionToContainer(toolPanel, controller.showContoursAction);
    BAMutil.addActionToContainer(toolPanel, controller.showContourLabelsAction);

    BAMutil.addActionToContainer(toolPanel, redrawAction);

    //  vertical split
    vertPanel = new VertPanel();
    splitDraw = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panz, vertPanel);
    int divLoc = store.getInt("vertSplit", 2 * defaultHeight / 3);
    splitDraw.setDividerLocation(divLoc);
    drawingPanel = new JPanel(new BorderLayout()); // filled later

    // status panel
    JPanel statusPanel = new JPanel(new BorderLayout());
    statusPanel.setBorder(new EtchedBorder());
    positionLabel = new JLabel("position");
    positionLabel.setToolTipText("position at cursor");
    dataValueLabel = new JLabel("data value", SwingConstants.CENTER);
    dataValueLabel.setToolTipText("data value (double click on grid)");
    statusPanel.add(positionLabel, BorderLayout.WEST);
    statusPanel.add(dataValueLabel, BorderLayout.CENTER);
    panz.setPositionLabel(positionLabel);

    // colorscale panel
    colorScalePanel = new ColorScale.Panel(this, controller.getColorScale());
    csDataMinMax = new JComboBox(GridRenderer.MinMaxType.values());
    csDataMinMax.setToolTipText("ColorScale Min/Max setting");
    csDataMinMax.addActionListener(
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            controller.setDataMinMaxType((GridRenderer.MinMaxType) csDataMinMax.getSelectedItem());
          }
        });
    JPanel westPanel = new JPanel(new BorderLayout());
    westPanel.add(colorScalePanel, BorderLayout.CENTER);
    westPanel.add(csDataMinMax, BorderLayout.NORTH);

    // lay it out
    JPanel northPanel = new JPanel();
    // northPanel.setLayout( new BoxLayout(northPanel, BoxLayout.Y_AXIS));
    northPanel.setLayout(new BorderLayout());
    northPanel.add(datasetNameLabel, BorderLayout.NORTH);
    northPanel.add(toolPanel, BorderLayout.SOUTH);

    setLayout(new BorderLayout());
    add(northPanel, BorderLayout.NORTH);
    add(statusPanel, BorderLayout.SOUTH);
    add(westPanel, BorderLayout.WEST);
    add(drawingPanel, BorderLayout.CENTER);

    setDrawHorizAndVert(controller.drawHorizOn, controller.drawVertOn);
  }
Пример #6
0
  // actions that control the dataset
  private void makeActionsDataset() {

    // choose local dataset
    AbstractAction chooseLocalDatasetAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            String filename = fileChooser.chooseFilename();
            if (filename == null) return;

            InvDataset invDs;
            try {
              invDs = new InvDatasetImpl(filename, FeatureType.GRID, ServiceType.NETCDF);
            } catch (Exception ue) {
              JOptionPane.showMessageDialog(
                  GridUI.this, "Invalid filename = <" + filename + ">\n" + ue.getMessage());
              ue.printStackTrace();
              return;
            }
            setDataset(invDs);
          }
        };
    BAMutil.setActionProperties(
        chooseLocalDatasetAction, "FileChooser", "open Local dataset...", false, 'L', -1);

    /* saveDatasetAction = new AbstractAction() {
      public void actionPerformed(ActionEvent e) {
        String fname = controller.getDatasetName();
        if (fname != null) {
          savedDatasetList.add( fname);
          BAMutil.addActionToMenu( savedDatasetMenu, new DatasetAction( fname), 0);
        }
      }
    };
    BAMutil.setActionProperties( saveDatasetAction, null, "save dataset", false, 'S', 0);
    */

    // Configure
    chooseProjectionAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            getProjectionManager().setVisible();
          }
        };
    BAMutil.setActionProperties(
        chooseProjectionAction, null, "Projection Manager...", false, 'P', 0);

    saveCurrentProjectionAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            getProjectionManager();
            // set the bounding box
            ProjectionImpl proj = panz.getProjectionImpl().constructCopy();
            proj.setDefaultMapArea(panz.getMapArea());
            // if (debug) System.out.println(" GV save projection "+ proj);

            // projManage.setMap(renderAll.get("Map"));   LOOK!
            // projManager.saveProjection( proj);
          }
        };
    BAMutil.setActionProperties(
        saveCurrentProjectionAction, null, "save Current Projection", false, 'S', 0);

    /* chooseColorScaleAction = new AbstractAction() {
      public void actionPerformed(ActionEvent e) {
        if (null == csManager) // lazy instantiation
          makeColorScaleManager();
        csManager.show();
      }
    };
    BAMutil.setActionProperties( chooseColorScaleAction, null, "ColorScale Manager...", false, 'C', 0);

    */
    // redraw
    redrawAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            repaint();
            controller.start(true);
            controller.draw(true);
          }
        };
    BAMutil.setActionProperties(redrawAction, "alien", "RedRaw", false, 'W', 0);

    showDatasetInfoAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (infoWindow == null) {
              datasetInfoTA = new TextHistoryPane();
              infoWindow =
                  new IndependentWindow(
                      "Dataset Information", BAMutil.getImage("GDVs"), datasetInfoTA);
              infoWindow.setSize(700, 700);
              infoWindow.setLocation(100, 100);
            }

            datasetInfoTA.clear();
            datasetInfoTA.appendLine(controller.getDatasetInfo());
            datasetInfoTA.gotoTop();
            infoWindow.show();
          }
        };
    BAMutil.setActionProperties(
        showDatasetInfoAction, "Information", "Show info...", false, 'S', -1);

    showNcMLAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (ncmlWindow == null) {
              ncmlTA = new TextHistoryPane();
              ncmlWindow = new IndependentWindow("Dataset NcML", BAMutil.getImage("GDVs"), ncmlTA);
              ncmlWindow.setSize(700, 700);
              ncmlWindow.setLocation(200, 70);
            }

            ncmlTA.clear();
            // datasetInfoTA.appendLine( "GeoGrid XML for "+ controller.getDatasetName()+"\n");
            ncmlTA.appendLine(controller.getNcML());
            ncmlTA.gotoTop();
            ncmlWindow.show();
          }
        };
    BAMutil.setActionProperties(showNcMLAction, null, "Show NcML...", false, 'X', -1);

    showGridDatasetInfoAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (ncmlWindow == null) {
              ncmlTA = new TextHistoryPane();
              ncmlWindow = new IndependentWindow("Dataset NcML", BAMutil.getImage("GDVs"), ncmlTA);
              ncmlWindow.setSize(700, 700);
              ncmlWindow.setLocation(200, 70);
            }

            ncmlTA.clear();
            // datasetInfoTA.appendLine( "GeoGrid XML for "+ controller.getDatasetName()+"\n");
            ncmlTA.appendLine(controller.getDatasetXML());
            ncmlTA.gotoTop();
            ncmlWindow.show();
          }
        };
    BAMutil.setActionProperties(
        showGridDatasetInfoAction, null, "Show GridDataset Info XML...", false, 'X', -1);

    // show gridTable
    showGridTableAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            gtWindow.show();
          }
        };
    BAMutil.setActionProperties(showGridTableAction, "Table", "grid Table...", false, 'T', -1);

    // show netcdf dataset Table
    showNetcdfDatasetAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            NetcdfDataset netcdfDataset = controller.getNetcdfDataset();
            if (null != netcdfDataset) {
              try {
                dsTable.setDataset(netcdfDataset, null);
              } catch (IOException e1) {
                e1.printStackTrace();
                return;
              }
              dsDialog.show();
            }
          }
        };
    BAMutil.setActionProperties(
        showNetcdfDatasetAction, "netcdf", "NetcdfDataset Table Info...", false, 'D', -1);

    /* write geotiff file
    geotiffAction = new AbstractAction() {
      public void actionPerformed(ActionEvent e) {
        GeoGrid grid = controller.getCurrentField();
        ucar.ma2.Array data = controller.getCurrentHorizDataSlice();
        if ((grid == null) || (data == null)) return;

        String filename = geotiffFileChooser.chooseFilename();
        if (filename == null) return;

        GeoTiff geotiff = null;
        try {
          /* System.out.println("write to= "+filename);
          ucar.nc2.geotiff.Writer.write2D(grid, data, filename+".tfw");
          geotiff = new GeoTiff(filename); // read back in
          geotiff.read();
          System.out.println( geotiff.showInfo());
          //geotiff.testReadData();
          geotiff.close(); * /

          // write two
          ucar.nc2.geotiff.GeotiffWriter writer = new ucar.nc2.geotiff.GeotiffWriter(filename);
          writer.writeGrid(grid, data, false);
          geotiff = new GeoTiff(filename); // read back in
          geotiff.read();
          System.out.println( "*************************************");
          System.out.println( geotiff.showInfo());
          //geotiff.testReadData();
          geotiff.close();


        } catch (IOException ioe) {
          ioe.printStackTrace();

        } finally {
          try {
            if (geotiff != null) geotiff.close();
          } catch (IOException ioe) { }
        }

      }
    };
    BAMutil.setActionProperties( geotiffAction, "Geotiff", "Write Geotiff file", false, 'G', -1);
    */

    minmaxHorizAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            csDataMinMax.setSelectedItem(GridRenderer.MinMaxType.horiz);
            controller.setDataMinMaxType(GridRenderer.MinMaxType.horiz);
          }
        };
    BAMutil.setActionProperties(minmaxHorizAction, null, "Horizontal plane", false, 'H', 0);

    minmaxLogAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            csDataMinMax.setSelectedItem(GridRenderer.MinMaxType.log);
            controller.setDataMinMaxType(GridRenderer.MinMaxType.log);
          }
        };
    BAMutil.setActionProperties(minmaxLogAction, null, "log horiz plane", false, 'V', 0);

    /* minmaxVolAction =  new AbstractAction() {
      public void actionPerformed(ActionEvent e) {
        csDataMinMax.setSelectedIndex(GridRenderer.VOL_MinMaxType);
        controller.setDataMinMaxType(GridRenderer.MinMaxType.vert;
      }
    };
    BAMutil.setActionProperties( minmaxVolAction, null, "Grid volume", false, 'G', 0); */

    minmaxHoldAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            csDataMinMax.setSelectedItem(GridRenderer.MinMaxType.hold);
            controller.setDataMinMaxType(GridRenderer.MinMaxType.hold);
          }
        };
    BAMutil.setActionProperties(minmaxHoldAction, null, "Hold scale constant", false, 'C', 0);

    fieldLoopAction = new LoopControlAction(fieldChooser);
    levelLoopAction = new LoopControlAction(levelChooser);
    timeLoopAction = new LoopControlAction(timeChooser);
  }