Esempio n. 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)));
  }
Esempio n. 2
0
 LoopControlAction(SuperComboBox cbox) {
   this.scbox = cbox;
   BAMutil.setActionProperties(this, null, cbox.getName(), false, 0, 0);
 }
Esempio n. 3
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);
  }