Back to index

wims  3.65+svn20090927
Public Member Functions | Public Attributes | Private Member Functions
geo.Polygone Class Reference

Polygone. More...

Inheritance diagram for geo.Polygone:
Inheritance graph
[legend]
Collaboration diagram for geo.Polygone:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Polygone (String Nom, Repere R)
 Construit un polygone non défini.
 Polygone (pt Ai[], int n, boolean type, String Nom, Repere R)
 Construit le polygone A1, A2, ..., An, A1.
 Polygone (double xi[], double yi[], int n, boolean type, String Nom, Repere R)
 Construit le polygone avec des coordonnees de points.
void trace (Graphics g)
 Trace ou efface le polygone.
boolean zone (int X, int Y)
 Teste si le curseur de la souris est proche du polygone.
void Polygone (pt Ai[], int n, boolean type)
 Redéfinit le polygone.
void Polygone (double xi[], double yi[], int n, boolean type)
 Redéfinit le polygone.

Public Attributes

double xi []
double yi []
boolean plein
 uitilisé pour le traçage : "true" pour un remplissage de la figure, "false" pour le dessin du bord uniquement
Polygon p
Repere R
 Repere associé.
boolean defini
 Existence de l'objet.
String Nom
 Nom de l'objet.

Private Member Functions

void maj (int n)

Detailed Description

Polygone.

Definition at line 12 of file Polygone.java.


Constructor & Destructor Documentation

geo.Polygone.Polygone ( String  Nom,
Repere  R 
) [inline]

Construit un polygone non défini.

Definition at line 30 of file Polygone.java.

  { super (Nom, R) ; plein = false ; }
geo.Polygone.Polygone ( pt  Ai[],
int  n,
boolean  type,
String  Nom,
Repere  R 
) [inline]

Construit le polygone A1, A2, ..., An, A1.

Definition at line 37 of file Polygone.java.

  { super (Nom, R) ; Polygone (Ai, n, type) ; }

Here is the call graph for this function:

Here is the caller graph for this function:

geo.Polygone.Polygone ( double  xi[],
double  yi[],
int  n,
boolean  type,
String  Nom,
Repere  R 
) [inline]

Construit le polygone avec des coordonnees de points.

Definition at line 44 of file Polygone.java.

  { super (Nom, R) ; Polygone (xi, yi, n, type) ; }

Here is the call graph for this function:

Here is the caller graph for this function:

void geo.Polygone.Polygone ( pt  Ai[],
int  n,
boolean  type 
) [inline]

Redéfinit le polygone.

Definition at line 79 of file Polygone.java.

  { defini = true ;
    for (int i = 0 ; (i < n) && defini ; i ++) defini = defini && Ai [i].defini ;
    if (defini)
      { if ((xi == null) || (n != xi.length))
          { xi = new double [n] ;
            yi = new double [n] ;
          }
        for (int i = 0 ; i < n ; i ++)
          { xi [i] = Ai [i].x ;
            yi [i] = Ai [i].y ;
          }
        maj (n) ;
        plein = type ;
      }
  }

Here is the call graph for this function:

void geo.Polygone.Polygone ( double  xi[],
double  yi[],
int  n,
boolean  type 
) [inline]

Redéfinit le polygone.

Definition at line 116 of file Polygone.java.

  { defini = true ;
    if ((this.xi == null) || (n != xi.length))
      { this.xi = new double [n] ;
        this.yi = new double [n] ;
      }
    for (int i = 0 ; i < n ; i ++)
      { this.xi [i] = xi [i] ;
        this.yi [i] = yi [i] ;
      }
    maj (n) ;
    plein = type ;
  }

Here is the call graph for this function:


Member Function Documentation

void geo.Polygone.maj ( int  n) [inline, private]

Definition at line 96 of file Polygone.java.

  { if ((p == null) || (p.npoints != n + 1))
      { p = new Polygon () ;
        for (int i = 0 ; i < n ; i ++) p.addPoint (R.Iabs (xi [i]), R.Iord (yi [i])) ;
        p.addPoint (R.Iabs (xi [0]), R.Iord (yi [0])) ;
      }
    else 
      { for (int i = 0 ; i < n ; i ++)
          { p.xpoints [i] = R.Iabs (xi [i]) ;
            p.ypoints [i] = R.Iord (yi [i]) ;
          }
        p.xpoints [n] = R.Iabs (xi [0]) ;
        p.ypoints [n] = R.Iord (yi [0]) ;
      }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void geo.Polygone.trace ( Graphics  g) [inline]

Trace ou efface le polygone.

Reimplemented from geo.ObjetRepere.

Definition at line 51 of file Polygone.java.

  { if (defini) if (plein) g.fillPolygon (p) ; else g.drawPolygon (p) ;
        if ((defini) && (Nom.length () != 0) && (p.npoints > 0))
          g.drawString (Nom, p.xpoints [0] + 2 , p.ypoints [0] + 2) ;
  }
boolean geo.Polygone.zone ( int  X,
int  Y 
) [inline]

Teste si le curseur de la souris est proche du polygone.

Reimplemented from geo.ObjetRepere.

Definition at line 61 of file Polygone.java.

   { boolean resultat = false ;
     if (defini) for (int i = 0 ; i < p.npoints ; i ++)
       { int AX = p.xpoints [i] ;
         int AY = p.xpoints [i] ;
         int BX = (i == p.npoints - 1) ? p.xpoints [0] : p.xpoints [i + 1] ;
         int BY = (i == p.npoints - 1) ? p.ypoints [0] : p.ypoints [i + 1] ;
         int A = BY - AY ; int B = AX - BX ;
         double d = ((double) Math.abs (A * X + B * Y + AY * BX - AX * BY)) / Math.sqrt ((double) (A * A + B * B)) ;
         if (resultat = ((d <= 4.0) && ((X - AX) * (X - BX) <= 0) && ((Y - AY) * (Y - BY) <= 0))) break ;
       }
     return resultat ;
   }

Member Data Documentation

Existence de l'objet.

Definition at line 22 of file ObjetRepere.java.

String geo.ObjetRepere.Nom [inherited]

Nom de l'objet.

Definition at line 28 of file ObjetRepere.java.

Polygon geo.Polygone.p

Definition at line 24 of file Polygone.java.

uitilisé pour le traçage : "true" pour un remplissage de la figure, "false" pour le dessin du bord uniquement

Definition at line 22 of file Polygone.java.

Repere associé.

Definition at line 16 of file ObjetRepere.java.

double geo.Polygone.xi[]

Definition at line 15 of file Polygone.java.

double geo.Polygone.yi[]

Definition at line 16 of file Polygone.java.


The documentation for this class was generated from the following file: