Ejemplo n.º 1
0
 /**
  * needed for XmlPersistable
  *
  * @param encoder encoder for encoding
  * @return this as an encoded Element
  */
 public Element createElement(XmlEncoder encoder) {
   List arguments =
       Misc.newList(
           ellipsoid, new Integer(onezone), new Boolean(onehemiflag), getDefaultMapArea());
   List types =
       Misc.newList(ellipsoid.getClass(), Integer.TYPE, Boolean.TYPE, Rectangle2D.Double.class);
   Element result = encoder.createObjectElement(getClass());
   Element ctorElement = encoder.createConstructorElement(arguments, types);
   result.appendChild(ctorElement);
   return result;
 }
Ejemplo n.º 2
0
  /**
   * Make the IdvWindow. Add event handlers for adding new data sources and closing the window.
   *
   * @return The window to put the gui in
   */
  public IdvWindow doMakeFrame() {
    if (frame == null) {
      JButton newBtn = new JButton("Add New Data Source");
      newBtn.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              idv.showChooser();
            }
          });
      JButton closeBtn = new JButton("Close");
      closeBtn.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              doClose();
            }
          });

      JComponent extra = getButtons();
      JComponent buttons;
      if (extra != null) {
        buttons =
            GuiUtils.wrap(
                GuiUtils.hflow(
                    Misc.newList(
                        /*newBtn,*/
                        extra, closeBtn),
                    4,
                    4));
      } else {
        buttons =
            GuiUtils.wrap(
                GuiUtils.hflow(
                    Misc.newList(
                        /*newBtn,*/
                        closeBtn),
                    4,
                    4));
      }

      JPanel contents = GuiUtils.centerBottom(getContents(), buttons);
      frame = new IdvWindow(getName(), idv, false);
      frame.getContentPane().add(contents);
      frame.addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              doClose();
            }
          });
      frame.pack();
      frame.show();
    }
    return frame;
  }
Ejemplo n.º 3
0
  public void getPropertyComponents(List comps, final ObjectListener listener) {
    visibleCbx = new JCheckBox(getName(), visible);
    float[] rgb = color.get().getRGBComponents(null);
    slider = new JSlider(0, 100, (int) (rgb[0] * 100));

    float[] xyz = new float[3];
    direction.get(xyz);
    directionXFld = makeField("" + xyz[0], listener, "X Direction");
    directionYFld = makeField("" + xyz[1], listener, "Y Direction");
    directionZFld = makeField("" + xyz[2], listener, "Z Direction");

    double[] pxyz = new double[3];
    location.get(pxyz);
    locationXFld = makeField("" + pxyz[0], listener, "");
    locationYFld = makeField("" + pxyz[1], listener, "");
    locationZFld = makeField("" + pxyz[2], listener, "");

    List fldComps =
        Misc.newList(GuiUtils.rLabel("Direction:"), directionXFld, directionYFld, directionZFld);
    //
    // fldComps.addAll(Misc.newList(GuiUtils.rLabel("Location:"),locationXFld,locationYFld,locationZFld));

    comps.add(visibleCbx);
    GuiUtils.tmpInsets = new Insets(0, 2, 0, 0);
    comps.add(
        GuiUtils.vbox(
            slider, GuiUtils.left(GuiUtils.doLayout(fldComps, 4, GuiUtils.WT_N, GuiUtils.WT_N))));

    if (listener != null) {
      visibleCbx.addActionListener(listener);
      slider.addChangeListener(listener);
    }
  }
Ejemplo n.º 4
0
 /**
  * Create the name label if needed.
  *
  * @return The component that holds the name label.
  */
 protected JComponent getLabelComponent() {
   if (nameLabel == null) {
     nameLabel = new JLabel();
     Font font = nameLabel.getFont();
     nameLabel.setFont(font.deriveFont(Font.ITALIC | Font.BOLD));
     labelComponent = GuiUtils.hflow(Misc.newList(new JLabel("Layout Model: "), nameLabel));
   }
   return labelComponent;
 }
