Exemplo n.º 1
0
 public void save() {
   varTable.saveState(false);
   csTable.saveState(false);
   axisTable.saveState(false);
   prefs.putBeanObject("InfoWindowBounds", infoWindow.getBounds());
   prefs.putInt("splitPos", split.getDividerLocation());
   prefs.putInt("splitPos2", split2.getDividerLocation());
   prefs.putBeanObject("InfoWindowBounds", infoWindow.getBounds());
   if (attWindow != null) prefs.putBeanObject("AttWindowBounds", attWindow.getBounds());
 }
Exemplo n.º 2
0
    void show() {
      if (isShowing) return;

      tablePanel.remove(currentComponent);
      split.setLeftComponent(currentComponent);
      split.setDividerLocation(splitPos);
      currentComponent = split;
      tablePanel.add(currentComponent, BorderLayout.CENTER);
      tablePanel.revalidate();
      isShowing = true;
    }
Exemplo n.º 3
0
    void hide() {
      if (!isShowing) return;
      tablePanel.remove(currentComponent);

      if (split != null) {
        splitPos = split.getDividerLocation();
        currentComponent = (JComponent) split.getLeftComponent();
        tablePanel.add(currentComponent, BorderLayout.CENTER);
      }

      tablePanel.revalidate();
      isShowing = false;
    }
Exemplo n.º 4
0
  public void save() {
    dumpPane.save();
    for (NestedTable nt : nestedTableList) {
      nt.saveState();
    }
    prefs.putBeanObject("InfoWindowBounds", infoWindow.getBounds());
    prefs.putBeanObject("DumpWindowBounds", dumpWindow.getBounds());
    if (attWindow != null) prefs.putBeanObject("AttWindowBounds", attWindow.getBounds());

    prefs.putInt("mainSplit", mainSplit.getDividerLocation());
  }
Exemplo n.º 5
0
  public DatasetViewer(PreferencesExt prefs, FileManager fileChooser) {
    this.prefs = prefs;
    this.fileChooser = fileChooser;

    // create the variable table(s)
    tablePanel = new JPanel(new BorderLayout());
    setNestedTable(0, null);

    // the tree view
    datasetTree = new DatasetTreeView();
    datasetTree.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            setSelected((Variable) e.getNewValue());
          }
        });

    // layout
    mainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, datasetTree, tablePanel);
    mainSplit.setDividerLocation(prefs.getInt("mainSplit", 100));

    setLayout(new BorderLayout());
    add(mainSplit, BorderLayout.CENTER);

    // the info window
    infoTA = new TextHistoryPane();
    infoWindow =
        new IndependentWindow("Variable Information", BAMutil.getImage("netcdfUI"), infoTA);
    infoWindow.setBounds(
        (Rectangle) prefs.getBean("InfoWindowBounds", new Rectangle(300, 300, 500, 300)));

    // the data Table
    dataTable = new StructureTable((PreferencesExt) prefs.node("structTable"));
    dataWindow = new IndependentWindow("Data Table", BAMutil.getImage("netcdfUI"), dataTable);
    dataWindow.setBounds(
        (Rectangle) prefs.getBean("dataWindow", new Rectangle(50, 300, 1000, 600)));

    // the ncdump Pane
    dumpPane = new NCdumpPane((PreferencesExt) prefs.node("dumpPane"));
    dumpWindow =
        new IndependentWindow("NCDump Variable Data", BAMutil.getImage("netcdfUI"), dumpPane);
    dumpWindow.setBounds(
        (Rectangle) prefs.getBean("DumpWindowBounds", new Rectangle(300, 300, 300, 200)));
  }
