Beispiel #1
0
  /**
   * traite une RESOURCE en la considérant comme sous-partie d'un FOV
   *
   * @param res
   */
  private SubFootprintBean processResource(SavotResource res) {
    SubFootprintBean subFpBean = new SubFootprintBean();
    subFpBean.setInSphericalCoords(sphericalCoordinates);

    TableSet tables = res.getTables();
    int nbTab = tables.getItemCount();
    SubFootprintBean sub;

    for (int i = 0; i < nbTab; i++) {
      // TODO : prendre en compte couleur éventuelle au niveau de la TABLE (pour les types STRING
      // notamment)
      sub = processTable((SavotTable) tables.getItemAt(i));
      if (sub != null) {
        subFpBean.addSubFootprintBean(sub);
      }
      //			System.out.println("sub : "+sub);
    }

    String id = res.getName();
    subFpBean.setName(id);
    subFpBean.setColor(getColor(res));

    return subFpBean;
  }
Beispiel #2
0
  private Color getColor(SavotResource res) {
    ParamSet params = res.getParams();
    int nbParams = params.getItemCount();

    SavotParam param;
    for (int i = 0; i < nbParams; i++) {
      param = (SavotParam) params.getItemAt(i);
      param = getParam(param);
      if (param != null && param.getName().equalsIgnoreCase("color")) {
        String val = param.getValue();
        int idx = Util.indexInArrayOf(val, Action.COLORNAME);
        if (idx >= 0) return Action.MYCOLORS[idx];
        else return Action.decodeStaticRGB(val);
      }
    }

    return null;
  }
Beispiel #3
0
  /**
   * construit le footprint associé à une RESOURCE
   *
   * @param res la RESOURCE "racine", pouvant contenir d'autres RESOURCE
   */
  private void processFovResource(SavotResource res) {
    FootprintBean fpBean = new FootprintBean();

    sphericalCoordinates = false;

    tabIndex = 0;

    SubFootprintBean sub;

    //	    System.out.println("Processing resource "+res);
    refMem = new Hashtable<String, MarkupComment>();
    String id = res.getId();
    // par défaut
    fpBean.setInstrumentName(id);

    // dangereux, car c'est sur cet ID qu'on va référencer un FoV
    //		if( id==null || id.length()==0 ) id = res.getName();

    // traitement des params au niveau RESOURCE
    ParamSet params = res.getParams();
    int nbParam = params.getItemCount();
    SavotParam param;
    for (int i = 0; i < nbParam; i++) {
      param = (SavotParam) params.getItemAt(i);

      if (param.getUtype().trim().equalsIgnoreCase(SPHERICAL_COORDS)) {
        sphericalCoordinates = true;
      }

      // position RA du FoV
      if (param.getUcd().equalsIgnoreCase("pos.eq.ra;meta.main")) {
        fpBean.setRa(param.getValue());
      }

      // position DE du FoV
      else if (param.getUcd().equalsIgnoreCase("pos.eq.dec;meta.main")) {
        fpBean.setDe(param.getValue());
      }

      // position RA du centre de rotation du FoV  (PF jan 09)
      if (param.getUcd().equalsIgnoreCase("pos.eq.ra")) {
        fpBean.setRaRot(param.getValue());
      }

      // position DE du centre de rotation du FoV  (PF jan 09)
      else if (param.getUcd().equalsIgnoreCase("pos.eq.dec")) {
        fpBean.setDeRot(param.getValue());
      }
      // angle position du FoV
      else if (param.getUcd().equalsIgnoreCase("pos.posAng")
          || param.getUtype().equals(SIAPExtBuilder.FOV_POS_ANGLE)) {
        double d;
        try {
          d = Double.valueOf(param.getValue()).doubleValue();
        } catch (NumberFormatException e) {
          continue;
          //				    d = 0.;
        }
        fpBean.setPosAngle(d);
      }

      // caractère "movable" du FoV
      else if (param.getName().equalsIgnoreCase("Movable")) {
        boolean b;
        try {
          b = Boolean.valueOf(param.getValue()).booleanValue();
        } catch (NumberFormatException e) {
          continue;
        }
        fpBean.setMovable(b);
      }

      // caractère "rollable" du FoV
      else if (param.getName().equalsIgnoreCase("Rollable")) {
        boolean b;
        try {
          b = Boolean.valueOf(param.getValue()).booleanValue();
        } catch (NumberFormatException e) {
          continue;
        }
        fpBean.setRollable(b);
      }

      // convention interne à Aladin pour affichage dans JTable
      else if (param.getId().equals("InstrumentDescription")) {
        fpBean.setInstrumentDesc(param.getValue());
      }
      // convention interne à Aladin pour affichage dans JTable
      else if (param.getId().equals("InstrumentName")) {
        fpBean.setInstrumentName(param.getValue());
      }
      // convention interne à Aladin pour affichage dans JTable
      else if (param.getId().equals("TelescopeName")) {
        fpBean.setTelescopeName(param.getValue());
      }
      // convention interne à Aladin pour affichage dans JTable
      else if (param.getId().equals("Origin")) {
        fpBean.setOrigin(param.getValue());
      }
    }

    // traitement de la RESOURCE racine
    sub = processResource(res);
    if (sub != null && sub.getNbOfSubParts() > 0) fpBean.addSubFootprintBean(sub);

    /*
    for( int i=0; i<nbTab; i++ ) {
    	processTable((SavotTable)tables.getItemAt(i), i);
    }
    */

    // traitement des RESOURCEs dans RESOURCE (Tom Donaldson)
    ResourceSet resources = res.getResources();
    for (int i = 0; i < resources.getItemCount(); i++) {
      sub = processResource((SavotResource) resources.getItemAt(i));
      if (sub != null) {
        fpBean.addSubFootprintBean(sub);
        // on garde en mémoire les sous-parties d'un FoV --> on les place pour cela dans un
        // container
        String subfpId = ((SavotResource) resources.getItemAt(i)).getId();
        if (subfpId != null && subfpId.length() > 0) {
          FootprintBean container = new FootprintBean();
          container.addSubFootprintBean(sub);
          container.setDisplayInFovList(false);
          // on évite d'écraser un bean existant par un sub-bean
          if (!hash.contains(subfpId)) {
            hash.put(subfpId, container);
          }
        }
      }
    }

    hash.put(id, fpBean);

    // on ne vérifie plus l'existence d'un bean avec le meme nom, on écrase
    if (footprintHash.get(id) != null) {
      Aladin.trace(
          1, "Footprint with ID " + id + "already exists ...\n Existing definition will be erased");
    }
    Aladin.trace(3, "Footprint : add to footprintHash footprint with key " + id + "**");
    footprintHash.put(id, fpBean);
  }