root / trunk / extensions / extTopology / src / com / iver / cit / gvsig / referencing / MappedPositionContainerImpl.java @ 23163
History | View | Annotate | Download (4.47 KB)
1 |
/*
|
---|---|
2 |
* Created on 10-abr-2006
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
/* CVS MESSAGES:
|
45 |
*
|
46 |
* $Id:
|
47 |
* $Log:
|
48 |
*/
|
49 |
package com.iver.cit.gvsig.referencing; |
50 |
|
51 |
import java.awt.Color; |
52 |
import java.sql.Types; |
53 |
import java.util.ArrayList; |
54 |
import java.util.List; |
55 |
|
56 |
import org.cresques.cts.IProjection; |
57 |
import org.geotools.referencefork.referencing.operation.builder.MappedPosition; |
58 |
import org.gvsig.referencing.MappedPositionContainer; |
59 |
import org.gvsig.referencing.ReferencingUtil; |
60 |
|
61 |
import com.iver.andami.PluginServices; |
62 |
import com.iver.cit.gvsig.drivers.VectorErrorMemoryDriver; |
63 |
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
64 |
import com.iver.cit.gvsig.fmap.core.ArrowLineSymbol; |
65 |
import com.iver.cit.gvsig.fmap.core.FShape; |
66 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
67 |
import com.iver.cit.gvsig.fmap.layers.FLayerGenericVectorial; |
68 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
69 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
70 |
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend; |
71 |
/**
|
72 |
* MappedPositionContainer implementation for the spatial adjust tool
|
73 |
* @author Alvaro Zabala
|
74 |
*
|
75 |
*/
|
76 |
public class MappedPositionContainerImpl implements MappedPositionContainer { |
77 |
|
78 |
|
79 |
|
80 |
/**
|
81 |
* Digitized vector errors
|
82 |
*/
|
83 |
private List<MappedPosition> mappedPositions; |
84 |
|
85 |
/**
|
86 |
* FLyrVect representation of the error vectors digitized by user
|
87 |
*/
|
88 |
private FLyrVect linksLyr;
|
89 |
|
90 |
|
91 |
public MappedPositionContainerImpl(){
|
92 |
this.mappedPositions = new ArrayList<MappedPosition>(); |
93 |
} |
94 |
|
95 |
|
96 |
public void addMappedPosition(MappedPosition mappedPosition) { |
97 |
mappedPositions.add(mappedPosition); |
98 |
} |
99 |
|
100 |
|
101 |
public int getCount() { |
102 |
return mappedPositions.size();
|
103 |
} |
104 |
|
105 |
|
106 |
public MappedPosition getMappedPosition(int idx) { |
107 |
return mappedPositions.get(idx);
|
108 |
} |
109 |
|
110 |
|
111 |
public List<MappedPosition> getAsList() { |
112 |
return mappedPositions;
|
113 |
} |
114 |
|
115 |
//FIXME CUANDO A?ADO ESTA CAPA AL TOC, NO SE MUESTRA EL SIMBOLO
|
116 |
//HAY QUE A?ADIR ALGUNA EXTENSION AL TOC??
|
117 |
public FLyrVect getLinkLyr(IProjection projection){
|
118 |
if(linksLyr == null){ |
119 |
ReferencingUtil ref = ReferencingUtil.getInstance(); |
120 |
int numberOfSessions = ref.getNumberOfSpatialAdjustSessions();
|
121 |
linksLyr = new FLayerGenericVectorial();
|
122 |
String name = PluginServices.getText(this, "LINKS_SPATIAL_ADJUST") + |
123 |
"_" +
|
124 |
numberOfSessions; |
125 |
ref.incrementAdjustSessions(); |
126 |
linksLyr.setName(name); |
127 |
linksLyr.setProjection(projection); |
128 |
((FLayerGenericVectorial)linksLyr).setDriver(new VectorErrorMemoryDriver(name, this)); |
129 |
try {
|
130 |
linksLyr.load(); |
131 |
|
132 |
VectorialUniqueValueLegend defaultLegend = |
133 |
LegendFactory.createVectorialUniqueValueLegend(FShape.LINE); |
134 |
|
135 |
defaultLegend.setClassifyingFieldNames(new String[] {"fid"}); |
136 |
defaultLegend.setClassifyingFieldTypes(new int[]{Types.NUMERIC}); |
137 |
|
138 |
|
139 |
|
140 |
ILineSymbol defaultSymbol = new ArrowLineSymbol();
|
141 |
defaultSymbol.setLineColor(Color.RED);
|
142 |
defaultLegend.setDefaultSymbol(defaultSymbol); |
143 |
linksLyr.setLegend(defaultLegend); |
144 |
|
145 |
} catch (LoadLayerException e) {
|
146 |
e.printStackTrace(); |
147 |
} |
148 |
} |
149 |
|
150 |
return linksLyr;
|
151 |
} |
152 |
|
153 |
|
154 |
public boolean existsLinksLyr() { |
155 |
return linksLyr != null; |
156 |
} |
157 |
|
158 |
|
159 |
public void delete(int linkIdx) { |
160 |
this.mappedPositions.remove(linkIdx);
|
161 |
} |
162 |
} |