|
From: <de...@us...> - 2012-06-21 21:15:00
|
Revision: 7376
http://fudaa.svn.sourceforge.net/fudaa/?rev=7376&view=rev
Author: deniger
Date: 2012-06-21 21:14:53 +0000 (Thu, 21 Jun 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/trace/TraceLigne.java
Added Paths:
-----------
trunk/framework/ebli-2d/src/test/java/org/fudaa/ebli/calque/edition/
Modified: trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/trace/TraceLigne.java
===================================================================
--- trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/trace/TraceLigne.java 2012-06-21 20:36:45 UTC (rev 7375)
+++ trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/trace/TraceLigne.java 2012-06-21 21:14:53 UTC (rev 7376)
@@ -20,45 +20,62 @@
/**
* Une classe de trace de lignes.
- *
+ *
* @version $Id: TraceLigne.java,v 1.20 2007-03-15 17:00:29 deniger Exp $
* @author Axel von Arnim
*/
public class TraceLigne {
- private final static float[] POINTILLE_DASH = { 2.0f, 2.0f };
- /** */
- private final static float[] TIRETE_DASH = { 6.0f, 3.0f };
- /** */
- /** */
- private final static float[] MIXTE_DASH = { 6.0f, 3.0f, 3.0f, 3.0f };
+ private final static float[] POINTILLE_DASH = {2.0f, 2.0f};
+ /**
+ * */
+ private final static float[] TIRETE_DASH = {6.0f, 3.0f};
+ /**
+ * */
+ /**
+ * */
+ private final static float[] MIXTE_DASH = {6.0f, 3.0f, 3.0f, 3.0f};
private final static BasicStroke DEFAULT_MIXTE_STROKE = new BasicStroke(1f, BasicStroke.CAP_BUTT,
- BasicStroke.JOIN_MITER, 10.0f, MIXTE_DASH, 0.0f);
- /** */
+ BasicStroke.JOIN_MITER, 10.0f, MIXTE_DASH, 0.0f);
+ /**
+ * */
private final static BasicStroke DEFAULT_POINTILLE_STROKE = new BasicStroke(1f, BasicStroke.CAP_BUTT,
- BasicStroke.JOIN_MITER, 10.0f, POINTILLE_DASH, 0.0f);
- /** */
+ BasicStroke.JOIN_MITER, 10.0f, POINTILLE_DASH, 0.0f);
+ /**
+ * */
private final static BasicStroke DEFAULT_STROKE = new BasicStroke(1f);
- /** */
+ /**
+ * */
private final static BasicStroke DEFAULT_TIRETE_STROKE = new BasicStroke(1f, BasicStroke.CAP_BUTT,
- BasicStroke.JOIN_MITER, 10.0f, TIRETE_DASH, 0.0f);
-
+ BasicStroke.JOIN_MITER, 10.0f, TIRETE_DASH, 0.0f);
final static double C_MAGIC = Math.PI / 4.;
- /** */
+ /**
+ * */
public final static Font FONTBASE = new Font("SansSerif", Font.PLAIN, 20);
- /** Ligne non dessinee. */
+ /**
+ * Ligne non dessinee.
+ */
public final static int INVISIBLE = 0;
- /** Ligne lisse. */
+ /**
+ * Ligne lisse.
+ */
public final static int LISSE = 1;
- /** ligne mixte. */
+ /**
+ * ligne mixte.
+ */
public final static int MIXTE = 5;
- /** les points remarquables sont mis en valeur. */
+ /**
+ * les points remarquables sont mis en valeur.
+ */
public final static int POINT_MARQUE = 2;
- /** ligne pointillee. */
+ /**
+ * ligne pointillee.
+ */
public final static int POINTILLE = 3;
- /** ligne tiretee. */
+ /**
+ * ligne tiretee.
+ */
public final static int TIRETE = 4;
-
private TraceLigneModel model_;
public final TraceLigneModel getModel() {
@@ -103,7 +120,7 @@
* @return le polygone correspondant
*/
private Polygon arc2polygon(final int _x1, final int _y1, final int _x2, final int _y2, final int _vx1,
- final int _vy1, final int _vx2, final int _vy2) {
+ final int _vy1, final int _vx2, final int _vy2) {
final int nb = (Math.abs(_x2 - _x1) + Math.abs(_y2 - _y1)) / 2;
Point pf;
final int[] x = new int[nb + 1];
@@ -123,20 +140,20 @@
*/
private float[] getDashArray() {
switch (model_.typeTrait_) {
- case POINTILLE:
- return POINTILLE_DASH;
- case TIRETE:
- return TIRETE_DASH;
- case MIXTE:
- return MIXTE_DASH;
- default:
- return FuEmptyArrays.FLOAT0;
+ case POINTILLE:
+ return POINTILLE_DASH;
+ case TIRETE:
+ return TIRETE_DASH;
+ case MIXTE:
+ return MIXTE_DASH;
+ default:
+ return FuEmptyArrays.FLOAT0;
}
}
/**
* Initialise le graphics2D g_.
- *
+ *
* @return true si l'initialisation de g_ a ete effectuee false si le type de trait est invisible
*/
protected boolean initialisationGraphics(final Graphics2D _g) {
@@ -151,17 +168,17 @@
}
public Polygon creeArc(final double _x1, final double _y1, final double _x2, final double _y2, final double _vx1,
- final double _vy1, final double _vx2, final double _vy2) {
+ final double _vy1, final double _vx2, final double _vy2) {
return creeArc((int) _x1, (int) _y1, (int) _x2, (int) _y2, (int) _vx1, (int) _vy1, (int) _vx2, (int) _vy2);
}
/**
* Cree un arc sous forme d'un polygone. Voir <i>dessineArc </i> pour les parametres.
- *
+ *
* @return l'arc
*/
public Polygon creeArc(final int _x1, final int _y1, final int _x2, final int _y2, final int _vx1, final int _vy1,
- final int _vx2, final int _vy2) {
+ final int _vx2, final int _vy2) {
final int nb = (Math.abs(_x2 - _x1) + Math.abs(_y2 - _y1)) / 2;
Point pf;
final int[] x = new int[nb + 2];
@@ -182,7 +199,7 @@
}
public void dessineArc(final Graphics2D _g, final double _x1, final double _y1, final double _x2, final double _y2,
- final double _vx1, final double _vy1, final double _vx2, final double _vy2) {
+ final double _vx1, final double _vy1, final double _vx2, final double _vy2) {
final Color oldColor = _g.getColor();
final Stroke oldStroke = _g.getStroke();
if (!initialisationGraphics(_g)) {
@@ -202,11 +219,11 @@
/**
* Trace un arc. Il est trace avec le type de trait definit par <i>typeTrait </i>.
- *
+ *
* @see #setTypeTrait(int)
*/
public void dessineArc(final Graphics2D _g, final int _x1, final int _y1, final int _x2, final int _y2,
- final int _vx1, final int _vy1, final int _vx2, final int _vy2) {
+ final int _vx1, final int _vy1, final int _vx2, final int _vy2) {
final Color oldColor = _g.getColor();
final Stroke oldStroke = _g.getStroke();
if (!initialisationGraphics(_g)) {
@@ -226,7 +243,7 @@
/**
* Meme fonctionnement que dessineArc. La courbure est plus sensible.
- *
+ *
* @param _x1
* @param y1
* @param x2
@@ -237,7 +254,7 @@
* @param vy2
*/
public void dessineArc2D(final Graphics2D _g, final double _x1, final double _y1, final double _x2, final double _y2,
- final double _vx1, final double _vy1, final double _vx2, final double _vy2) {
+ final double _vx1, final double _vy1, final double _vx2, final double _vy2) {
final Color oldColor = _g.getColor();
final Stroke oldStroke = _g.getStroke();
if (!initialisationGraphics(_g)) {
@@ -252,20 +269,20 @@
* Dessine une ellipse passant par les points x1,x2,x3 et x4.
*/
public void dessineEllipse(final Graphics2D _g, final int _x1, final int _y1, final int _x2, final int _y2,
- final int _x3, final int _y3, final int _x4, final int _y4) {
+ final int _x3, final int _y3, final int _x4, final int _y4) {
int i;
final Polygon arc1 = arc2polygon((_x1 + _x2) / 2, (_y1 + _y2) / 2, (_x2 + _x3) / 2, (_y2 + _y3) / 2,
- (int) ((_x2 - _x1) * C_MAGIC), (int) ((_y2 - _y1) * C_MAGIC), (int) ((_x3 - _x2) * C_MAGIC),
- (int) ((_y3 - _y2) * C_MAGIC));
+ (int) ((_x2 - _x1) * C_MAGIC), (int) ((_y2 - _y1) * C_MAGIC), (int) ((_x3 - _x2) * C_MAGIC),
+ (int) ((_y3 - _y2) * C_MAGIC));
final Polygon arc2 = arc2polygon((_x2 + _x3) / 2, (_y2 + _y3) / 2, (_x3 + _x4) / 2, (_y3 + _y4) / 2,
- (int) ((_x3 - _x2) * C_MAGIC), (int) ((_y3 - _y2) * C_MAGIC), (int) ((_x4 - _x3) * C_MAGIC),
- (int) ((_y4 - _y3) * C_MAGIC));
+ (int) ((_x3 - _x2) * C_MAGIC), (int) ((_y3 - _y2) * C_MAGIC), (int) ((_x4 - _x3) * C_MAGIC),
+ (int) ((_y4 - _y3) * C_MAGIC));
final Polygon arc3 = arc2polygon((_x3 + _x4) / 2, (_y3 + _y4) / 2, (_x4 + _x1) / 2, (_y4 + _y1) / 2,
- (int) ((_x4 - _x3) * C_MAGIC), (int) ((_y4 - _y3) * C_MAGIC), (int) ((_x1 - _x4) * C_MAGIC),
- (int) ((_y1 - _y4) * C_MAGIC));
+ (int) ((_x4 - _x3) * C_MAGIC), (int) ((_y4 - _y3) * C_MAGIC), (int) ((_x1 - _x4) * C_MAGIC),
+ (int) ((_y1 - _y4) * C_MAGIC));
final Polygon arc4 = arc2polygon((_x4 + _x1) / 2, (_y4 + _y1) / 2, (_x1 + _x2) / 2, (_y1 + _y2) / 2,
- (int) ((_x1 - _x4) * C_MAGIC), (int) ((_y1 - _y4) * C_MAGIC), (int) ((_x2 - _x1) * C_MAGIC),
- (int) ((_y2 - _y1) * C_MAGIC));
+ (int) ((_x1 - _x4) * C_MAGIC), (int) ((_y1 - _y4) * C_MAGIC), (int) ((_x2 - _x1) * C_MAGIC),
+ (int) ((_y2 - _y1) * C_MAGIC));
final int[] ellx = new int[arc1.npoints + arc2.npoints + arc3.npoints + arc4.npoints];
final int[] elly = new int[arc1.npoints + arc2.npoints + arc3.npoints + arc4.npoints];
for (i = 0; i < arc1.npoints; i++) {
@@ -289,7 +306,7 @@
/**
* Dessine une eclipse dans le rectangle dont le coin a gauche est (_x,_y), la largeur _w et la hauteur _h.
- *
+ *
* @param _x abscisse point en haut a gauche
* @param _y abscisse point en haut a gauche
* @param _w largeur
@@ -319,8 +336,9 @@
}
/**
- * Trace une fleche. La fleche est tracee avec le type definit par <i>typeTrait </i>. \ | \ ecart \ | ------------ / / /<-->retour
- *
+ * Trace une fleche. La fleche est tracee avec le type definit par <i>typeTrait </i>. \ | \ ecart \ | ------------ / /
+ * /<-->retour
+ *
* @param _x1 premier point x
* @param _y1 premier point y
* @param _x2 deuxieme point x
@@ -330,7 +348,7 @@
* @see #setTypeTrait(int)
*/
public void dessineFleche(final Graphics2D _g, final int _x1, final int _y1, final int _x2, final int _y2,
- final int _retour, final int _ecart) {
+ final int _retour, final int _ecart) {
final Color oldColor = _g.getColor();
final Stroke oldStroke = _g.getStroke();
if (!initialisationGraphics(_g)) {
@@ -339,13 +357,13 @@
_g.drawLine(_x1, _y1, _x2, _y2);
_g.setColor(oldColor);
_g.setStroke(oldStroke);
-
+
dessinePointe(_g, _x1, _y1, _x2, _y2, _retour, _ecart);
}
-
+
/**
- * Trac\xE9 d'une pointe de fleche uniquement, centr\xE9e sur (xpointe,ypointe).
- * La direction est donn\xE9e par le deuxieme point (xorig,yorig).
+ * Trac\xE9 d'une pointe de fleche uniquement, centr\xE9e sur (xpointe,ypointe). La direction est donn\xE9e par le deuxieme point
+ * (xorig,yorig).
* @param _g Le contexte graphique
* @param _xorig Le x du point d'origine, donnant la direction.
* @param _yorig Le y du point d'origine, donnant la direction.
@@ -355,7 +373,7 @@
* @param _retour la longueur du retour de la fleche
*/
public void dessinePointe(final Graphics2D _g, final int _xorig, final int _yorig, final int _xpointe, final int _ypointe,
- final int _retour, final int _ecart) {
+ final int _retour, final int _ecart) {
final Color oldColor = _g.getColor();
final Stroke oldStroke = _g.getStroke();
if (!initialisationGraphics(_g)) {
@@ -391,12 +409,10 @@
_g.setColor(oldColor);
_g.setStroke(oldStroke);
}
-
-
-
+
/**
* Trace un polygone. Il est trace avec le type definit par <i>typeTrait </i>.
- *
+ *
* @param _x polygone x
* @param _y polygone y
* @see #setTypeTrait(int)
@@ -423,7 +439,7 @@
/**
* Trace une polyligne. Elle est tracee avec le type defini par <i>typeTrait </i>.
- *
+ *
* @param _x polyligne x
* @param _y polyligne y
* @see #setTypeTrait(int)
@@ -455,13 +471,13 @@
}
public void dessineRectangle(final Graphics2D _g2d, final double _x, final double _y, final double _largeur,
- final double _hauteur) {
+ final double _hauteur) {
dessineRectangle(_g2d, (int) _x, (int) _y, (int) _largeur, (int) _hauteur);
}
/**
* Trace un rectangle. Il est trace avec le type de trait <i>typetrait </i>.
- *
+ *
* @param _x position x
* @param _y position y
* @param _largeur largeur
@@ -473,7 +489,7 @@
}
public void dessineRoundRectangle(final Graphics2D _g, final int _x, final int _y, final int _largeur,
- final int _hauteur, final int _rayon) {
+ final int _hauteur, final int _rayon) {
final Color oldColor = _g.getColor();
final Stroke oldStroke = _g.getStroke();
if (!initialisationGraphics(_g)) {
@@ -489,9 +505,11 @@
r.setRect(_x - 1d, _y + _hauteur - 1d, 2d, 2d);
_g.draw(r);
}
- if (_rayon > 0) _g.drawRoundRect(_x, _y, _largeur - 1, _hauteur - 1, _rayon, _rayon);
- else
+ if (_rayon > 0) {
+ _g.drawRoundRect(_x, _y, _largeur - 1, _hauteur - 1, _rayon, _rayon);
+ } else {
_g.drawRect(_x, _y, _largeur - 1, _hauteur - 1);
+ }
_g.setColor(oldColor);
_g.setStroke(oldStroke);
}
@@ -512,7 +530,7 @@
/**
* Trace un texte.
- *
+ *
* @param _t le texte
* @param _x position x
* @param _y position y
@@ -537,7 +555,7 @@
/**
* Trace un trait. Le trait est trace avec le type definit par <i>typeTrait </i>.
- *
+ *
* @param _x1 premier point x
* @param _y1 premier point y
* @param _x2 deuxieme point x
@@ -558,7 +576,12 @@
_g.drawRect(_x1 - 1, _y1 - 1, 2, 2);
_g.drawRect(_x2 - 1, _y2 - 1, 2, 2);
} else {
- _g.drawLine(_x1, _y1, _x2, _y2);
+ try {
+ _g.drawLine(_x1, _y1, _x2, _y2);
+ } catch (Throwable e) {
+ Stroke stroke = _g.getStroke();
+ e.printStackTrace();
+ }
}
_g.setColor(oldColor);
_g.setStroke(oldStroke);
@@ -584,13 +607,13 @@
return DEFAULT_STROKE;
}
switch (model_.typeTrait_) {
- case POINTILLE:
- return DEFAULT_POINTILLE_STROKE;
- case TIRETE:
- return DEFAULT_TIRETE_STROKE;
- case MIXTE:
- return DEFAULT_MIXTE_STROKE;
- default:
+ case POINTILLE:
+ return DEFAULT_POINTILLE_STROKE;
+ case TIRETE:
+ return DEFAULT_TIRETE_STROKE;
+ case MIXTE:
+ return DEFAULT_MIXTE_STROKE;
+ default:
}
}
if (model_.typeTrait_ == LISSE || (model_.typeTrait_ == POINT_MARQUE)) {
@@ -614,5 +637,4 @@
public boolean setTypeTrait(final int _type) {
return model_.setTypeTrait(_type);
}
-
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|