Exemplo n.º 6
0
  public CoordSysTable(PreferencesExt prefs, JPanel buttPanel) {
    this.prefs = prefs;

    if (buttPanel != null) {
      AbstractAction attAction =
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              showAtts();
            }
          };
      BAMutil.setActionProperties(attAction, "FontDecr", "global attributes", false, 'A', -1);
      BAMutil.addActionToContainer(buttPanel, attAction);
    }

    varTable =
        new BeanTable(VariableBean.class, (PreferencesExt) prefs.node("VariableBeans"), false);
    varTable.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            VariableBean vb = (VariableBean) varTable.getSelectedBean();
            if (null != vb.firstCoordSys) setSelectedCoordinateSystem(vb.firstCoordSys);
          }
        });

    csTable =
        new BeanTable(
            CoordinateSystemBean.class, (PreferencesExt) prefs.node("CoordinateSystemBean"), false);
    csTable.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            CoordinateSystemBean csb = (CoordinateSystemBean) csTable.getSelectedBean();
            setSelectedCoordinateAxes(csb.coordSys);
          }
        });

    axisTable =
        new BeanTable(AxisBean.class, (PreferencesExt) prefs.node("CoordinateAxisBean"), false);

    ucar.nc2.ui.widget.PopupMenu varPopup = new PopupMenu(varTable.getJTable(), "Options");
    varPopup.addAction(
        "Show Declaration",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            VariableBean vb = (VariableBean) varTable.getSelectedBean();
            Variable v = ds.findVariable(vb.getName());
            if (v == null) return;
            infoTA.clear();
            infoTA.appendLine(v.toString());
            infoTA.appendLine(showMissing(v));
            infoTA.gotoTop();
            infoWindow.show();
          }
        });

    varPopup.addAction(
        "Try as Grid",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            VariableBean vb = (VariableBean) varTable.getSelectedBean();
            VariableEnhanced v = (VariableEnhanced) ds.findVariable(vb.getName());
            if (v == null) return;
            infoTA.clear();
            infoTA.appendLine(tryGrid(v));
            infoTA.gotoTop();
            infoWindow.show();
          }
        });

    PopupMenu csPopup = new PopupMenu(csTable.getJTable(), "Options");
    csPopup.addAction(
        "Show CoordSys",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            CoordinateSystemBean csb = (CoordinateSystemBean) csTable.getSelectedBean();
            CoordinateSystem coordSys = csb.coordSys;
            infoTA.clear();
            infoTA.appendLine("Coordinate System = " + coordSys.getName());
            for (CoordinateAxis axis : coordSys.getCoordinateAxes()) {
              infoTA.appendLine("  " + axis.getAxisType() + " " + axis.writeCDL(true, false));
            }
            infoTA.appendLine(" Coordinate Transforms");
            for (CoordinateTransform ct : coordSys.getCoordinateTransforms()) {
              infoTA.appendLine("  " + ct.getName() + " type=" + ct.getTransformType());
              for (Parameter p : ct.getParameters()) {
                infoTA.appendLine("    " + p);
              }
              if (ct instanceof ProjectionCT) {
                ProjectionCT pct = (ProjectionCT) ct;
                if (pct.getProjection() != null) {
                  infoTA.appendLine("    impl.class= " + pct.getProjection().getClass().getName());
                  // pct.getProjection();
                }
              }
              if (ct instanceof VerticalCT) {
                VerticalCT vct = (VerticalCT) ct;
                infoTA.appendLine("  VerticalCT= " + vct);
              }
            }
            infoTA.gotoTop();
            infoWindow.show();
          }
        });

    PopupMenu axisPopup = new PopupMenu(axisTable.getJTable(), "Options");
    axisPopup.addAction(
        "Show Declaration",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            AxisBean bean = (AxisBean) axisTable.getSelectedBean();
            if (bean == null) return;
            VariableDS axis = (VariableDS) ds.findVariable(bean.getName());
            if (axis == null) return;
            infoTA.clear();
            infoTA.appendLine(axis.toString());
            infoTA.appendLine(showMissing(axis));
            infoTA.gotoTop();
            infoWindow.show();
          }
        });

    axisPopup.addAction(
        "Show Values",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            AxisBean bean = (AxisBean) axisTable.getSelectedBean();
            if (bean == null) return;
            infoTA.clear();
            showValues(bean.axis);
            infoTA.gotoTop();
            infoWindow.show();
          }
        });
    axisPopup.addAction(
        "Show Value Differences",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            AxisBean bean = (AxisBean) axisTable.getSelectedBean();
            if (bean == null) return;
            infoTA.clear();
            showValueDiffs(bean.axis);
            infoTA.gotoTop();
            infoWindow.show();
          }
        });

    axisPopup.addAction(
        "Show Values as Date",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            AxisBean bean = (AxisBean) axisTable.getSelectedBean();
            if (bean == null) return;
            infoTA.clear();
            showValuesAsDates(bean.axis);
            infoTA.gotoTop();
            infoWindow.show();
          }
        });

    // the info window
    infoTA = new TextHistoryPane();
    infoWindow = new IndependentWindow("Extra Information", BAMutil.getImage("netcdfUI"), infoTA);
    infoWindow.setBounds(
        (Rectangle) prefs.getBean("InfoWindowBounds", new Rectangle(300, 300, 500, 300)));

    split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, varTable, csTable);
    split.setDividerLocation(prefs.getInt("splitPos", 500));

    split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, split, axisTable);
    split2.setDividerLocation(prefs.getInt("splitPos2", 500));

    setLayout(new BorderLayout());
    add(split2, BorderLayout.CENTER);
  }
Exemplo n.º 7
0
 void saveState() {
   table.saveState(false);
   if (split != null) myPrefs.putInt("splitPos" + level, split.getDividerLocation());
 }
Exemplo n.º 8
0
    NestedTable(int level) {
      this.level = level;
      myPrefs = (PreferencesExt) prefs.node("NestedTable" + level);

      table = new BeanTableSorted(VariableBean.class, myPrefs, false);

      JTable jtable = table.getJTable();
      PopupMenu csPopup = new PopupMenu(jtable, "Options");
      csPopup.addAction(
          "Show Declaration",
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              showDeclaration(table, false);
            }
          });
      csPopup.addAction(
          "Show NcML",
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              showDeclaration(table, true);
            }
          });
      csPopup.addAction(
          "NCdump Data",
          "Dump",
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              dumpData(table);
            }
          });
      if (level == 0) {
        csPopup.addAction(
            "Data Table",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                dataTable(table);
              }
            });
      }

      // get selected variable, see if its a structure
      table.addListSelectionListener(
          new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
              Variable v = getCurrentVariable(table);
              if ((v != null) && (v instanceof Structure)) {
                hideNestedTable(NestedTable.this.level + 2);
                setNestedTable(NestedTable.this.level + 1, (Structure) v);

              } else {
                hideNestedTable(NestedTable.this.level + 1);
              }
              if (eventsOK) datasetTree.setSelected(v);
            }
          });

      // layout
      if (currentComponent == null) {
        currentComponent = table;
        tablePanel.add(currentComponent, BorderLayout.CENTER);
        isShowing = true;

      } else {
        split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, currentComponent, table);
        splitPos = myPrefs.getInt("splitPos" + level, 500);
        if (splitPos > 0) split.setDividerLocation(splitPos);

        show();
      }
    }