Example #1
0
  protected void setCoord(ViewSimple v) {
    Coord c = new Coord();
    boolean ok = false;
    //      if( plan.type==Plan.TOOL && ((PlanTool)plan).lock() ) return;

    Projection proj;
    if (Projection.isOk(proj = v.getProj())) {
      c.x = xv[v.n];
      c.y = yv[v.n];
      proj.getCoord(c);
      raj = c.al;
      dej = c.del;
      ok = true;
    }

    if (!ok && plan.type == Plan.TOOL) {
      ((PlanTool) plan).setXYorig(true);
    }

    if (ok) {
      View view = plan.aladin.view;
      for (int i = 0; i < view.modeView; i++) {
        ViewSimple vx = view.viewSimple[i];
        if (vx != v && !vx.isFree()) projection(vx);
      }
    }
  }
Example #2
0
 /**
  * Modification de la position en ra,dec (relative) C'EST BIZARRE, CA MARCHE MIEUX SANS TESTER LES
  * DEPASSEMENT EN ra,dec
  *
  * @param dra,dde decalages
  */
 protected void deltaRaDec(double dra, double dde) {
   raj += dra;
   dej += dde;
   //      if( dej>90.) { dej=180-dej; raj+=180.; }
   //      if( dej<90.) { dej=-180-dej; raj+=180.; }
   //      if( raj>=360.) raj-=360;
   //      if( raj<0.) raj+=360;
   View view = plan.aladin.view;
   for (int i = 0; i < view.modeView; i++) {
     ViewSimple v = view.viewSimple[i];
     if (!v.isFree()) projection(v);
   }
 }
Example #3
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);
  }
Example #4
0
  /**
   * Modification de la position (absolue)
   *
   * @param x,y nouvelle position
   */
  protected void setPosition(ViewSimple v, double x, double y) {
    // Positionnement d'un objet n'ayant que des positions x,y natives
    if (raj == Double.NaN) {
      this.x = x;
      this.y = v.getPRefDimension().height - y;
    }

    xv[v.n] = x;
    yv[v.n] = y;
    setCoord(v);
  }
Example #5
0
  /**
   * Projection de la source => calcul (x,y).
   *
   * @param proj la projection a utiliser
   */
  protected void projection(ViewSimple v) {

    Projection proj;
    Coord c = new Coord();

    // S'il n'y a pas de calibration, on prend les x,y natifs
    if ((plan != null && plan.hasXYorig) || !Projection.isOk(proj = v.getProj())) {
      xv[v.n] = x - 0.5;
      yv[v.n] = v.getPRefDimension().height - y + 0.5;

      // Sinon on calcule les xy en fonction des coord. ra,de
    } else {
      // Calcul initial d'un objet n'ayant des des positions xy natives
      if (raj == Double.NaN && xv[v.n] != 0) setCoord(v, proj);

      c.al = raj;
      c.del = dej;
      proj.getXY(c);
      xv[v.n] = c.x;
      yv[v.n] = c.y;
    }
  }
Example #6
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);
  }
Example #7
0
  /**
   * Creation d'un objet graphique (methode generalisee)
   *
   * @param plan plan d'appartenance de la ligne
   * @param x,y position XY
   * @param raj,dej position RA,DEC
   * @param methode masque de bits pour indiquer quels sont les champs qu'on doit mettre a jour : XY
   *     : la position (x,y) dans les coordonnees de l'image RADE : la position RA,DEC RADE_COMPUTE
   *     : la position RA,DEC est deduite de XY en fonction de l'astrometrie courante XY_COMPUTE :
   *     la position XY est deduite de RA,DEC en fonction de l'astrometrie courante
   * @param id identificateur associe a l'objet graphique
   */
  protected Position(
      Plan plan, ViewSimple v, double x, double y, double raj, double dej, int methode, String id) {
    this.id = id;
    this.plan = plan;
    createCacheXYVP();

    // On me passe un XY
    if ((methode & XY) != 0) {
      if (v != null) {
        xv[v.n] = x;
        yv[v.n] = y;
      }

      // Pas de calibration astrométrique associée ?
      if (v == null || v.pref == null || !Projection.isOk(v.getProj())) {
        this.x = x;
        this.y = (v == null ? y : v.getPRefDimension().height - y);
      }

      // Calcul des coordonnées correspondantes ?
      else if ((methode & RADE_COMPUTE) != 0) {
        setCoord(v);
      }
    }

    // On me passe des coord.
    if ((methode & RADE) != 0) {
      this.raj = raj;
      this.dej = dej;
      if ((methode & XY_COMPUTE) != 0) {
        try {
          projection(v);
        } catch (Exception e) {
        }
      }
    }
  }
Example #8
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);
  }
Example #9
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);
 }
Example #10
0
 // ajout Thomas pour generation LINK avec coordonnees en flottants
 protected PointD getViewCoordDouble(ViewSimple v, int dw, int dh) {
   if (Double.isNaN(xv[v.n])) return null;
   return v.getViewCoordDoubleWithMarge(null, xv[v.n], yv[v.n], dw, dh);
 }