Back to index

wims  3.65+svn20090927
Repere.java
Go to the documentation of this file.
00001 package geo ;
00002 
00003 import java.awt.Graphics ;
00004 
00013 public class Repere
00014 {
00015 
00020   public int X0 ;
00021 
00026   public int Y0 ;
00027 
00032    public int XMAX ;
00033 
00039    public int YMAX ;
00040 
00045   public double unitex ;
00046 
00051   public double unitey ;
00052 
00057   public Repere (int X0,int Y0,int XMAX,int YMAX,double unitex,double unitey)
00058   { this.X0 = X0; this.Y0 = Y0;
00059     this.XMAX = XMAX ; this.YMAX = YMAX ;
00060     this.unitex = unitex ; this.unitey = unitey ;
00061   }
00062 
00067   public void trace (Graphics g)
00068   { int UX = X0 + new Double (unitex) . intValue () ;
00069     int UY = Y0 - new Double (unitey) . intValue () ;
00070     if ((Y0 >= 0) && (Y0 <= YMAX)) { g.drawLine (0, Y0, XMAX, Y0) ;
00071                                         if ((UX >= 0) && (UX <= XMAX))
00072                                               g.drawLine (UX, Y0 - 2, UX, Y0 + 2) ;
00073                                       } 
00074     if ((X0 >= 0) && (X0 <= XMAX)) { g.drawLine (X0, 0, X0, YMAX) ;
00075                                         if ((UY >= 0) && (UY <= YMAX))
00076                                               g.drawLine (X0 - 2, UY, X0 + 2, UY);
00077                                       }
00078     }
00079 
00084   public void cadre (Graphics g)
00085   { g.drawRect (0, 0, XMAX - 1, YMAX - 1) ; }
00086 
00091   public int Iabs (double x)
00092   { return (int) (x * unitex + X0); }
00093 
00098   public int Iord (double y)
00099   { return (int) (- y * unitey + Y0); }
00100 
00105   public double Abs (int X)
00106   { return (X - X0) / unitex ; }
00107 
00112   public double Ord (int Y)
00113   { return (Y0 - Y) / unitey ; }
00114 
00119   public boolean affiche (int X, int Y)
00120   { return ((X >= 0) && (X <= XMAX) && (Y >= 0) && (Y <= YMAX)); }
00121 
00126   public void Repere (int X0,int Y0,int XMAX,int YMAX,double unitex,double unitey)
00127   { this.X0 = X0; this.Y0 = Y0;
00128     this.XMAX = XMAX ; this.YMAX = YMAX ;
00129     this.unitex = unitex ; this.unitey = unitey ;
00130   }
00131 
00132 }
00133