From: <bma...@us...> - 2008-08-29 08:53:18
|
Revision: 3849 http://fudaa.svn.sourceforge.net/fudaa/?rev=3849&view=rev Author: bmarchan Date: 2008-08-29 08:53:27 +0000 (Fri, 29 Aug 2008) Log Message: ----------- Ajout d'un modele pour le trac?\195?\169 de surfaces. Modified Paths: -------------- branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/trace/TraceSurface.java Added Paths: ----------- branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/trace/TraceSurfaceModel.java Modified: branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java =================================================================== --- branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java 2008-08-29 08:52:01 UTC (rev 3848) +++ branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java 2008-08-29 08:53:27 UTC (rev 3849) @@ -14,6 +14,7 @@ import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Polygon; import org.nfunk.jep.Variable; @@ -44,6 +45,7 @@ import org.fudaa.ebli.commun.EbliSelectionMode; import org.fudaa.ebli.commun.EbliSelectionState; import org.fudaa.ebli.commun.EbliUIProperties; +import org.fudaa.ebli.controle.BSelecteurLineModel; import org.fudaa.ebli.find.EbliFindExpressionContainerInterface; import org.fudaa.ebli.geometrie.GrBoite; import org.fudaa.ebli.geometrie.GrMorphisme; @@ -52,6 +54,8 @@ import org.fudaa.ebli.trace.TraceIconModel; import org.fudaa.ebli.trace.TraceLigne; import org.fudaa.ebli.trace.TraceLigneModel; +import org.fudaa.ebli.trace.TraceSurface; +import org.fudaa.ebli.trace.TraceSurfaceModel; /** * Un calque g\xE9rant des g\xE9om\xE9tries quelconques, \xE0 un niveau global ou atomique.<p> @@ -112,11 +116,12 @@ /** true si edition de sommets */ transient private boolean isAtomicMode_; - + /** Le mod\xE8le des g\xE9om\xE9tries */ protected ZModeleGeometry modele_; - /** La selection a utilise dans le mode selection sommets */ protected EbliListeSelectionMulti selectionMulti_; + /** Le mod\xE8le pour le trac\xE9 de surfaces */ + protected TraceSurfaceModel surfModel_; /** @@ -126,6 +131,7 @@ public ZCalqueGeometry(final ZModeleGeometry _modele) { modele_ = _modele; iconModel_ = new TraceIconModel(TraceIcon.CARRE_PLEIN, 2, Color.BLACK); + surfModel_=new TraceSurfaceModel(TraceSurface.INVISIBLE, Color.BLACK,null); } protected EbliListeSelectionMulti creeSelectionMutli() { @@ -440,10 +446,46 @@ else tl= ligneModel_.buildCopy(); + final TraceSurface ts=surfModel_.buildCopy(); + final GrBoite bPoly = new GrBoite(); bPoly.o_ = new GrPoint(); bPoly.e_ = new GrPoint(); + // Les surfaces, si a tracer + if (!isRapide()) { + TIntArrayList x=new TIntArrayList(50); + TIntArrayList y=new TIntArrayList(50); + + for (int i = nombre - 1; i >= 0; i--) { + if (!modele_.isGeometryReliee(i) || !modele_.isGeometryFermee(i)) + continue; + + // il n'y a pas de points pour cette g\xE9om\xE9trie + final int nbPoints=modele_.getNbPointForGeometry(i); + if (nbPoints <= 0) + continue; + + modele_.getDomaineForGeometry(i, bPoly); + // Si la boite du polygone n'est pas dans la boite d'affichage on passe + if (bPoly.intersectionXY(clip) == null) { + continue; + } + + x.reset(); + y.reset(); + final GrPoint pt=new GrPoint(); + for (int j=0; j<nbPoints; j++) { + // le point de dest est initialise + modele_.point(pt, i, j); + pt.autoApplique(versEcran); + x.add((int)pt.x_); + y.add((int)pt.y_); + } + ts.remplitPolygone((Graphics2D)_g,x.toNativeArray(),y.toNativeArray()); + } + } + // on part de la fin : comme ca la premiere ligne apparait au-dessus for (int i = nombre - 1; i >= 0; i--) { if (!modele_.isGeometryReliee(i)) @@ -800,6 +842,20 @@ return false; } + public boolean setSurfaceModel(final TraceSurfaceModel _model) { + final TraceSurfaceModel surf = getSurfaceModel(); + if (_model != null && surf != null && surf.updateData(_model)) { +// firePropertyChange(BSelecteurLineModel.getProperty(_idx), null, surf); + repaint(); + return true; + } + return false; + } + + public TraceSurfaceModel getSurfaceModel() { + return surfModel_; + } + public boolean setTitle(final String _title) { final boolean r = super.setTitle(_title); if (r && modele_ != null && modele_.getGeomData() != null) { Modified: branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/trace/TraceSurface.java =================================================================== --- branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/trace/TraceSurface.java 2008-08-29 08:52:01 UTC (rev 3848) +++ branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/trace/TraceSurface.java 2008-08-29 08:53:27 UTC (rev 3849) @@ -40,40 +40,73 @@ private final static Rectangle TEXTURE_RECTANGLE = new Rectangle(0, 0, TEXTURE_PAINT_TAILLE, TEXTURE_PAINT_TAILLE); private static TextureIcone[] ICONES; private final static double C_MAGIC = Math.PI / 4d; - private int styleSurface_; - private Color couleurFond_; - private Color couleurPremierPlan_; - // donnees membres publiques +// private int styleSurface_; +// private Color couleurFond_; +// private Color couleurPremierPlan_; + + /** Type invisible */ public final static int INVISIBLE = 0; + /** Type uniforme (couleur background utilis\xE9) */ public final static int UNIFORME = 1; + /** Type hachure horizontal */ public final static int HACHURE_HORIZONTAL = 2; + /** Type hachure verticale */ public final static int HACHURE_VERTICAL = 3; + /** Type hachure haut gauche vers bas droit */ public final static int HACHURE_DROITE = 4; + /** Type hachure haut droit vers bas gauche */ public final static int HACHURE_GAUCHE = 5; + /** Type pointill\xE9 */ public final static int POINTILLE = 6; + + /** Noms des textures */ public final static List TEXTURE_NOM = new CtuluPermanentList(new String[] { EbliResource.EBLI.getString("invisible"), EbliResource.EBLI.getString("uniforme"), EbliResource.EBLI.getString("hachures horizontales"), EbliResource.EBLI.getString("hachures verticales"), EbliResource.EBLI.getString("hachures droites"), EbliResource.EBLI.getString("hachures gauches"), EbliResource.EBLI.getString("pointill\xE9s") }); + + /** Modele de surface */ + private TraceSurfaceModel model_; /** * Recupere le graphics 2D. Initialise le style de surface a uniforme, la couleur de fond est blanche et le premiere * plan est noire. */ public TraceSurface() { - styleSurface_ = UNIFORME; - couleurFond_ = Color.white; - couleurPremierPlan_ = Color.black; + model_ = new TraceSurfaceModel(); } /** + * @param _type le type de surface + * @param _fg la couleur de dessus + * @param _bg la couleur de fond + */ + public TraceSurface(final int _type, final Color _fg, final Color _bg) { + model_ = new TraceSurfaceModel(_type, _bg, _fg); + } + + /** + * @param _d les donn\xE9es d'initialisation + */ + public TraceSurface(final TraceSurfaceModel _d) { + model_ = _d; + } + + /** + * @param _d les donn\xE9es d'initialisation + */ + public TraceSurface(final TraceSurface _d) { + model_ = new TraceSurfaceModel(_d.model_); + } + + /** * Renvoie le texturePaint correspondant. * * @return TexturePaint */ private TexturePaint getTexturePaint() { - return getTexturePaint(styleSurface_, couleurPremierPlan_, couleurFond_); + return getTexturePaint(model_.typeSurface_, model_.fgColor_, model_.bgColor_); } private Polygon arc2polygon(final int _x1, final int _y1, final int _x2, final int _y2, final int _vx1, @@ -178,24 +211,16 @@ * @param _styleSurface TypeSurface */ public void setTypeSurface(final int _styleSurface) { - styleSurface_ = _styleSurface; + model_.typeSurface_ = _styleSurface; } /** - * @param _c Couleur - * @deprecated use getCouleurFond() - */ - public void setCouleur(final Color _c) { - setCouleurFond(_c); - } - - /** * Affectation de la propriete <I>couleur de fond</I> . * * @param _c CouleurFond */ public void setCouleurFond(final Color _c) { - couleurFond_ = _c; + model_.bgColor_ = _c; } /** @@ -204,7 +229,7 @@ * @param _c CouleurPremierPlan */ public void setCouleurPremierPlan(final Color _c) { - couleurPremierPlan_ = _c; + model_.fgColor_ = _c; } // Methodes publiques @@ -215,24 +240,16 @@ * @return TypeSurface */ public int getTypeSurface() { - return styleSurface_; + return model_.typeSurface_; } /** - * @return Couleur - * @deprecated use getCouleurFond() - */ - public Color getCouleur() { - return getCouleurFond(); - } - - /** * Accesseur de la propriete <I>couleur de fond</I> . Couleur des lignes tracees. * * @return CouleurFond */ public Color getCouleurFond() { - return couleurFond_; + return model_.bgColor_; } /** @@ -241,7 +258,7 @@ * @return CouleurPremierPlan */ public Color getCouleurPremierPlan() { - return couleurPremierPlan_; + return model_.fgColor_; } public void remplitEllipse(final Graphics2D _g, final double _x1, final double _y1, final double _x2, @@ -251,7 +268,7 @@ public void remplitEllipse(final Graphics2D _g2d, final int _x1, final int _y1, final int _x2, final int _y2, final int _x3, final int _y3, final int _x4, final int _y4) { - if (styleSurface_ == INVISIBLE) { + if (model_.typeSurface_ == INVISIBLE) { return; } int i; @@ -292,7 +309,7 @@ * Remplissage de polygone. */ public void remplitPolygone(final Graphics2D _g2d, final int[] _x, final int[] _y) { - if (styleSurface_ == INVISIBLE) { + if (model_.typeSurface_ == INVISIBLE) { return; } remplitPolygone(_g2d, new Polygon(_x, _y, _x.length)); @@ -305,13 +322,13 @@ * @see #setTypeSurface(int) */ public void remplitPolygone(final Graphics2D _g2d, final Polygon _pol) { - if (styleSurface_ == INVISIBLE) { + if (model_.typeSurface_ == INVISIBLE) { return; } final Paint oldPaint = _g2d.getPaint(); - _g2d.setColor(couleurFond_); - if (styleSurface_ == UNIFORME) { - _g2d.setColor(couleurFond_); + _g2d.setColor(model_.bgColor_); + if (model_.typeSurface_ == UNIFORME) { + _g2d.setColor(model_.bgColor_); } else { _g2d.setPaint(getTexturePaint()); } Added: branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/trace/TraceSurfaceModel.java =================================================================== --- branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/trace/TraceSurfaceModel.java (rev 0) +++ branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/trace/TraceSurfaceModel.java 2008-08-29 08:53:27 UTC (rev 3849) @@ -0,0 +1,172 @@ +/* + * @creation 26 janv. 2005 + * @modification $Date: 2007-05-22 14:19:05 $ + * @license GNU General Public License 2 + * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail de...@fu... + */ +package org.fudaa.ebli.trace; + +import java.awt.Color; + +/** + * Une classe permettant de stocker les donnees essentielles pour le trac\xE9 de surfaces. + * @author Bertrand Marchand + */ +public class TraceSurfaceModel { + + int typeSurface_; + Color bgColor_; + Color fgColor_; + + public TraceSurfaceModel() { + this(null); + } + + public TraceSurfaceModel(final int _typeSurface, final Color _bgColor, final Color _fgColor) { + typeSurface_ = _typeSurface; + bgColor_ = _bgColor; + fgColor_ = _fgColor; + } + + public TraceSurfaceModel(final TraceSurfaceModel _m) { + if (_m == null) { + setDefault(); + } else { + typeSurface_ = _m.typeSurface_; + bgColor_ = _m.bgColor_; + fgColor_ = _m.fgColor_; + } + } + + public TraceSurface buildCopy() { + return new TraceSurface(new TraceSurfaceModel(this)); + } + + private void setDefault() { + typeSurface_ = TraceSurface.UNIFORME; + bgColor_ = Color.white; + fgColor_ = Color.black; + } + + public boolean equals(final Object _obj) { + if (_obj == this) { + return true; + } + if (_obj == null) { + return false; + } + if (_obj.getClass().equals(getClass())) { + final TraceSurfaceModel d = (TraceSurfaceModel) _obj; + return d.typeSurface_ == typeSurface_ && + (d.bgColor_ == bgColor_ || (d.bgColor_!=null && d.bgColor_.equals(bgColor_)) && + (d.fgColor_ == fgColor_ || (d.fgColor_!=null && d.fgColor_.equals(fgColor_)))); + } + return false; + } + + public final Color getFgColor() { + return fgColor_; + } + + public final Color getBgColor() { + return bgColor_; + } + + public final int getType() { + return typeSurface_; + } + + public int hashCode() { + return 13 * typeSurface_+(fgColor_ == null ? 0 : fgColor_.hashCode())+(bgColor_ == null ? 0 : bgColor_.hashCode()); + } + + public boolean isBgColorIgnored() { + return bgColor_==null; + } + + public boolean isFgColorIgnored() { + return fgColor_==null; + } + + public boolean isTypeIgnored() { + return typeSurface_ < 0; + } + + /** + * @param _d + * @return false si toutes les donn\xE9es ne sont diff\xE9rentes + */ + public boolean keepCommonValues(final TraceSurfaceModel _d) { + if (typeSurface_ != _d.typeSurface_) { + typeSurface_ = -1; + } + if (fgColor_ != null && !fgColor_.equals(_d.fgColor_)) { + fgColor_ = null; + } + if (bgColor_ != null && !bgColor_.equals(_d.bgColor_)) { + bgColor_ = null; + } + + return typeSurface_ >= 0 || fgColor_ !=null && bgColor_ != null; + } + + public boolean setBgColor(final Color _c) { + if (_c != bgColor_) { + bgColor_ = _c; + return true; + } + return false; + } + + public void setBgColorIgnored() { + bgColor_ = null; + } + + public boolean setFgColor(final Color _c) { + if (_c != fgColor_) { + fgColor_ = _c; + return true; + } + return false; + } + + public void setFgColorIgnored() { + fgColor_ = null; + } + + public void setTypeIgnored() { + typeSurface_ = -1; + } + + public boolean setType(final int _type) { + if (_type != typeSurface_) { + typeSurface_ = _type; + return true; + } + return false; + } + + public String toString() { + return "trace surface type=" + typeSurface_ + ", foreground color " + fgColor_.toString() + + ", background color=" + bgColor_.toString(); + } + + public boolean updateData(final TraceSurfaceModel _model) { + boolean r = false; + if (!_model.isFgColorIgnored() && (!_model.getFgColor().equals(getFgColor()))) { + setFgColor(_model.getFgColor()); + r = true; + } + if (!_model.isBgColorIgnored() && (!_model.getBgColor().equals(getBgColor()))) { + setBgColor(_model.getBgColor()); + r = true; + } + if (!_model.isTypeIgnored() && _model.getType()!=getType()) { + setType(_model.getType()); + r = true; + } + return r; + } + +} \ No newline at end of file Property changes on: branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/trace/TraceSurfaceModel.java ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |