From: <bma...@us...> - 2008-08-12 09:58:09
|
Revision: 3773 http://fudaa.svn.sourceforge.net/fudaa/?rev=3773&view=rev Author: bmarchan Date: 2008-08-12 09:58:15 +0000 (Tue, 12 Aug 2008) Log Message: ----------- G?\195?\169n?\195?\169ralisation du visitor de calque CalqueFindPolyligneVisitor. Modified Paths: -------------- branches/Br_FudaaModeleur_TF/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/find/CalqueFindCourbeTreeModel.java Added Paths: ----------- branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/CalqueGeometryVisitor.java Removed Paths: ------------- branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/find/CalqueFindPolyligneVisitor.java Modified: branches/Br_FudaaModeleur_TF/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java =================================================================== --- branches/Br_FudaaModeleur_TF/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java 2008-08-12 07:45:50 UTC (rev 3772) +++ branches/Br_FudaaModeleur_TF/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java 2008-08-12 09:58:15 UTC (rev 3773) @@ -33,6 +33,19 @@ */ public final class GISLib { + /** Un masque pour aucune g\xE9ometrie */ + public static final int MASK_NONE = 0; + /** Un masque pour des polygones */ + public static final int MASK_POLYGONE = 1<<0; + /** Un masque pour des polylignes */ + public static final int MASK_POLYLINE = 1<<1; + /** Un masque pour des multipoints */ + public static final int MASK_MULTIPOINT = 1<<2; + /** Un masque pour des points */ + public static final int MASK_POINT = 1<<3; + /** Un masque pour toute geometrie */ + public static final int MASK_ALL = MASK_POLYGONE|MASK_POLYLINE|MASK_MULTIPOINT|MASK_POINT; + public static double getDistance(final Envelope _e, final double _x, final double _y) { if (_e == null || _e.isNull()) { return Double.MAX_VALUE; Copied: branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/CalqueGeometryVisitor.java (from rev 3739, branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/find/CalqueFindPolyligneVisitor.java) =================================================================== --- branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/CalqueGeometryVisitor.java (rev 0) +++ branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/CalqueGeometryVisitor.java 2008-08-12 09:58:15 UTC (rev 3773) @@ -0,0 +1,88 @@ +/* + * @creation 21 nov. 06 + * @modification $Date: 2006-12-05 10:14:38 $ + * @license GNU General Public License 2 + * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail de...@fu... + */ +package org.fudaa.ebli.calque; + +import org.fudaa.ctulu.gis.GISLib; + +/** + * Un visiteur qui permet de determiner si un calque contient des g\xE9ometries + * d'un type donn\xE9e. + * @author Bertrand Marchand + * @version $Id: CalqueFindPolyligneVisitor.java,v 1.1 2006-12-05 10:14:38 deniger Exp $ + */ +public class CalqueGeometryVisitor implements BCalqueVisitor { + int mask_=GISLib.MASK_ALL; + + boolean found_; + + public CalqueGeometryVisitor() { + super(); + } + + public CalqueGeometryVisitor(final int _mask) { + super(); + mask_=_mask; + } + + public boolean visit(final BCalque _cq) { + // on arrete la visite + if (found_) { + return false; + } + if (_cq == null || _cq.isGroupeCalque()) { + return true; + } + + found_ = isMatching(_cq); + if (found_) { + return false; + } + return true; + } + + /** + * Controle que le calque contient des objets du type donn\xE9.<p> + * Attention : Un polygone n'est pas consid\xE9r\xE9 comme une polyligne sp\xE9cialis\xE9e. + * @param _cq Le calque a tester. + * @return True si trouv\xE9. + */ + public boolean isMatching(final BCalque _cq) { + if (_cq instanceof ZCalquePoint && (mask_&GISLib.MASK_POINT)!=0) { + return ((ZCalquePoint) _cq).modeleDonnees().getNombre() > 0; + } + else if (_cq instanceof ZCalqueMultiPoint && (mask_&GISLib.MASK_MULTIPOINT)!=0) { + return ((ZCalqueMultiPoint) _cq).modeleDonnees().getNombre() > 0; + } + else if (_cq instanceof ZCalqueLigneBrisee && (mask_&GISLib.MASK_POLYLINE)!=0) { + boolean bok=((ZCalqueLigneBrisee) _cq).modeleDonnees().getNombre() > 0; + return bok && (!((ZCalqueLigneBrisee) _cq).containsPolygone()); + } + else if (_cq instanceof ZCalqueLigneBrisee && (mask_&GISLib.MASK_POLYGONE)!=0) { + boolean bok=((ZCalqueLigneBrisee) _cq).modeleDonnees().getNombre() > 0; + return bok && ((ZCalqueLigneBrisee) _cq).containsPolygone(); + } + return false; + } + + public void setMask(int _mask) { + mask_=_mask; + } + + public int getMask() { + return mask_; + } + + public boolean isFound() { + return found_; + } + + public void resetFound() { + found_ = false; + } + +} Property changes on: branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/CalqueGeometryVisitor.java ___________________________________________________________________ Added: svn:mergeinfo + Modified: branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/find/CalqueFindCourbeTreeModel.java =================================================================== --- branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/find/CalqueFindCourbeTreeModel.java 2008-08-12 07:45:50 UTC (rev 3772) +++ branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/find/CalqueFindCourbeTreeModel.java 2008-08-12 09:58:15 UTC (rev 3773) @@ -35,6 +35,7 @@ import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ctulu.gis.GISAttributeModelObjectInterface; import org.fudaa.ctulu.gis.GISGeometry; +import org.fudaa.ctulu.gis.GISLib; import org.fudaa.ctulu.gis.GISVisitorChooser; import org.fudaa.ctulu.gis.GISVisitorLigneCollector; import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; @@ -44,6 +45,7 @@ import org.fudaa.ebli.calque.BArbreCalqueModel; import org.fudaa.ebli.calque.BCalque; import org.fudaa.ebli.calque.BGroupeCalque; +import org.fudaa.ebli.calque.CalqueGeometryVisitor; import org.fudaa.ebli.calque.ZCalqueLigneBrisee; import org.fudaa.ebli.commun.EbliLib; import org.fudaa.ebli.ressource.EbliResource; @@ -61,7 +63,7 @@ final BGroupeCalque rootLayer_; LayerNode rootNode_; boolean onlyLigneFerme_; - final CalqueFindPolyligneVisitor finder_ = new CalqueFindPolyligneVisitor(false); + final CalqueGeometryVisitor finder_ = new CalqueGeometryVisitor(GISLib.MASK_POLYLINE|GISLib.MASK_POLYGONE); public static class CellRenderer extends JLabel implements TreeCellRenderer { final Color selectedBackground_ = UIManager.getColor("Tree.selectionBackground"); @@ -300,7 +302,9 @@ public void setOnlyLigneFerme(final boolean _onlyLigneFerme) { onlyLigneFerme_ = _onlyLigneFerme; - finder_.setOnlyPolygone(onlyLigneFerme_); + int mask=GISLib.MASK_POLYGONE; + if (!_onlyLigneFerme) mask|=GISLib.MASK_POLYLINE; + finder_.setMask(mask); buildTree(); } Deleted: branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/find/CalqueFindPolyligneVisitor.java =================================================================== --- branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/find/CalqueFindPolyligneVisitor.java 2008-08-12 07:45:50 UTC (rev 3772) +++ branches/Br_FudaaModeleur_TF/fudaa_devel/ebli/src/org/fudaa/ebli/calque/find/CalqueFindPolyligneVisitor.java 2008-08-12 09:58:15 UTC (rev 3773) @@ -1,77 +0,0 @@ -/* - * @creation 21 nov. 06 - * @modification $Date: 2006-12-05 10:14:38 $ - * @license GNU General Public License 2 - * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne - * @mail de...@fu... - */ -package org.fudaa.ebli.calque.find; - -import org.fudaa.ebli.calque.BCalque; -import org.fudaa.ebli.calque.BCalqueVisitor; -import org.fudaa.ebli.calque.ZCalqueLigneBrisee; - -/** - * @author fred deniger - * @version $Id: CalqueFindPolyligneVisitor.java,v 1.1 2006-12-05 10:14:38 deniger Exp $ - */ -public class CalqueFindPolyligneVisitor implements BCalqueVisitor { - - boolean onlyPolygone_; - - boolean found_; - - public CalqueFindPolyligneVisitor() { - super(); - } - - public CalqueFindPolyligneVisitor(final boolean _onlyPolygone) { - super(); - onlyPolygone_ = _onlyPolygone; - } - - public boolean visit(final BCalque _cq) { - // on arrete la visite - if (found_) { - return false; - } - if (_cq == null || _cq.isGroupeCalque()) { - return true; - } - - found_ = isMatching(_cq); - if (found_) { - return false; - } - return true; - } - - public boolean isMatching(final BCalque _cq) { - boolean ok = _cq instanceof ZCalqueLigneBrisee; - if (ok) { - ok = ((ZCalqueLigneBrisee) _cq).modeleDonnees().getNombre() > 0; - } - if (ok && onlyPolygone_) { - ok = ((ZCalqueLigneBrisee) _cq).containsPolygone(); - } - return ok; - - } - - public boolean isOnlyPolygone() { - return onlyPolygone_; - } - - public void setOnlyPolygone(final boolean _onlyPolygone) { - onlyPolygone_ = _onlyPolygone; - } - - public boolean isFound() { - return found_; - } - - public void resetFound() { - found_ = false; - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |