Applications graphiques en Java JAVA Graphique 2D ● L'objet Graphics2D de Java Swing permet : – la transformation affine ● (rotation, basculement, étirement, ...) – la gestion de couleurs JAVA 2D ● (contraste, luminosité, netteté, saturation...) – La gestion du rendu E. ADAM ● (texture, dégradé de couleurs, ...) UVHC - ISTV – L'édition de texte améliorée E. ADAM – ISTV - UVHC E. ADAM – ISTV - UVHC Applications graphiques en Java Applications graphiques en Java Transformations Transformations ● ● G2D permet : AffineTransform : appliquer une transformation affine sous forme de matrice à chaque point (x, y) d'un – la rotation (rotate), le redimensionnement (scale), graphique : le basculement (shear), la translation (translate) de graphiques a c tx x ' x a.x c.y tx =[ ]. = – b d ty Il est possible de combiner les transformations : y' y b.x d.y ty ● Utilisation de la classe de Transformation Affine : – AffineTransform Redimensionnement 2 0 0 [ ] 0 0.5 0 E. ADAM – ISTV - UVHC E. ADAM – ISTV - UVHC Applications graphiques en Java Applications graphiques en Java Transformations Transformations Translation Rotation PI/2 1 0 10 0 1 0 [ ] [ ] 20 1 0 0 0 1 20 0 10 0 0 0 Basculement Rotation Téta cos tetha sin tetha 0 1 0.5 0 [ ] [ ] sin tetha cos tetha 0 0 1 0 0 0 0 0 E. ADAM – ISTV - UVHC E.
–la gestion de couleurs ●(contraste, luminosité, netteté, saturation...)
–La gestion du rendu ●(texture, dégradé de couleurs, ...)
–L'édition de texte améliorée
Applications graphiques en Java
Transformations
●AffineTransform : appliquer une transformation affine sous forme de matrice à chaque point (x, y) d'un graphique : ' x'=[caxtydtb].x=x.a.by.cd.txt
Redimensionnement
[2 0 0] 0 0.5 0
Applications graphiques en Java
Translation
0
Basculement
0
Transformations
[21001001]
[05.00110]
Applications graphiques en Java
0
20
Transformations
0 10
●Utilisation de TransformAffine : –Dans la méthode paint ou paintComponent :
publicvoidaipContnopmtne(Graphics g) { super.paintComponent(g); if (!tracker.)(0DIkcehc)return;
}
Graphics2D g2d = (Graphics2D) g; AffineTransform atOld = g2d.getTransform(); AffineTransform atT = new AffineTransform(); atT.rotate(Math.PI/6);
// definition d'une transparence à 50% pour les prochains dessins AlphaCompositeac = AlaCphpoomtesi.nItsgtenaec(mposhaCoSRC_ite.REVOApl, 0.5f); g2d.poomtCsetesi(ac);
Programmer’s Guide to theJava 2D™ API Enhanced Graphics and Imaging for Java JavaTM 2 SDK, Standard Edition, 1.4 Version April 24, 2001 ●" / + ! ; ?