Пример #1
0
  /**
   * _more_
   *
   * @param visible _more_
   * @throws Exception _more_
   */
  public void setPairProfilesVisibility(boolean visible) throws Exception {
    profilesVisibility = visible;
    Set s = getDataTimeSet();
    int len = s.getLength();
    if (len < 2) { // no pair do nothing
      return;
    }
    AnimationWidget aniWidget = this.getAnimationWidget();
    // aniWidget.setBoxPanelVisible( !visible);
    // if (visible) {
    aniWidget.gotoIndex(0);
    aniWidget.setRunning(false);
    // }

    if (visible) {

      Set timeset = subSetProfilesTimeSet(s);
      dataNode.setOutputTimes((SampledSet) timeset);
    } else {
      Set timeset = getDataTimeSet();
      dataNode.setOutputTimes((SampledSet) timeset);
    }
    // GuiUtils.enableTree(aniWidget.getContents(), !visible);
    // now update the display list label
    aeroDisplay.setProfilesVisibility(visible, 0);

    if (visible) {
      if (s != null) {
        double[][] samples = s.getDoubles();
        DateTime dt = new DateTime(samples[0][1], s.getSetUnits()[0]);
        DateTime dt1 = new DateTime(samples[0][0], s.getSetUnits()[0]);
        listlabel =
            dt1.dateString()
                + ":"
                + dt1.timeString()
                + " and "
                + dt.dateString()
                + ":"
                + dt.timeString();
      }

    } else {
      listlabel = null;
    }

    updateDisplayList();
    updateHeaderLabel();
  }
Пример #2
0
  /**
   * Respond to a timeChange event
   *
   * @param time new time
   */
  protected void timeChanged(Real time) {
    try {
      super.timeChanged(time);
      dataNode.setTime(new DateTime(time));
      if (getProfilesVisibility()) {
        AnimationWidget aniWidget = this.getAnimationWidget();
        int idx = 0;
        if (aniWidget.getTimes() != null) {
          int n = aniWidget.getTimes().length;
          for (int i = 0; i < n; i++) {
            if ((new DateTime(time)).equals(aniWidget.getTimeAtIndex(i))) {
              idx = i;
              continue;
            }
          }
        }
        aeroDisplay.setProfilesVisibility(true, idx);
        // display list update
        Set s = getDataTimeSet();
        if (s != null) {
          double[][] samples = s.getDoubles();
          DateTime dt = new DateTime(samples[0][idx + 1], s.getSetUnits()[0]);
          DateTime dt1 = new DateTime(samples[0][idx], s.getSetUnits()[0]);
          listlabel =
              dt1.dateString()
                  + ":"
                  + dt1.timeString()
                  + " and "
                  + dt.dateString()
                  + ":"
                  + dt.timeString();
        }

        updateDisplayList();
        updateHeaderLabel();
      }
    } catch (Exception ex) {
      logException("timeValueChanged", ex);
    }
  }
Пример #3
0
  public Element saveParameterSet() {
    if (imageDefaults == null) {
      imageDefaults = getImageDefaults();
    }
    if (newCompName.length() == 0) {
      newComponentError("parameter set");
      return null;
    }
    Element newChild = imageDefaultsDocument.createElement(TAG_DEFAULT);
    newChild.setAttribute(ATTR_NAME, newCompName);

    if (datachoice == null) {
      datachoice = getDataChoice();
    }
    dataSource = getDataSource();
    if (!(dataSource.getClass().isInstance(new AddeImageParameterDataSource()))) {
      return newChild;
    }
    AddeImageParameterDataSource testDataSource = (AddeImageParameterDataSource) dataSource;
    List imageList = testDataSource.getDescriptors(datachoice, this.dataSelection);
    int numImages = imageList.size();
    List dateTimes = new ArrayList();
    DateTime thisDT = null;
    if (!(imageList == null)) {
      AddeImageDescriptor aid = null;
      for (int imageNo = 0; imageNo < numImages; imageNo++) {
        aid = (AddeImageDescriptor) (imageList.get(imageNo));
        thisDT = aid.getImageTime();
        if (!(dateTimes.contains(thisDT))) {
          if (thisDT != null) {
            dateTimes.add(thisDT);
          }
        }
      }
      String dateS = "";
      String timeS = "";
      if (!(dateTimes.isEmpty())) {
        thisDT = (DateTime) dateTimes.get(0);
        dateS = thisDT.dateString();
        timeS = thisDT.timeString();
        if (dateTimes.size() > 1) {
          for (int img = 1; img < dateTimes.size(); img++) {
            thisDT = (DateTime) dateTimes.get(img);
            String str = ',' + thisDT.dateString();
            String newString = new String(dateS + str);
            dateS = newString;
            str = ',' + thisDT.timeString();
            newString = new String(timeS + str);
            timeS = newString;
          }
        }
      }
      if (aid != null) {
        String displayUrl = testDataSource.getDisplaySource();
        ImageParameters ip = new ImageParameters(displayUrl);
        List props = ip.getProperties();
        List vals = ip.getValues();
        String server = ip.getServer();
        newChild.setAttribute(ATTR_SERVER, server);
        int num = props.size();
        if (num > 0) {
          String attr = "";
          String val = "";
          for (int i = 0; i < num; i++) {
            attr = (String) (props.get(i));
            if (attr.equals(ATTR_POS)) {
              val = new Integer(numImages - 1).toString();
            } else if (attr.equals(ATTR_DAY)) {
              val = dateS;
            } else if (attr.equals(ATTR_TIME)) {
              val = timeS;
            } else {
              val = (String) (vals.get(i));
            }
            newChild.setAttribute(attr, val);
          }
        }
      }
    }
    Element parent = xmlTree.getSelectedElement();
    if (parent == null) {
      parent = (Element) lastCat;
    }
    if (parent != null) {
      Element exists = XmlUtil.findElement(parent, "default", ATTR_NAME, newCompName);
      if (!(exists == null)) {
        JLabel label = new JLabel("Replace \"" + newCompName + "\"?");
        JPanel contents = GuiUtils.top(GuiUtils.inset(label, newCompName.length() + 12));
        if (!GuiUtils.showOkCancelDialog(null, "Parameter Set Exists", contents, null)) {
          return newChild;
        }
        parent.removeChild(exists);
      }
      parent.appendChild(newChild);
      makeXmlTree();
    }
    try {
      imageDefaults.writeWritable();
    } catch (Exception e) {
      logger.error("write error!", e);
    }
    imageDefaults.setWritableDocument(imageDefaultsDocument, imageDefaultsRoot);
    return newChild;
  }
