001: /*
002: * This file is part of the GeOxygene project source files.
003: *
004: * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for
005: * the development and deployment of geographic (GIS) applications. It is a open source
006: * contribution of the COGIT laboratory at the Institut Géographique National (the French
007: * National Mapping Agency).
008: *
009: * See: http://oxygene-project.sourceforge.net
010: *
011: * Copyright (C) 2005 Institut Géographique National
012: *
013: * This library is free software; you can redistribute it and/or modify it under the terms
014: * of the GNU Lesser General Public License as published by the Free Software Foundation;
015: * either version 2.1 of the License, or any later version.
016: *
017: * This library is distributed in the hope that it will be useful, but WITHOUT ANY
018: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
019: * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
020: *
021: * You should have received a copy of the GNU Lesser General Public License along with
022: * this library (see file LICENSE if present); if not, write to the Free Software
023: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024: *
025: */
026:
027: package fr.ign.cogit.geoxygene.spatial.coordgeom;
028:
029: import java.util.List;
030:
031: //import operateur.OpDirectPosition;
032:
033: /**
034: * Polyligne.
035: * L'attribut "interpolation" est égal à "linear".
036: *
037: * @author Thierry Badard & Arnaud Braun
038: * @version 1.1
039: *
040: * 19.02.2007 : correction de bug constructeur à partir d'une liste de DirectPosition
041: *
042: */
043:
044: public class GM_LineString extends GM_CurveSegment {
045:
046: //////////////////////////////////////////////////////////////////////////
047: // Attribut "controlPoint" et méthodes pour le traiter ///////////////////
048: //////////////////////////////////////////////////////////////////////////
049: /** Points pour le dessin de la polyligne : séquence de DirectPosition.
050: Le premier point est le startPoint de la polyligne. */
051: protected DirectPositionList controlPoint;
052:
053: /** Renvoie la liste conbtrolPoint. Equivalent de samplePoint() et de coord(). A laisser ?*/
054: public DirectPositionList getControlPoint() {
055: return controlPoint;
056: }
057:
058: /** Renvoie le DirectPosition de rang i. */
059: public DirectPosition getControlPoint(int i) {
060: return (DirectPosition) this .controlPoint.get(i);
061: }
062:
063: /** Affecte un DirectPosition au i-ème rang de la liste. */
064: public void setControlPoint(int i, DirectPosition value) {
065: this .controlPoint.set(i, value);
066: }
067:
068: /** Ajoute un DirectPosition en fin de liste */
069: public void addControlPoint(DirectPosition value) {
070: this .controlPoint.add(value);
071: }
072:
073: /** Ajoute un DirectPosition au i-ème rang de la liste. */
074: public void addControlPoint(int i, DirectPosition value) {
075: this .controlPoint.add(i, value);
076: }
077:
078: /** Efface de la liste le DirectPosition passé en paramètre. */
079: public void removeControlPoint(DirectPosition value) {
080: this .controlPoint.remove(value);
081: }
082:
083: /** Efface le i-ème DirectPosition de la liste. */
084: public void removeControlPoint(int i) {
085: this .controlPoint.remove(i);
086: }
087:
088: /** Renvoie le nombre de DirectPosition. */
089: public int sizeControlPoint() {
090: return this .controlPoint.size();
091: }
092:
093: //////////////////////////////////////////////////////////////////////////
094: // Constructeurs /////////////////////////////////////////////////////////
095: //////////////////////////////////////////////////////////////////////////
096: /** Constructeur par défaut.*/
097: public GM_LineString() {
098: super ();
099: this .segment.add(this );
100: controlPoint = new DirectPositionList();
101: interpolation = "linear";
102: }
103:
104: /** Constructeur à partir d'une liste de DirectPosition.*/
105: public GM_LineString(DirectPositionList points) {
106: super ();
107: this .segment.add(this );
108: controlPoint = new DirectPositionList();
109: controlPoint.addAll(points);
110: interpolation = "linear";
111: }
112:
113: //////////////////////////////////////////////////////////////////////////
114: // Méthode de la norme ///////////////////////////////////////////////////
115: //////////////////////////////////////////////////////////////////////////
116: /** A FAIRE. Renvoie null.
117: * Décompose une polyligne en une séquence de segments.
118: */
119: public List asGM_LineSegment() {
120: return null;
121: }
122:
123: //////////////////////////////////////////////////////////////////////////
124: // Implémentation de méthodes abstraites /////////////////////////////////
125: //////////////////////////////////////////////////////////////////////////
126: /** Renvoie la liste ordonnée des points de contrôle (idem que coord()). */
127: public DirectPositionList coord() {
128: return (this .controlPoint);
129: }
130:
131: /** Renvoie un GM_CurveSegment de sens opposé. */
132: public GM_CurveSegment reverse() {
133: GM_LineString result = new GM_LineString();
134: int n = controlPoint.size();
135: for (int i = 0; i < n; i++)
136: result.getControlPoint().add(
137: (DirectPosition) controlPoint.get(n - 1 - i));
138: return result;
139: }
140:
141: }
|