Ejemplo n.º 5
0
 /**
  * Create a UrlDataChoice.
  *
  * @param url URL (choice ID)
  * @param desc DataChoice description
  */
 public UrlDataChoice(String url, String desc) {
   super(
       url,
       desc,
       desc,
       Misc.newList(
           new DataCategory("Documentation", true),
           new DataCategory(DataCategory.CATEGORY_HTML, false)));
   this.url = url;
 }
Ejemplo n.º 6
0
    /**
     * Make the gui for the data subset panel
     *
     * @return gui for data subset panel
     */
    protected JComponent doMakeContents() {
      GuiUtils.tmpInsets = GuiUtils.INSETS_5;
      String prop = (String) pointDataSource.getProperty(PROP_STATIONMODELNAME);
      if (dataSelection != null) {
        prop = (String) dataSelection.getProperty(PROP_STATIONMODELNAME);
      }
      if (prop != null) {
        pmc.setPlotModelByName((String) prop);
      }

      return GuiUtils.top(GuiUtils.hflow(Misc.newList(new JLabel("Layout Model: "), pmc), 5, 5));
    }
Ejemplo n.º 7
0
  /**
   * Add components to properties dialog
   *
   * @param comps List of components
   * @param tabIdx Which tab in properties dialog
   */
  protected void getPropertiesComponents(List comps, int tabIdx) {
    super.getPropertiesComponents(comps, tabIdx);
    if (tabIdx != 0) {
      return;
    }
    comps.add(GuiUtils.rLabel("Histogram: "));

    comps.add(
        GuiUtils.left(
            GuiUtils.hbox(
                Misc.newList(new JLabel("Number of Bins: "), binFld = new JTextField("" + bins, 6)),
                4)));
    //                                             new JLabel("      Stacked: "),
    // stackedCbx = new JCheckBox("",stacked)),4)));
  }
Ejemplo n.º 8
0
 /**
  * Get list of default units TFO for the gui
  *
  * @return List of TFOS for choosing units
  */
 public static List getDefaultUnitList() {
   return Misc.newList(
       new Object[] {
         new TwoFacedObject("Default", null),
         "Celsius",
         "Fahrenheit",
         "Kelvin",
         "millibars",
         "hectoPascals",
         "meters",
         "kilometers",
         "feet",
         "knots",
         "meters/second",
         "miles/hour",
         "kilometers/hour",
         "furlongs/fortnight"
       });
 }
Ejemplo n.º 9
0
  /**
   * Make the control widgets
   *
   * @param controlWidgets list of control widgets
   * @throws RemoteException Java RMI error
   * @throws VisADException VisAD Error
   */
  public void getControlWidgets(List controlWidgets) throws VisADException, RemoteException {
    super.getControlWidgets(controlWidgets);

    JComponent barbSizeBox =
        GuiUtils.wrap(
            GuiUtils.createValueBox(
                this, CMD_BARBSIZE, (int) flowScaleValue, Misc.createIntervalList(1, 10, 1), true));

    // make possible another component(s) to put on same line w barbSizeBox
    JComponent extra = doMakeExtraComponent();

    JComponent rightPanel =
        GuiUtils.leftCenter(
            ((extra != null)
                ? (JComponent) GuiUtils.hflow(Misc.newList(barbSizeBox, extra))
                : (JComponent) barbSizeBox),
            GuiUtils.filler());
    controlWidgets.add(new WrapperWidget(this, GuiUtils.rLabel("Windbarb size: "), rightPanel));
  }
