Exemplo n.º 1
0
  /** Utilisé pour le calcul des statistiques sur un polygone */
  protected double statPixel(Graphics g, int x, int y, ViewSimple v, HistItem onMouse) {

    // Mise à jour des stats
    double pix;
    PlanImage pi = (PlanImage) v.pref;
    Color col = g.getColor();

    if (!(plan instanceof PlanBG)
        && (y < 0
            || y >= pi.naxis2
            || x < 0
            || x >= pi.naxis1
            || (pi.fmt == PlanImage.JPEG || pi.pixelsOrigin == null && !pi.isBigImage()))) {
      pix = Double.NaN;
    } else {
      pix = pi.getPixelInDouble(x, y);
    }

    double zoom = v.getZoom();

    // Coloriage du pixel si concerné
    if (g != null && onMouse != null && onMouse.contains(pix)) {
      Point p = v.getViewCoord(x + 0.5, y + 0.5);
      if (p != null) {
        g.setColor(Color.cyan);
        int z1 = (int) zoom;
        if (z1 < 1) z1 = 2;
        g.fillRect(p.x - z1 / 2, p.y - z1 / 2, z1, z1);
      }
    }

    if (zoom > 2) {
      Point p = v.getViewCoord(x + 0.5, y + 0.5);
      if (Double.isNaN(pix)) g.setColor(Color.orange);
      else g.setColor(Color.red);
      if (zoom > 4) Util.fillCircle5(g, p.x, p.y);
      else Util.fillCircle2(g, p.x, p.y);
    }
    g.setColor(col);

    return statPixel(pix);
  }
Exemplo n.º 2
0
  /** Utilisé pour le calcul des statistiques sur un polygone */
  protected double statPixel(
      Graphics g, double pix, double ra, double dec, ViewSimple v, HistItem onMouse) {

    Coord coo = new Coord(ra, dec);
    v.getProj().getXY(coo);
    Color col = g.getColor();

    // Détermination de la taille d'un pixel Healpix sur la vue.
    double pixelSize =
        v.rv.height / (v.getTailleDE() / ((PlanBG) v.pref).getPixelResolution()) / Math.sqrt(2);

    // Coloriage du pixel si concerné
    if (g != null && onMouse != null && onMouse.contains(pix)) {
      Point p = v.getViewCoord(coo.x, coo.y);
      if (p != null) {
        g.setColor(Color.cyan);
        int z1 = (int) pixelSize;
        if (z1 < 1) z1 = 2;
        Polygon pol =
            new Polygon(
                new int[] {p.x, p.x + z1, p.x, p.x - z1},
                new int[] {p.y - z1, p.y, p.y + z1, p.y},
                4);
        g.fillPolygon(pol);
      }
    }

    if (pixelSize > 4) {
      Point p = v.getViewCoord(coo.x, coo.y);
      if (Double.isNaN(pix)) g.setColor(Color.orange);
      else g.setColor(Color.red);
      if (pixelSize > 8) Util.fillCircle5(g, p.x, p.y);
      else Util.fillCircle2(g, p.x, p.y);
    }
    g.setColor(col);

    return statPixel(pix);
  }
Exemplo n.º 3
0
  /** Affichage des statistiques d'un polygone */
  protected void statDraw(Graphics g, ViewSimple v, int dx, int dy) {

    // Juste pour afficher le débugging des losanges HEALPix couvrant
    //       if( v.pref instanceof PlanBG && ((PlanBG)v.pref).DEBUGMODE )  { statCompute(g,v);
    // return; }

    if (!v.flagPhotometry || !v.pref.hasAvailablePixels() || v.pref instanceof PlanImageRGB) return;

    if (!statCompute(g, v)) return;

    String cnt = Util.myRound(nombre);
    String sum = Util.myRound(total);
    String avg = Util.myRound(moyenne);
    String med = Double.isNaN(mediane) ? "" : Util.myRound(mediane);
    String sig = Util.myRound(sigma);
    String surf = Coord.getUnit(surface, false, true) + "²";

    if (isWithStat() || isWithLabel()) {
      Rectangle r = getStatPosition(v);
      if (r != null && (isWithLabel() || v.aladin.view.isMultiView())) {
        r.x += dx;
        r.y += dy;
        g.drawLine(r.x, r.y, r.x, r.y + HAUTSTAT);
        if (posx == -1) {
          posx = (int) (minx + 3 * (maxx - minx) / 4.);
          posy = (maxy + miny) / 2;
        }
        Point c = v.getViewCoord(posx, posy);
        if (c != null) {
          g.drawLine(r.x, r.y + HAUTSTAT / 2, c.x, c.y);
          Util.fillCircle5(g, c.x, c.y);

          r.x += 2;
          r.y += STATDY - 2;

          g.setFont(Aladin.BOLD);
          g.drawString("Cnt", r.x, r.y);
          g.drawString(cnt, r.x + 43, r.y);
          r.y += STATDY;
          g.drawString("Sum", r.x, r.y);
          g.drawString(sum, r.x + 43, r.y);
          r.y += STATDY;
          g.drawString("Avg", r.x, r.y);
          g.drawString(avg, r.x + 43, r.y);
          r.y += STATDY;
          g.drawString("Sigma", r.x, r.y);
          g.drawString(sig, r.x + 43, r.y);
          r.y += STATDY;
          if (this instanceof Repere) {
            g.drawString("Rad", r.x, r.y);
            g.drawString(Coord.getUnit(((Repere) this).getRadius()), r.x + 43, r.y);
            r.y += STATDY;
          }
          g.drawString("Surf", r.x, r.y);
          g.drawString(surf, r.x + 43, r.y);
          r.y += STATDY;
          if (!Double.isNaN(mediane)) {
            g.drawString("Med", r.x, r.y);
            g.drawString(med, r.x + 43, r.y);
            r.y += STATDY;
          }
        }
      }
    }

    if (v.pref == plan.aladin.calque.getPlanBase()) {
      id =
          "Cnt "
              + cnt
              + " / Sum "
              + sum
              + " / Avg "
              + avg
              + " / Sigma "
              + sig
              + (this instanceof Repere
                  ? " / Rad " + Coord.getUnit(((Repere) this).getRadius())
                  : "")
              + " / Surf "
              + surf
              + (Double.isNaN(mediane) ? "" : " / Med " + med);
      histOn();
    }
    //       status(plan.aladin);
  }
Exemplo n.º 4
0
 /** Retourne la position en unité View des stats */
 protected Rectangle getStatPosition(ViewSimple v) {
   Point hg = v.getViewCoord(minx, miny);
   Point bd = v.getViewCoord(maxx, maxy);
   if (hg == null || bd == null) return null;
   return new Rectangle(bd.x + 5, hg.y, LARGSTAT, HAUTSTAT);
 }