/**
   * Construction d'un TreeNodeAllSky à partir des infos qu'il est possible de glaner à l'endroit
   * indiqué, soit par exploration du répertoire, soit par le fichier Properties
   */
  public TreeNodeAllsky(Aladin aladin, String pathOrUrl) {
    String s;
    this.aladin = aladin;
    local =
        !(pathOrUrl.startsWith("http:")
            || pathOrUrl.startsWith("https:")
            || pathOrUrl.startsWith("ftp:"));
    MyProperties prop = new MyProperties();

    // Par http ou ftp ?
    try {
      InputStream in = null;
      if (!local) in = (new URL(pathOrUrl + "/" + PlanHealpix.PROPERTIES)).openStream();
      else in = new FileInputStream(new File(pathOrUrl + Util.FS + PlanHealpix.PROPERTIES));
      if (in != null) {
        prop.load(in);
        in.close();
      }
    } catch (Exception e) {
      aladin.trace(3, "No properties file found => auto discovery...");
    }

    // recherche du frame Healpix
    String strFrame = prop.getProperty(PlanHealpix.KEY_COORDSYS, "G");
    char c1 = strFrame.charAt(0);
    if (c1 == 'C' || c1 == 'Q') frame = Localisation.ICRS;
    else if (c1 == 'E') frame = Localisation.ECLIPTIC;
    else if (c1 == 'G') frame = Localisation.GAL;

    url = pathOrUrl;

    s = prop.getProperty(PlanHealpix.KEY_LABEL);
    if (s != null) label = s;
    else {
      char c = local ? Util.FS.charAt(0) : '/';
      int end = pathOrUrl.length();
      int offset = pathOrUrl.lastIndexOf(c);
      if (offset == end - 1 && offset > 0) {
        end = offset;
        offset = pathOrUrl.lastIndexOf(c, end - 1);
      }
      label = pathOrUrl.substring(offset + 1, end);
    }
    id = "__" + label;

    s = prop.getProperty(PlanHealpix.KEY_VERSION);
    if (s != null) version = s;

    description = prop.getProperty(PlanHealpix.KEY_DESCRIPTION);
    verboseDescr = prop.getProperty(PlanHealpix.KEY_DESCRIPTION_VERBOSE);
    copyright = prop.getProperty(PlanHealpix.KEY_COPYRIGHT);
    copyrightUrl = prop.getProperty(PlanHealpix.KEY_COPYRIGHT_URL);
    useCache = !local && Boolean.parseBoolean(prop.getProperty(PlanHealpix.KEY_USECACHE, "True"));

    s = prop.getProperty(PlanHealpix.KEY_TARGET);
    if (s == null) target = null;
    else {
      try {
        target = new Coord(s);
      } catch (Exception e) {
        aladin.trace(3, "target error!");
        target = null;
      }
    }
    s = prop.getProperty(PlanHealpix.KEY_TARGETRADIUS);
    if (s == null) radius = -1;
    else {
      try {
        radius = Server.getAngle(s, Server.RADIUSd);
      } catch (Exception e) {
        aladin.trace(3, "radius error!");
        radius = -1;
      }
    }

    s = prop.getProperty(PlanHealpix.KEY_NSIDE);
    if (s != null)
      try {
        nside = Integer.parseInt(s);
      } catch (Exception e) {
        aladin.trace(3, "NSIDE number not parsable !");
        nside = -1;
      }

    try {
      maxOrder = new Integer(prop.getProperty(PlanHealpix.KEY_MAXORDER));
    } catch (Exception e) {
      maxOrder = getMaxOrderByPath(pathOrUrl, local);
      if (maxOrder == -1) {
        aladin.trace(3, "No maxOrder found (even with scanning dir.) => assuming 11");
        maxOrder = 11;
      }
    }

    // Les paramètres liés aux cubes
    try {
      cube = new Boolean(prop.getProperty(PlanHealpix.KEY_ISCUBE));
    } catch (Exception e) {
      cube = false;
    }
    if (cube) {
      s = prop.getProperty(PlanHealpix.KEY_CUBEDEPTH);
      if (s != null) {
        try {
          cubeDepth = Integer.parseInt(s);
        } catch (Exception e) {
          aladin.trace(3, "CubeDepth syntax error [" + s + "] => trying autodetection");
          cubeDepth = -1;
        }
      }
      s = prop.getProperty(PlanHealpix.KEY_CUBEFIRSTFRAME);
      if (s != null) {
        try {
          cubeFirstFrame = Integer.parseInt(s);
        } catch (Exception e) {
          aladin.trace(3, "cubeFirstFrame syntax error [" + s + "] => assuming frame 0");
          cubeFirstFrame = -1;
        }
      }
    }

    progen = pathOrUrl.endsWith("HpxFinder") || pathOrUrl.endsWith("HpxFinder/");

    s = prop.getProperty(PlanHealpix.KEY_ISCAT);
    if (s != null) cat = new Boolean(s);
    else cat = getFormatByPath(pathOrUrl, local, 2);

    // Détermination du format des cellules dans le cas d'un survey pixels
    String keyColor = prop.getProperty(PlanHealpix.KEY_ISCOLOR);
    if (keyColor != null) color = new Boolean(keyColor);
    //      if( color ) inJPEG=true;
    if (!cat && !progen /* && (keyColor==null || !color)*/) {
      String format = prop.getProperty(PlanHealpix.KEY_FORMAT);
      if (format != null) {
        int a, b;
        inFits = (a = Util.indexOfIgnoreCase(format, "fit")) >= 0;
        inJPEG =
            (b = Util.indexOfIgnoreCase(format, "jpeg")) >= 0
                || (b = Util.indexOfIgnoreCase(format, "jpg")) >= 0;
        inPNG = (b = Util.indexOfIgnoreCase(format, "png")) >= 0;
        truePixels = inFits && a < b; // On démarre dans le premier format indiqué
      } else {
        inFits = getFormatByPath(pathOrUrl, local, 0);
        inJPEG = getFormatByPath(pathOrUrl, local, 1);
        inPNG = getFormatByPath(pathOrUrl, local, 3);
        truePixels =
            local && inFits
                || !(!local
                    && (inJPEG
                        || inPNG)); // par défaut on démarre en FITS en local, en Jpeg en distant
      }
      if (keyColor == null) {
        color = getIsColorByPath(pathOrUrl, local);
      }
      if (color) truePixels = false;
    }

    aladin.trace(4, toString1());
  }
  public TreeNodeAllsky(
      Aladin aladin,
      String actionName,
      String id,
      String aladinMenuNumber,
      String url,
      String aladinLabel,
      String description,
      String verboseDescr,
      String ack,
      String aladinProfile,
      String copyright,
      String copyrightUrl,
      String path,
      String aladinHpxParam) {
    super(aladin, actionName, aladinMenuNumber, aladinLabel, path);
    this.aladinLabel = aladinLabel;
    this.url = url;
    this.description = description;
    this.verboseDescr = verboseDescr;
    this.ack = ack;
    this.copyright = copyright;
    this.copyrightUrl = copyrightUrl;
    this.hpxParam = aladinHpxParam;
    this.aladinProfile = aladinProfile;
    this.internalId = id;

    if (this.url != null) {
      char c = this.url.charAt(this.url.length() - 1);
      if (c == '/' || c == '\\') this.url = this.url.substring(0, this.url.length() - 1);
    }

    // Parsing des paramètres Healpix
    // ex: 3 8 nocache
    boolean first = true;
    if (hpxParam != null) {
      StringTokenizer st = new StringTokenizer(hpxParam);
      try {
        String s;
        while (st.hasMoreTokens()) {
          s = st.nextToken();

          // test minOrder maxOrder (si un seul nombre => maxOrder);
          try {
            int n = Integer.parseInt(s);
            if (maxOrder != -1) {
              minOrder = maxOrder;
              maxOrder = n;
            } else maxOrder = n;
          } catch (Exception e) {
          }

          if (Util.indexOfIgnoreCase(s, "nocache") >= 0) useCache = false;
          if (Util.indexOfIgnoreCase(s, "color") >= 0) color = true;
          if (Util.indexOfIgnoreCase(s, "cube") >= 0) cube = true;
          if (Util.indexOfIgnoreCase(s, "fits") >= 0) {
            inFits = true;
            if (first) {
              first = false;
              truePixels = true;
            }
          }
          if (Util.indexOfIgnoreCase(s, "jpeg") >= 0) {
            inJPEG = true;
            if (first) {
              first = false;
              truePixels = false;
            }
          }
          if (Util.indexOfIgnoreCase(s, "png") >= 0) {
            inPNG = true;
            if (first) {
              first = false;
              truePixels = false;
            }
          }
          if (Util.indexOfIgnoreCase(s, "gal") >= 0) frame = Localisation.GAL;
          if (Util.indexOfIgnoreCase(s, "ecl") >= 0) frame = Localisation.ECLIPTIC;
          if (Util.indexOfIgnoreCase(s, "equ") >= 0) frame = Localisation.ICRS;
          if (Util.indexOfIgnoreCase(s, "cat") >= 0) cat = true;
          if (Util.indexOfIgnoreCase(s, "progen") >= 0) progen = true;
          if (Util.indexOfIgnoreCase(s, "map") >= 0) map = true;
          if (Util.indexOfIgnoreCase(s, "moc") >= 0) moc = true;

          // Un numéro de version du genre "v1.23" ?
          if (s.charAt(0) == 'v') {
            try {
              double n = Double.parseDouble(s.substring(1));
              version = "-" + s;
            } catch (Exception e) {
            }
          }
        }
        if (minOrder == -1) minOrder = 2;
        if (maxOrder == -1) maxOrder = 8;
      } catch (Exception e) {
      }
    }

    // dans le cas d'un répertoire local => pas d'utilisateur du cache
    if (url != null && !url.startsWith("http") && !url.startsWith("ftp")) useCache = false;

    if (copyright != null || copyrightUrl != null) setCopyright(copyright);

    //      Aladin.trace(3,this.toString1());
  }