Ejemplo n.º 10
0
 /**
  * Popup a unit selection gui. This will also save off persistently any new unit names typed in.
  *
  * @param unit The current unit
  * @param defaultUnit The default unit to return if the user chooses "Default"
  * @return The new unit or null on a cancel or an error
  */
 public Unit selectUnit(Unit unit, Unit defaultUnit) {
   JComboBox ufld = makeUnitBox(unit, defaultUnit);
   Component panel = GuiUtils.label(" New unit:  ", ufld);
   if (!GuiUtils.showOkCancelDialog(
       null, "Change unit", GuiUtils.inset(panel, 5), null, Misc.newList(ufld))) {
     return null;
   }
   Object selected = ufld.getSelectedItem();
   String unitName = TwoFacedObject.getIdString(selected);
   if (unitName == null) {
     return defaultUnit;
   }
   try {
     Unit newUnit = Util.parseUnit(unitName);
     if (!(selected instanceof TwoFacedObject)) {
       selected = new TwoFacedObject(selected.toString(), newUnit);
     }
     addToUnitList(selected);
     return newUnit;
   } catch (Exception exc) {
     LogUtil.userMessage("Error parsing unit:" + unitName + "\n" + exc);
   }
   return null;
 }
Ejemplo n.º 11
0
 /**
  * Process the given action (e.g., url, idv command) with the given properties. This just creates
  * a new PropertiedAction, adds it to a list and turns around and calls the handleActions method.
  *
  * @param action The String action (Url, Idv command, etc.) to handle.
  * @param properties The properties for this action.
  */
 protected void handleAction(String action, Hashtable properties) {
   handleActions(Misc.newList(new PropertiedAction(action, properties)));
 }
Ejemplo n.º 12
0
 /**
  * Add any macro name/label pairs
  *
  * @param names List of macro names
  * @param labels List of macro labels
  */
 protected void getMacroNames(List names, List labels) {
   super.getMacroNames(names, labels);
   names.addAll(Misc.newList(MACRO_POSITION));
   labels.addAll(Misc.newList("Probe Position"));
 }
 /**
  * Add any macro name/label pairs
  *
  * @param names List of macro names
  * @param labels List of macro labels
  */
 protected void getMacroNames(List names, List labels) {
   super.getMacroNames(names, labels);
   names.addAll(Misc.newList(MACRO_STATION));
   labels.addAll(Misc.newList("Station"));
 }
Ejemplo n.º 14
0
 /**
  * Create a parent-less category with the given metacategory.
  *
  * @param name name of this DataCategory
  * @param metaCategory meta category
  */
 public DataCategory(String name, DataCategory metaCategory) {
   this(name, Misc.newList(metaCategory));
 }
Ejemplo n.º 15
0
 /**
  * _more_
  *
  * @param what _more_
  * @param where _more_
  * @return _more_
  * @throws SQLException _more_
  */
 private Statement select(String what, String where) throws SQLException {
   return evaluate(SqlUtil.makeSelect(what, Misc.newList(where)));
 }
