From: <emm...@us...> - 2008-11-03 12:28:34
|
Revision: 4152 http://fudaa.svn.sourceforge.net/fudaa/?rev=4152&view=rev Author: emmanuel_martin Date: 2008-11-03 12:28:29 +0000 (Mon, 03 Nov 2008) Log Message: ----------- tache #72 : "Duplication de points ayant les m?\195?\170me coordonn?\195?\169es lors d'interpolation entre 2 entit?\195?\169s diff?\195?\169rentes" Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlInterpolationPanel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlSceneEditor.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dMultiPoint.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlInterpolationPanel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlInterpolationPanel.java 2008-11-03 11:20:21 UTC (rev 4151) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlInterpolationPanel.java 2008-11-03 12:28:29 UTC (rev 4152) @@ -11,10 +11,14 @@ import java.awt.event.ActionListener; import javax.swing.ButtonGroup; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import org.fudaa.ctulu.CtuluLib; import org.fudaa.ctulu.gui.CtuluDialogPanel; +import org.fudaa.ebli.commun.EbliLib; +import com.memoire.bu.BuCheckBox; import com.memoire.bu.BuGridLayout; import com.memoire.bu.BuRadioButton; import com.memoire.bu.BuTextField; @@ -24,7 +28,7 @@ * @author Bertrand Marchand * @version $Id: MdlInterpolationPanel.java,v 1.1.2.1 2008-05-13 12:10:11 bmarchan Exp $ */ -public class MdlInterpolationPanel extends CtuluDialogPanel { +public class MdlInterpolationPanel extends CtuluDialogPanel implements ChangeListener { private class InterpolationActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { @@ -37,6 +41,7 @@ private BuTextField tfDist_; private BuRadioButton rbNbPts_; private BuRadioButton rbDist_; + private boolean useBorderPoints_; private int nbPts_=0; private double dist_=0; @@ -64,6 +69,12 @@ tfDist_=addDoubleText("1.0"); rbNbPts_.doClick(); + + // La checkBox indiquant l'utilisation ou non des points d'extr\xE9mit\xE9s + useBorderPoints_=false; + BuCheckBox cb=new BuCheckBox(EbliLib.getS("Duplication des points aux extr\xE9mit\xE9s.")); + cb.addChangeListener(this); + add(cb); } public boolean valide() { @@ -89,4 +100,15 @@ public boolean isNbPtsGiven() { return rbNbPts_.isSelected(); } + + public boolean useBorderPoints(){ + return useBorderPoints_; + } + + /* (non-Javadoc) + * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent) + */ + public void stateChanged(ChangeEvent e) { + useBorderPoints_=!useBorderPoints_; + } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlSceneEditor.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlSceneEditor.java 2008-11-03 11:20:21 UTC (rev 4151) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlSceneEditor.java 2008-11-03 12:28:29 UTC (rev 4152) @@ -115,11 +115,13 @@ ZModeleDonnees mdld=((ZCalqueAffichageDonneesInterface)getScene().getCalqueActif()).modeleDonnees(); if (mdld instanceof MdlModel2dMultiPoint) { MdlModel2dMultiPoint mdl=(MdlModel2dMultiPoint)mdld; - mdl.interpolate(coords, dist, getMng()); + if(!mdl.interpolate(coords, dist, pnInterpolation_.useBorderPoints(), getMng())) + ui_.warn(FudaaLib.getS("Interpolation"), FudaaLib.getS("L'interpolation n'a pas pu avoir lieu par manque de point."), false); } else if (mdld instanceof MdlModel2dLine) { MdlModel2dLine mdl=(MdlModel2dLine)mdld; - mdl.interpolate(coords, dist, getMng()); + if(!mdl.interpolate(coords, dist, pnInterpolation_.useBorderPoints(), getMng())) + ui_.warn(FudaaLib.getS("Interpolation"), FudaaLib.getS("L'interpolation n'a pas pu avoir lieu par manque de point."), false); } } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java 2008-11-03 11:20:21 UTC (rev 4151) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java 2008-11-03 12:28:29 UTC (rev 4152) @@ -46,30 +46,44 @@ * Interpole entre 2 points, suivant un nombre de points donn\xE9s. * @param _coords Les 2 coordonn\xE9es * @param _dist La distance entre 2 points cons\xE9cutifs. + * @param _useBorderPoints vrai si la ligne int\xE9pol\xE9e doit contenir les coordonn\xE9es fournies. * @param _cmd Le container de commandes. * @return true si modif ok. */ - public boolean interpolate(Coordinate[] _coords, double _dist, final CtuluCommandContainer _cmd){ + public boolean interpolate(Coordinate[] _coords, double _dist, boolean _useBorderPoints, final CtuluCommandContainer _cmd){ double distTot= Math.sqrt((_coords[1].x-_coords[0].x)*(_coords[1].x-_coords[0].x)+(_coords[1].y-_coords[0].y)*(_coords[1].y-_coords[0].y)); int nbpts=(int)Math.round(distTot/_dist)-1; - - Coordinate[] coords=new Coordinate[_coords.length+nbpts]; - for (int i=1; i<coords.length-1; i++) { - Coordinate c=new Coordinate(); - c.x=_coords[0].x+(_coords[1].x-_coords[0].x)*i*_dist/distTot; - c.y=_coords[0].y+(_coords[1].y-_coords[0].y)*i*_dist/distTot; - c.z=_coords[0].z+(_coords[1].z-_coords[0].z)*i*_dist/distTot; - coords[i]=c; + Coordinate[] coords; + if (_useBorderPoints) { + coords=new Coordinate[_coords.length+nbpts]; + for (int i=1; i<coords.length-1; i++) + coords[i]=new Coordinate( + _coords[0].x+(_coords[1].x-_coords[0].x)*i*_dist/distTot, + _coords[0].y+(_coords[1].y-_coords[0].y)*i*_dist/distTot, + _coords[0].z+(_coords[1].z-_coords[0].z)*i*_dist/distTot + ); + coords[0]=(Coordinate)_coords[0].clone(); + coords[coords.length-1]=(Coordinate)_coords[1].clone(); } - coords[0]=(Coordinate)_coords[0].clone(); - coords[coords.length-1]=(Coordinate)_coords[1].clone(); - - GISPolyligne poly = (GISPolyligne)GISGeometryFactory.INSTANCE.createLineString(coords); - int idx = getGeomData().addGeometry(poly, null, _cmd); - if(idx!=-1) - setGeomModif(idx, _cmd); - return true; + else { + coords=new Coordinate[nbpts]; + for (int i=0; i<coords.length; i++) + coords[i]=new Coordinate( + _coords[0].x+(_coords[1].x-_coords[0].x)*(i+1)*_dist/distTot, + _coords[0].y+(_coords[1].y-_coords[0].y)*(i+1)*_dist/distTot, + _coords[0].z+(_coords[1].z-_coords[0].z)*(i+1)*_dist/distTot + ); + } + if (coords.length>=2) { + GISPolyligne poly=(GISPolyligne)GISGeometryFactory.INSTANCE.createLineString(coords); + int idx=getGeomData().addGeometry(poly, null, _cmd); + if (idx!=-1) + setGeomModif(idx, _cmd); + return true; + } + else + return false; } /** Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dMultiPoint.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dMultiPoint.java 2008-11-03 11:20:21 UTC (rev 4151) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dMultiPoint.java 2008-11-03 12:28:29 UTC (rev 4152) @@ -37,29 +37,43 @@ * Interpole entre 2 points, suivant un nombre de points donn\xE9s. * @param _coords Les 2 coordonn\xE9es * @param _dist La distance entre 2 points cons\xE9cutifs. + * @param _useBorderPoints vrai si la ligne int\xE9pol\xE9e doit contenir les coordonn\xE9es fournies. * @return true si modif ok. */ - public boolean interpolate(Coordinate[] _coords, double _dist, final CtuluCommandContainer _cmd){ + public boolean interpolate(Coordinate[] _coords, double _dist, boolean _useBorderPoints, final CtuluCommandContainer _cmd){ double distTot= Math.sqrt((_coords[1].x-_coords[0].x)*(_coords[1].x-_coords[0].x)+(_coords[1].y-_coords[0].y)*(_coords[1].y-_coords[0].y)); int nbpts=(int)Math.round(distTot/_dist)-1; - - Coordinate[] coords=new Coordinate[_coords.length+nbpts]; - for (int i=1; i<coords.length-1; i++) { - Coordinate c=new Coordinate(); - c.x=_coords[0].x+(_coords[1].x-_coords[0].x)*i*_dist/distTot; - c.y=_coords[0].y+(_coords[1].y-_coords[0].y)*i*_dist/distTot; - c.z=_coords[0].z+(_coords[1].z-_coords[0].z)*i*_dist/distTot; - coords[i]=c; + Coordinate[] coords; + if (_useBorderPoints) { + coords=new Coordinate[_coords.length+nbpts]; + for (int i=1; i<coords.length-1; i++) + coords[i]=new Coordinate( + _coords[0].x+(_coords[1].x-_coords[0].x)*i*_dist/distTot, + _coords[0].y+(_coords[1].y-_coords[0].y)*i*_dist/distTot, + _coords[0].z+(_coords[1].z-_coords[0].z)*i*_dist/distTot + ); + coords[0]=(Coordinate)_coords[0].clone(); + coords[coords.length-1]=(Coordinate)_coords[1].clone(); } - coords[0]=(Coordinate)_coords[0].clone(); - coords[coords.length-1]=(Coordinate)_coords[1].clone(); - - GISMultiPoint poly = (GISMultiPoint) GISGeometryFactory.INSTANCE.createMultiPoint(coords); - int idx = geometries_.addGeometry(poly, null, _cmd); - // Modification de l'etat de la g\xE9ometrie en modifi\xE9e - if(idx != -1) - setGeomModif(idx, _cmd); - return true; + else { + coords=new Coordinate[nbpts]; + for (int i=0; i<coords.length; i++) + coords[i]=new Coordinate( + _coords[0].x+(_coords[1].x-_coords[0].x)*(i+1)*_dist/distTot, + _coords[0].y+(_coords[1].y-_coords[0].y)*(i+1)*_dist/distTot, + _coords[0].z+(_coords[1].z-_coords[0].z)*(i+1)*_dist/distTot + ); + } + if (coords.length>=2) { + GISMultiPoint poly=(GISMultiPoint)GISGeometryFactory.INSTANCE.createMultiPoint(coords); + int idx=geometries_.addGeometry(poly, null, _cmd); + // Modification de l'etat de la g\xE9ometrie en modifi\xE9e + if (idx!=-1) + setGeomModif(idx, _cmd); + return true; + } + else + return false; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |