svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / rendering / legend / styling / DefaultLabelingMethod.java @ 23750
History | View | Annotate | Download (4.2 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
|
42 |
/* CVS MESSAGES:
|
43 |
*
|
44 |
* $Id: DefaultLabelingMethod.java 10815 2007-03-20 16:16:20Z jaume $
|
45 |
* $Log$
|
46 |
* Revision 1.1 2007-03-20 16:16:20 jaume
|
47 |
* refactored to use ISymbol instead of FSymbol
|
48 |
*
|
49 |
* Revision 1.2 2007/03/09 08:33:43 jaume
|
50 |
* *** empty log message ***
|
51 |
*
|
52 |
* Revision 1.1.2.2 2007/02/01 11:42:47 jaume
|
53 |
* *** empty log message ***
|
54 |
*
|
55 |
* Revision 1.1.2.1 2007/01/30 18:10:45 jaume
|
56 |
* start commiting labeling stuff
|
57 |
*
|
58 |
*
|
59 |
*/
|
60 |
package org.gvsig.fmap.mapcontext.rendering.legend.styling; |
61 |
|
62 |
import org.gvsig.fmap.data.exceptions.ReadException; |
63 |
import org.gvsig.fmap.data.feature.FeatureCollection; |
64 |
import org.gvsig.fmap.mapcontext.ViewPort; |
65 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
66 |
|
67 |
import com.iver.utiles.XMLEntity; |
68 |
import com.iver.utiles.XMLException; |
69 |
|
70 |
public class DefaultLabelingMethod implements ILabelingMethod { |
71 |
|
72 |
|
73 |
private LabelClass defaultLabel;
|
74 |
|
75 |
public DefaultLabelingMethod() {}
|
76 |
|
77 |
public DefaultLabelingMethod(LabelClass defaultLabel) {
|
78 |
this();
|
79 |
this.defaultLabel = defaultLabel;
|
80 |
} |
81 |
|
82 |
|
83 |
public void addLabelClass(LabelClass lbl) { |
84 |
defaultLabel = lbl; |
85 |
} |
86 |
|
87 |
|
88 |
public void deleteLabelClass(LabelClass lbl) { |
89 |
// does nothing
|
90 |
} |
91 |
|
92 |
public String getClassName() { |
93 |
return getClass().getName();
|
94 |
} |
95 |
|
96 |
public XMLEntity getXMLEntity() throws XMLException { |
97 |
XMLEntity xml = new XMLEntity();
|
98 |
xml.putProperty("className", getClassName());
|
99 |
|
100 |
if (defaultLabel !=null) { |
101 |
XMLEntity defaultLabelClassXML = defaultLabel.getXMLEntity(); |
102 |
defaultLabelClassXML.putProperty("id", "defaultLabelClass"); |
103 |
xml.addChild(defaultLabelClassXML); |
104 |
} |
105 |
return xml;
|
106 |
} |
107 |
|
108 |
public void setXMLEntity(XMLEntity xml) { |
109 |
if (xml.findChildren("id", "defaultClass") !=null) |
110 |
defaultLabel = LabelingFactory. |
111 |
createLabelClassFromXML(xml.firstChild("id", "defaultLabelClass")); |
112 |
} |
113 |
|
114 |
|
115 |
public boolean allowsMultipleClass() { |
116 |
return false; |
117 |
} |
118 |
|
119 |
public void renameLabelClass(LabelClass lbl, String newName) { |
120 |
// does nothing
|
121 |
} |
122 |
|
123 |
|
124 |
public FeatureCollection getFeatureIteratorByLabelClass(FLyrVect layer, LabelClass lc, ViewPort viewPort, String[] usedFields) |
125 |
throws ReadException {
|
126 |
return (FeatureCollection)layer.getFeatureStore().getDataCollection(usedFields,null,null); |
127 |
// layer.getSource().getFeatureIterator(
|
128 |
// viewPort.getAdjustedExtent(), usedFields,
|
129 |
// layer.getProjection(), true);
|
130 |
} |
131 |
|
132 |
public boolean definesPriorities() { |
133 |
return false; |
134 |
} |
135 |
|
136 |
public void setDefinesPriorities(boolean flag) { |
137 |
/* nothing, since only one label class is suported */
|
138 |
} |
139 |
public LabelClass getLabelClassByName(String labelName) { |
140 |
return defaultLabel;
|
141 |
} |
142 |
|
143 |
public void clearAllClasses() { |
144 |
defaultLabel = null;
|
145 |
} |
146 |
|
147 |
public LabelClass[] getLabelClasses() { |
148 |
return defaultLabel == null ? new LabelClass[0] : new LabelClass[] { defaultLabel }; |
149 |
} |
150 |
|
151 |
public ILabelingMethod cloneMethod() {
|
152 |
if (defaultLabel !=null) |
153 |
try {
|
154 |
return new DefaultLabelingMethod(LabelingFactory.createLabelClassFromXML(defaultLabel.getXMLEntity())); |
155 |
} catch (XMLException e) {
|
156 |
// TODO Auto-generated catch block
|
157 |
e.printStackTrace(); |
158 |
} |
159 |
return new DefaultLabelingMethod(); |
160 |
} |
161 |
} |