Ejemplo n.º 16
0
  /** Make the <code>DataChoices</code> for this <code>DataSource</code>. */
  public void doMakeDataChoices() {

    if (sources == null) {
      return;
    }
    String stationModelName = (String) getProperty(PROP_STATIONMODELNAME);
    Hashtable properties =
        Misc.newHashtable(DataChoice.PROP_ICON, "/auxdata/ui/icons/Placemark16.gif");
    if (stationModelName != null) {
      properties.put(PROP_STATIONMODELNAME, stationModelName);
    }
    if (!getDefaultLevels().isEmpty()) {
      properties.put(DataSelection.PROP_DEFAULT_LEVELS, getDefaultLevels());
    }
    DataChoice uberChoice = null;
    /*  Might want to do this someday
    uberChoice = new DirectDataChoice(this,
                                        sources, getName(),
                                        getDataName(),
                                        getPointCategories(),
                                        properties);
    */

    if (sources.size() > 1) {
      uberChoice =
          new CompositeDataChoice(
              this, sources, getName(), getDataName(), getPointCategories(), properties);
      addDataChoice(uberChoice);
    }

    for (int i = 0; i < sources.size(); i++) {
      String dataChoiceDesc = getDescription();
      String dataChoiceName = getDataName();
      if (uberChoice != null) {
        dataChoiceDesc = IOUtil.getFileTail(sources.get(i).toString());
        dataChoiceName = IOUtil.getFileTail(sources.get(i).toString());
      }

      DataChoice choice =
          new DirectDataChoice(
              this,
              new Integer(i),
              dataChoiceDesc,
              dataChoiceName,
              getPointCategories(),
              properties);

      /*
      We'd like to create sub choices for each parameter but we don't really
      know the parameters until we read the data and that can be expensive
                  DirectDataChoice subChoice = new DirectDataChoice(this,
                            (String) sources.get(i),
                            getDescription(), getDataName(),
                            getPointCategories(), properties);
                            choice.addDataChoice(subChoice);*/

      if (uberChoice != null) {
        ((CompositeDataChoice) uberChoice).addDataChoice(choice);
      } else {
        addDataChoice(choice);
      }
      // Only add the grid data choices for the first source
      if (i > 0) {
        continue;
      }
      try {
        FieldImpl sample = (makeGridFields ? getSample(choice) : null);
        if (sample != null) {
          for (int dataChoiceType = 0; dataChoiceType < 2; dataChoiceType++) {
            Hashtable seenFields = new Hashtable();
            if (ucar.unidata.data.grid.GridUtil.isTimeSequence(sample)) {
              sample = (FieldImpl) sample.getSample(0);
            }
            PointOb ob = (PointOb) sample.getSample(0);
            Tuple tuple = (Tuple) ob.getData();
            TupleType tupleType = (TupleType) tuple.getType();
            MathType[] types = tupleType.getComponents();
            CompositeDataChoice compositeDataChoice = null;
            for (int typeIdx = 0; typeIdx < types.length; typeIdx++) {
              if (!(types[typeIdx] instanceof RealType)) {
                continue;
              }
              RealType type = (RealType) types[typeIdx];
              if (!canCreateGrid(type)) {
                continue;
              }
              //                        List gridCategories =
              //                            DataCategory.parseCategories("OA Fields;GRID-2D-TIME;");
              List gridCategories = DataCategory.parseCategories("GRID-2D-TIME;", false);
              if (compositeDataChoice == null) {
                compositeDataChoice =
                    new CompositeDataChoice(
                        this,
                        "",
                        "Grid Fields from Objective Analysis",
                        "Gridded Fields " + ((dataChoiceType == 0) ? "" : "(with first guess)"),
                        Misc.newList(DataCategory.NONE_CATEGORY),
                        null);
                addDataChoice(compositeDataChoice);
              }
              String name = ucar.visad.Util.cleanTypeName(type.toString());
              if (seenFields.get(name) != null) {
                continue;
              }
              seenFields.put(name, name);
              List idList = Misc.newList(new Integer(i), type);
              if (dataChoiceType == 1) {
                idList.add(new Boolean(true));
              }
              DataChoice gridChoice =
                  new DirectDataChoice(this, idList, name, name, gridCategories, (Hashtable) null);
              compositeDataChoice.addDataChoice(gridChoice);
            }
          }
        }
      } catch (Exception exc) {
        throw new WrapperException("Making grid parameters", exc);
      }
      //            if(true) break;
    }
  }
Ejemplo n.º 17
0
 /**
  * Set the ForecastHour property.
  *
  * @param value The new value for ForecastHour
  */
 public void setForecastHour(int value) {
   forecastHours = (List<Integer>) Misc.newList(new Integer(value));
 }
Ejemplo n.º 18
0
 /**
  * Set the ChartForecastTime property.
  *
  * @param value The new value for ChartForecastTime
  */
 public void setForecastTime(DateTime value) {
   forecastTimes = (List<DateTime>) Misc.newList(value);
 }