Пример #4
0
  private Hashtable makeParameterValues() {
    Hashtable parameterValues = new Hashtable();
    //    	Document doc = XmlUtil.makeDocument();
    //    	Element newChild = doc.createElement(TAG_DEFAULT);

    if (datachoice == null) {
      datachoice = getDataChoice();
    }
    dataSource = getDataSource();
    if (!(dataSource.getClass().isInstance(new AddeImageParameterDataSource()))) {
      logger.trace(
          "dataSource not a AddeImageParameterDataSource; it is: {}",
          dataSource.getClass().toString());
      return parameterValues;
    }
    AddeImageParameterDataSource testDataSource = (AddeImageParameterDataSource) dataSource;
    List imageList = testDataSource.getDescriptors(datachoice, this.dataSelection);
    int numImages = imageList.size();
    List dateTimes = new ArrayList();
    DateTime thisDT = null;
    if (!(imageList == null)) {
      AddeImageDescriptor aid = null;
      for (int imageNo = 0; imageNo < numImages; imageNo++) {
        aid = (AddeImageDescriptor) (imageList.get(imageNo));
        thisDT = aid.getImageTime();
        if (!(dateTimes.contains(thisDT))) {
          if (thisDT != null) {
            dateTimes.add(thisDT);
          }
        }
      }

      // Set the date and time for later reference
      String dateS = "";
      String timeS = "";
      if (!(dateTimes.isEmpty())) {
        thisDT = (DateTime) dateTimes.get(0);
        dateS = thisDT.dateString();
        timeS = thisDT.timeString();
        if (dateTimes.size() > 1) {
          for (int img = 1; img < dateTimes.size(); img++) {
            thisDT = (DateTime) dateTimes.get(img);
            String str = "," + thisDT.dateString();
            String newString = new String(dateS + str);
            dateS = newString;
            str = "," + thisDT.timeString();
            newString = new String(timeS + str);
            timeS = newString;
          }
        }
      }

      // Set the unit for later reference
      String unitS = "";
      if (!(datachoice.getId() instanceof BandInfo)) {
        logger.trace(
            "dataChoice ID not a BandInfo; it is: {}", datachoice.getId().getClass().toString());
        return parameterValues;
      }
      BandInfo bi = (BandInfo) datachoice.getId();
      unitS = bi.getPreferredUnit();

      if (aid != null) {
        String displayUrl = testDataSource.getDisplaySource();
        ImageParameters ip = new ImageParameters(displayUrl);
        List props = ip.getProperties();
        List vals = ip.getValues();
        String server = ip.getServer();
        parameterValues.put(ATTR_SERVER, server);
        //    			newChild.setAttribute(ATTR_SERVER, server);
        int num = props.size();
        if (num > 0) {
          String attr = "";
          String val = "";
          for (int i = 0; i < num; i++) {
            attr = (String) (props.get(i));
            if (attr.equals(ATTR_POS)) {
              val = new Integer(numImages - 1).toString();
            } else if (attr.equals(ATTR_DAY)) {
              val = dateS;
            } else if (attr.equals(ATTR_TIME)) {
              val = timeS;
            } else if (attr.equals(ATTR_UNIT)) {
              val = unitS;
            } else {
              val = (String) (vals.get(i));
            }
            parameterValues.put(attr, val);
          }
        }
      }
    }
    return parameterValues;
  }