Revision 38160
tags/v2_0_0_Build_2046/libraries/libFMap_mapcontext/resources-test/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
5 |
|
|
6 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
7 |
<layout class="org.apache.log4j.PatternLayout"> |
|
8 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
9 |
</layout> |
|
10 |
</appender> |
|
11 |
|
|
12 |
<category name="org.gvsig.tools"> |
|
13 |
<priority value="DEBUG" /> |
|
14 |
</category> |
|
15 |
<category name="org.gvsig.fmap.mapcontext"> |
|
16 |
<priority value="DEBUG" /> |
|
17 |
</category> |
|
18 |
|
|
19 |
<root> |
|
20 |
<priority value="INFO" /> |
|
21 |
<appender-ref ref="CONSOLE" /> |
|
22 |
</root> |
|
23 |
</log4j:configuration> |
tags/v2_0_0_Build_2046/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/ExtentHistory.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 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 |
package org.gvsig.fmap.mapcontext; |
|
42 |
|
|
43 |
import java.awt.geom.Rectangle2D; |
|
44 |
|
|
45 |
import org.gvsig.tools.ToolsLocator; |
|
46 |
import org.gvsig.tools.dynobject.DynStruct; |
|
47 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
48 |
import org.gvsig.tools.persistence.Persistent; |
|
49 |
import org.gvsig.tools.persistence.PersistentState; |
|
50 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
51 |
|
|
52 |
/** |
|
53 |
* <p><code>ExtentHistory</code> is designed for managing a history of extents.</p> |
|
54 |
* |
|
55 |
* <p>Note: An <i>extent</i> is a re.setMandatory(true)ctangular area, with information of its top-left 2D corner.</p> |
|
56 |
* |
|
57 |
* @author Vicente Caballero Navarro |
|
58 |
*/ |
|
59 |
public class ExtentHistory implements Persistent { |
|
60 |
|
|
61 |
/** |
|
62 |
* <p>Maximum number of extents that can store.</p> |
|
63 |
*/ |
|
64 |
private int NUMREC; |
|
65 |
|
|
66 |
/** |
|
67 |
* <p>Array with the extents.</p> |
|
68 |
* |
|
69 |
* @see #hasPrevious() |
|
70 |
* @see #put(Rectangle2D) |
|
71 |
* @see #get() |
|
72 |
* @see #removePrev() |
|
73 |
*/ |
|
74 |
private Rectangle2D[] extents; |
|
75 |
|
|
76 |
/** |
|
77 |
* <p>Number of extents stored.</p> |
|
78 |
* |
|
79 |
* @see #hasPrevious() |
|
80 |
* @see #put(Rectangle2D) |
|
81 |
* @see #get() |
|
82 |
* @see #removePrev() |
|
83 |
*/ |
|
84 |
private int num = 0; |
|
85 |
|
|
86 |
|
|
87 |
/** |
|
88 |
* <p>Creates a new instance of <code>ExtentsHistory</code> with an history of 10 extents.</p> |
|
89 |
*/ |
|
90 |
public ExtentHistory() { |
|
91 |
this(10); |
|
92 |
} |
|
93 |
|
|
94 |
|
|
95 |
/** |
|
96 |
* <p>Creates a new instance of <code>ExtentsHistory</code> with an history of <code>numEntries</code> extents.</p> |
|
97 |
* |
|
98 |
* @param numEntries the maximum number of extents that will store the instance |
|
99 |
*/ |
|
100 |
public ExtentHistory(int numEntries) { |
|
101 |
NUMREC = numEntries; |
|
102 |
extents = new Rectangle2D[NUMREC]; |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 |
* <p>Appends the specified extent to the end of this history.</p> |
|
107 |
* |
|
108 |
* @param ext the new extent |
|
109 |
* |
|
110 |
* @see #get() |
|
111 |
* @see #hasPrevious() |
|
112 |
*/ |
|
113 |
public void put(Rectangle2D ext) { |
|
114 |
if ((ext != null) && ((num < 1) || (ext != extents[num - 1]))) { |
|
115 |
if (num < (NUMREC)) { |
|
116 |
extents[num] = ext; |
|
117 |
num = num + 1; |
|
118 |
} else { |
|
119 |
for (int i = 0; i < (NUMREC - 1); i++) { |
|
120 |
extents[i] = extents[i + 1]; |
|
121 |
} |
|
122 |
|
|
123 |
extents[num - 1] = ext; |
|
124 |
} |
|
125 |
} |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* <p>Returns <code>true</code> if there are extents registered.</p> |
|
130 |
* |
|
131 |
* @return <code>true</code> if there are extents registered; <code>false</code> otherwise |
|
132 |
* |
|
133 |
* @see #put(Rectangle2D) |
|
134 |
* @see #removePrev() |
|
135 |
* @see #get() |
|
136 |
*/ |
|
137 |
public boolean hasPrevious() { |
|
138 |
return num > 0; |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* <p>Returns the last extent in the history.</p> |
|
143 |
* |
|
144 |
* @return the last extent in the history |
|
145 |
* |
|
146 |
* @see #put(Rectangle2D) |
|
147 |
* @see #getXMLEntity() |
|
148 |
*/ |
|
149 |
public Rectangle2D get() { |
|
150 |
if (num <= 0) { |
|
151 |
return null; |
|
152 |
} |
|
153 |
Rectangle2D ext = extents[num - 1]; |
|
154 |
|
|
155 |
return ext; |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* <p>Extracts (removing) the last extent from the history.</p> |
|
160 |
* |
|
161 |
* @return last extent in the history |
|
162 |
* |
|
163 |
* @see #hasPrevious() |
|
164 |
*/ |
|
165 |
public Rectangle2D removePrev() { |
|
166 |
if (num <= 0) { |
|
167 |
return null; |
|
168 |
} |
|
169 |
Rectangle2D ext = extents[--num]; |
|
170 |
return ext; |
|
171 |
} |
|
172 |
|
|
173 |
public void loadFromState(PersistentState state) |
|
174 |
throws PersistenceException { |
|
175 |
|
|
176 |
num = state.getInt("num"); |
|
177 |
NUMREC = state.getInt("numrec"); |
|
178 |
extents = (Rectangle2D[]) state.getArray("extents", Rectangle2D.class); |
|
179 |
} |
|
180 |
|
|
181 |
/** |
|
182 |
* <p> |
|
183 |
* Returns information of this object. All information is stored as |
|
184 |
* properties:<br> |
|
185 |
* </p> |
|
186 |
* <p> |
|
187 |
* <b>Properties:</b> |
|
188 |
* <ul> |
|
189 |
* <li><i>className</i>: name of this class. |
|
190 |
* <li><i>num</i>: number of extents registered. |
|
191 |
* <li><i>numrec</i>: maximum number of extents that can register. |
|
192 |
* <li><i>extents</i>: . |
|
193 |
* </ul> |
|
194 |
* </p> |
|
195 |
* |
|
196 |
*/ |
|
197 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
198 |
|
|
199 |
state.set("num", num); |
|
200 |
state.set("numrec", NUMREC); |
|
201 |
state.set("extents", extents); |
|
202 |
} |
|
203 |
|
|
204 |
|
|
205 |
public static void registerPersistent() { |
|
206 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
207 |
DynStruct definition = manager.addDefinition( |
|
208 |
ExtentHistory.class, |
|
209 |
"ExtentHistory", |
|
210 |
"ExtentHistory Persistence definition", |
|
211 |
null, |
|
212 |
null |
|
213 |
); |
|
214 |
definition.addDynFieldInt("num").setMandatory(true); |
|
215 |
definition.addDynFieldInt("numrec").setMandatory(true); |
|
216 |
definition.addDynFieldArray("extents").setClassOfItems(Rectangle2D.class).setMandatory(true); |
|
217 |
} |
|
218 |
} |
tags/v2_0_0_Build_2046/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/symbols/impl/DefaultSymbolPreferences.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {} {{Task}} |
|
26 |
*/ |
|
27 |
package org.gvsig.fmap.mapcontext.rendering.symbols.impl; |
|
28 |
|
|
29 |
import java.awt.Color; |
|
30 |
import java.awt.Font; |
|
31 |
import java.io.File; |
|
32 |
|
|
33 |
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport; |
|
34 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolPreferences; |
|
35 |
|
|
36 |
/** |
|
37 |
* Default {@link SymbolPreferences} implementation based on object attributes. |
|
38 |
* |
|
39 |
* @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team |
|
40 |
*/ |
|
41 |
public class DefaultSymbolPreferences implements SymbolPreferences { |
|
42 |
|
|
43 |
private String symbolFileExtension = ".gvssym"; |
|
44 |
|
|
45 |
private Color defaultSymbolColor; |
|
46 |
|
|
47 |
private Color defaultSymbolFillColor; |
|
48 |
|
|
49 |
private boolean defaultSymbolFillColorAleatory; |
|
50 |
|
|
51 |
private Font defaultSymbolFont; |
|
52 |
|
|
53 |
private String symbolLibraryPath; |
|
54 |
|
|
55 |
/** |
|
56 |
* The unit that will be used when creating new symbols with Cartographic |
|
57 |
* support. |
|
58 |
*/ |
|
59 |
private int defaultCartographicSupportMeasureUnit = -1; |
|
60 |
|
|
61 |
/** |
|
62 |
* The reference system that will be used when creating new symbols with |
|
63 |
* Cartographic support. |
|
64 |
*/ |
|
65 |
private int defaultCartographicSupportReferenceSystem = |
|
66 |
CartographicSupport.WORLD; |
|
67 |
|
|
68 |
public DefaultSymbolPreferences() { |
|
69 |
resetDefaultSymbolColor(); |
|
70 |
resetDefaultSymbolFillColor(); |
|
71 |
resetDefaultSymbolFillColorAleatory(); |
|
72 |
resetSymbolLibraryPath(); |
|
73 |
resetDefaultSymbolFont(); |
|
74 |
} |
|
75 |
|
|
76 |
public String getSymbolFileExtension() { |
|
77 |
return symbolFileExtension; |
|
78 |
} |
|
79 |
|
|
80 |
public void setSymbolFileExtension(String symbolFileExtension) { |
|
81 |
this.symbolFileExtension = symbolFileExtension; |
|
82 |
} |
|
83 |
public String getSymbolLibraryPath() { |
|
84 |
return symbolLibraryPath; |
|
85 |
} |
|
86 |
|
|
87 |
public void setSymbolLibraryPath(String symbolLibraryPath) { |
|
88 |
this.symbolLibraryPath = symbolLibraryPath; |
|
89 |
} |
|
90 |
|
|
91 |
public void resetSymbolLibraryPath() { |
|
92 |
symbolLibraryPath = |
|
93 |
System.getProperty("user.home") + File.separator + "gvSIG" |
|
94 |
+ File.separator + "Symbols"; |
|
95 |
} |
|
96 |
|
|
97 |
public Color getDefaultSymbolColor() { |
|
98 |
return defaultSymbolColor; |
|
99 |
} |
|
100 |
|
|
101 |
public void setDefaultSymbolColor(Color defaultSymbolColor) { |
|
102 |
this.defaultSymbolColor = defaultSymbolColor; |
|
103 |
} |
|
104 |
|
|
105 |
public void resetDefaultSymbolColor() { |
|
106 |
defaultSymbolColor = Color.GRAY; |
|
107 |
} |
|
108 |
|
|
109 |
public Color getDefaultSymbolFillColor() { |
|
110 |
return defaultSymbolFillColor; |
|
111 |
} |
|
112 |
|
|
113 |
public void setDefaultSymbolFillColor(Color defaultSymbolFillColor) { |
|
114 |
this.defaultSymbolFillColor = defaultSymbolFillColor; |
|
115 |
} |
|
116 |
|
|
117 |
public void resetDefaultSymbolFillColor() { |
|
118 |
defaultSymbolFillColor = new Color(60, 235, 235); |
|
119 |
} |
|
120 |
|
|
121 |
public boolean isDefaultSymbolFillColorAleatory() { |
|
122 |
return defaultSymbolFillColorAleatory; |
|
123 |
} |
|
124 |
|
|
125 |
public void setDefaultSymbolFillColorAleatory( |
|
126 |
boolean defaultSymbolFillColorAleatory) { |
|
127 |
this.defaultSymbolFillColorAleatory = defaultSymbolFillColorAleatory; |
|
128 |
} |
|
129 |
|
|
130 |
public void resetDefaultSymbolFillColorAleatory() { |
|
131 |
defaultSymbolFillColorAleatory = false; |
|
132 |
} |
|
133 |
|
|
134 |
public Font getDefaultSymbolFont() { |
|
135 |
return defaultSymbolFont; |
|
136 |
} |
|
137 |
|
|
138 |
public void setDefaultSymbolFont(Font defaultSymbolFont) { |
|
139 |
this.defaultSymbolFont = defaultSymbolFont; |
|
140 |
} |
|
141 |
|
|
142 |
public void resetDefaultSymbolFont() { |
|
143 |
defaultSymbolFont = new Font("Serif", Font.PLAIN, 8); |
|
144 |
} |
|
145 |
|
|
146 |
public int getDefaultCartographicSupportMeasureUnit() { |
|
147 |
return defaultCartographicSupportMeasureUnit; |
|
148 |
} |
|
149 |
|
|
150 |
public void setDefaultCartographicSupportMeasureUnit( |
|
151 |
int defaultCartographicSupportMeasureUnit) { |
|
152 |
this.defaultCartographicSupportMeasureUnit = |
|
153 |
defaultCartographicSupportMeasureUnit; |
|
154 |
} |
|
155 |
|
|
156 |
public int getDefaultCartographicSupportReferenceSystem() { |
|
157 |
return defaultCartographicSupportReferenceSystem; |
|
158 |
} |
|
159 |
|
|
160 |
public void setDefaultCartographicSupportReferenceSystem( |
|
161 |
int defaultCartographicSupportReferenceSystem) { |
|
162 |
this.defaultCartographicSupportReferenceSystem = |
|
163 |
defaultCartographicSupportReferenceSystem; |
|
164 |
} |
|
165 |
} |
tags/v2_0_0_Build_2046/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/symbols/impl/SaveSymbolException.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {DiSiD Technologies} {{Task}} |
|
26 |
*/ |
|
27 |
package org.gvsig.fmap.mapcontext.rendering.symbols.impl; |
|
28 |
|
|
29 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolException; |
|
30 |
|
|
31 |
/** |
|
32 |
* Exception thrown when there is an error while a symbol is being persisted. |
|
33 |
* @author gvSIG team |
|
34 |
*/ |
|
35 |
public class SaveSymbolException extends SymbolException { |
|
36 |
|
|
37 |
private static final long serialVersionUID = 2386696269496820720L; |
|
38 |
|
|
39 |
private static final String KEY = "SaveSymbolException"; |
|
40 |
|
|
41 |
private static final String MESSAGE = "Error while persisting a symbol"; |
|
42 |
|
|
43 |
public SaveSymbolException(Throwable cause) { |
|
44 |
super(MESSAGE, cause, KEY, serialVersionUID); |
|
45 |
} |
|
46 |
} |
tags/v2_0_0_Build_2046/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/symbols/impl/LoadSymbolException.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {gvSIG} {Create Symbol management API} |
|
26 |
*/ |
|
27 |
package org.gvsig.fmap.mapcontext.rendering.symbols.impl; |
|
28 |
|
|
29 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolException; |
|
30 |
|
|
31 |
/** |
|
32 |
* Exception thrown when there is an error while a persisted symbol is being |
|
33 |
* loaded. |
|
34 |
* |
|
35 |
* @author gvSIG team |
|
36 |
*/ |
|
37 |
public class LoadSymbolException extends SymbolException { |
|
38 |
|
|
39 |
private static final long serialVersionUID = 3182880573327780775L; |
|
40 |
|
|
41 |
private static final String KEY = "LoadSymbolException"; |
|
42 |
|
|
43 |
private static final String MESSAGE = "Error while loading a persisted symbol"; |
|
44 |
|
|
45 |
public LoadSymbolException(Throwable cause) { |
|
46 |
super(MESSAGE, cause, KEY, serialVersionUID); |
|
47 |
} |
|
48 |
} |
tags/v2_0_0_Build_2046/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/symbols/impl/DefaultSymbolManager.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {DiSiD Technologies} {{Task}} |
|
26 |
*/ |
|
27 |
package org.gvsig.fmap.mapcontext.rendering.symbols.impl; |
|
28 |
|
|
29 |
import java.awt.Color; |
|
30 |
import java.io.File; |
|
31 |
import java.io.FileFilter; |
|
32 |
import java.io.FileInputStream; |
|
33 |
import java.io.FileOutputStream; |
|
34 |
import java.io.IOException; |
|
35 |
import java.util.Collections; |
|
36 |
import java.util.HashMap; |
|
37 |
import java.util.Map; |
|
38 |
import java.util.Random; |
|
39 |
|
|
40 |
import org.gvsig.fmap.mapcontext.MapContextRuntimeException; |
|
41 |
import org.gvsig.fmap.mapcontext.impl.InvalidRegisteredClassException; |
|
42 |
import org.gvsig.fmap.mapcontext.impl.RegisteredClassInstantiationException; |
|
43 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol; |
|
44 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
45 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IWarningSymbol; |
|
46 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolException; |
|
47 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager; |
|
48 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolPreferences; |
|
49 |
import org.gvsig.tools.ToolsLocator; |
|
50 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
51 |
import org.gvsig.tools.persistence.PersistentState; |
|
52 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
53 |
|
|
54 |
/** |
|
55 |
* Default {@link SymbolManager} implementation. |
|
56 |
* |
|
57 |
* @author gvSIG team |
|
58 |
*/ |
|
59 |
public class DefaultSymbolManager implements SymbolManager { |
|
60 |
|
|
61 |
private SymbolPreferences symbolPreferences = |
|
62 |
new DefaultSymbolPreferences(); |
|
63 |
|
|
64 |
private Map symbolsByName = Collections.synchronizedMap(new HashMap()); |
|
65 |
|
|
66 |
private Map symbolsByShapeType = Collections.synchronizedMap(new HashMap()); |
|
67 |
|
|
68 |
private Map multiLineSymbolsByName = |
|
69 |
Collections.synchronizedMap(new HashMap()); |
|
70 |
|
|
71 |
private Map multiLineSymbolsByShapeType = |
|
72 |
Collections.synchronizedMap(new HashMap()); |
|
73 |
|
|
74 |
private IWarningSymbol warningSymbol; |
|
75 |
|
|
76 |
private Object warningSymbolLock = new Object(); |
|
77 |
|
|
78 |
public ISymbol[] loadSymbols(File folder) throws SymbolException { |
|
79 |
return loadSymbols(folder, null); |
|
80 |
} |
|
81 |
|
|
82 |
public ISymbol[] loadSymbols(File folder, FileFilter fileFilter) |
|
83 |
throws SymbolException { |
|
84 |
// TODO: add symbol caching |
|
85 |
|
|
86 |
if (folder.exists()) { |
|
87 |
|
|
88 |
File[] symbolFiles = null; |
|
89 |
if (fileFilter == null) { |
|
90 |
symbolFiles = folder.listFiles(); |
|
91 |
} else { |
|
92 |
symbolFiles = folder.listFiles(fileFilter); |
|
93 |
} |
|
94 |
|
|
95 |
if (symbolFiles != null) { |
|
96 |
ISymbol[] symbols = new ISymbol[symbolFiles.length]; |
|
97 |
for (int i = 0; i < symbolFiles.length; i++) { |
|
98 |
symbols[i] = loadSymbol(symbolFiles[i]); |
|
99 |
} |
|
100 |
return symbols; |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
return null; |
|
105 |
} |
|
106 |
|
|
107 |
public void saveSymbol(ISymbol symbol, String fileName, File folder) |
|
108 |
throws SymbolException { |
|
109 |
saveSymbol(symbol, fileName, folder, false); |
|
110 |
} |
|
111 |
|
|
112 |
public void saveSymbol(ISymbol symbol, String fileName, File folder, |
|
113 |
boolean overwrite) throws SymbolException { |
|
114 |
// TODO: add symbol caching |
|
115 |
|
|
116 |
PersistenceManager persistenceManager = ToolsLocator |
|
117 |
.getPersistenceManager(); |
|
118 |
|
|
119 |
File symbolFile = new File(folder, fileName); |
|
120 |
if (!overwrite && symbolFile.exists()) { |
|
121 |
throw new SymbolFileAlreadyExistsException(symbolFile); |
|
122 |
} |
|
123 |
|
|
124 |
try { |
|
125 |
FileOutputStream fos = new FileOutputStream(symbolFile); |
|
126 |
|
|
127 |
persistenceManager.saveState(persistenceManager.getState(symbol), |
|
128 |
fos); |
|
129 |
|
|
130 |
fos.flush(); |
|
131 |
fos.close(); |
|
132 |
} catch (PersistenceException e) { |
|
133 |
throw new SaveSymbolException(e); |
|
134 |
} catch (IOException e) { |
|
135 |
throw new SaveSymbolException(e); |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* Loads a persisted symbol from the given file. |
|
141 |
*/ |
|
142 |
private ISymbol loadSymbol(File file) throws SymbolException { |
|
143 |
if (file.exists()) { |
|
144 |
try { |
|
145 |
FileInputStream fis = new FileInputStream(file); |
|
146 |
|
|
147 |
PersistenceManager persistenceManager = ToolsLocator |
|
148 |
.getPersistenceManager(); |
|
149 |
|
|
150 |
PersistentState state = persistenceManager.loadState(fis); |
|
151 |
ISymbol symbol = (ISymbol) persistenceManager.create(state); |
|
152 |
|
|
153 |
fis.close(); |
|
154 |
return symbol; |
|
155 |
} catch (PersistenceException e) { |
|
156 |
throw new LoadSymbolException(e); |
|
157 |
} catch (IOException e) { |
|
158 |
throw new LoadSymbolException(e); |
|
159 |
} |
|
160 |
} |
|
161 |
|
|
162 |
return null; |
|
163 |
} |
|
164 |
|
|
165 |
public SymbolPreferences getSymbolPreferences() { |
|
166 |
return symbolPreferences; |
|
167 |
} |
|
168 |
|
|
169 |
public ISymbol createSymbol(String symbolName) |
|
170 |
throws MapContextRuntimeException { |
|
171 |
return createSymbol(symbolName, (Class) symbolsByName.get(symbolName), |
|
172 |
ISymbol.class); |
|
173 |
} |
|
174 |
|
|
175 |
public ISymbol createSymbol(int shapeType) |
|
176 |
throws MapContextRuntimeException { |
|
177 |
String symbolName = |
|
178 |
(String) symbolsByShapeType.get(new Integer(shapeType)); |
|
179 |
|
|
180 |
return symbolName == null ? null : createSymbol(symbolName); |
|
181 |
} |
|
182 |
|
|
183 |
public ISymbol createSymbol(String symbolName, Color color) |
|
184 |
throws MapContextRuntimeException { |
|
185 |
ISymbol symbol = createSymbol(symbolName); |
|
186 |
|
|
187 |
if (symbol != null) { |
|
188 |
symbol.setColor(color); |
|
189 |
} |
|
190 |
|
|
191 |
return symbol; |
|
192 |
} |
|
193 |
|
|
194 |
public ISymbol createSymbol(int shapeType, Color color) |
|
195 |
throws MapContextRuntimeException { |
|
196 |
String symbolName = |
|
197 |
(String) symbolsByShapeType.get(new Integer(shapeType)); |
|
198 |
|
|
199 |
return symbolName == null ? null : createSymbol(symbolName, color); |
|
200 |
} |
|
201 |
|
|
202 |
public IMultiLayerSymbol createMultiLayerSymbol(String symbolName) |
|
203 |
throws MapContextRuntimeException { |
|
204 |
return (IMultiLayerSymbol) createSymbol(symbolName, |
|
205 |
(Class) multiLineSymbolsByName.get(symbolName), |
|
206 |
IMultiLayerSymbol.class); |
|
207 |
} |
|
208 |
|
|
209 |
public IMultiLayerSymbol createMultiLayerSymbol(int shapeType) |
|
210 |
throws MapContextRuntimeException { |
|
211 |
String symbolName = |
|
212 |
(String) multiLineSymbolsByShapeType.get(new Integer(shapeType)); |
|
213 |
|
|
214 |
return symbolName == null ? null : createMultiLayerSymbol(symbolName); |
|
215 |
} |
|
216 |
|
|
217 |
public void registerSymbol(String symbolName, Class symbolClass) |
|
218 |
throws MapContextRuntimeException { |
|
219 |
if (symbolClass == null || !ISymbol.class.isAssignableFrom(symbolClass)) { |
|
220 |
throw new InvalidRegisteredClassException(ISymbol.class, |
|
221 |
symbolClass, symbolName); |
|
222 |
} |
|
223 |
symbolsByName.put(symbolName, symbolClass); |
|
224 |
} |
|
225 |
|
|
226 |
public void registerSymbol(String symbolName, int[] shapeTypes, |
|
227 |
Class symbolClass) throws MapContextRuntimeException { |
|
228 |
registerSymbol(symbolName, symbolClass); |
|
229 |
if (shapeTypes != null) { |
|
230 |
for (int i = 0; i < shapeTypes.length; i++) { |
|
231 |
symbolsByShapeType.put(new Integer(shapeTypes[i]), symbolName); |
|
232 |
} |
|
233 |
} |
|
234 |
} |
|
235 |
|
|
236 |
public void registerMultiLayerSymbol(String symbolName, Class symbolClass) |
|
237 |
throws MapContextRuntimeException { |
|
238 |
if (symbolClass == null |
|
239 |
|| !IMultiLayerSymbol.class.isAssignableFrom(symbolClass)) { |
|
240 |
throw new InvalidRegisteredClassException(IMultiLayerSymbol.class, |
|
241 |
symbolClass, symbolName); |
|
242 |
} |
|
243 |
|
|
244 |
multiLineSymbolsByName.put(symbolName, symbolClass); |
|
245 |
} |
|
246 |
|
|
247 |
public void registerMultiLayerSymbol(String symbolName, int[] shapeTypes, |
|
248 |
Class symbolClass) throws MapContextRuntimeException { |
|
249 |
registerMultiLayerSymbol(symbolName, symbolClass); |
|
250 |
if (shapeTypes != null) { |
|
251 |
for (int i = 0; i < shapeTypes.length; i++) { |
|
252 |
multiLineSymbolsByShapeType.put(new Integer(shapeTypes[i]), |
|
253 |
symbolName); |
|
254 |
} |
|
255 |
} |
|
256 |
} |
|
257 |
|
|
258 |
public IWarningSymbol getWarningSymbol(String message, String symbolDesc, |
|
259 |
int symbolDrawExceptionType) throws MapContextRuntimeException { |
|
260 |
synchronized (warningSymbolLock) { |
|
261 |
if (warningSymbol == null) { |
|
262 |
warningSymbol = (IWarningSymbol) createSymbol("warning"); |
|
263 |
} |
|
264 |
} |
|
265 |
|
|
266 |
// TODO: set those values as parameter values in the draw method. |
|
267 |
warningSymbol.setDescription(symbolDesc); |
|
268 |
warningSymbol.setMessage(message); |
|
269 |
warningSymbol.setDrawExceptionType(symbolDrawExceptionType); |
|
270 |
|
|
271 |
return warningSymbol; |
|
272 |
} |
|
273 |
|
|
274 |
private ISymbol createSymbol(String symbolName, Class symbolClass, |
|
275 |
Class expectedType) throws MapContextRuntimeException { |
|
276 |
ISymbol symbol; |
|
277 |
try { |
|
278 |
symbol = |
|
279 |
(ISymbol) (symbolClass == null ? null |
|
280 |
: symbolClass.newInstance()); |
|
281 |
} catch (InstantiationException e) { |
|
282 |
throw new RegisteredClassInstantiationException(expectedType, |
|
283 |
symbolClass, symbolName, e); |
|
284 |
} catch (IllegalAccessException e) { |
|
285 |
throw new RegisteredClassInstantiationException(expectedType, |
|
286 |
symbolClass, symbolName, e); |
|
287 |
} |
|
288 |
|
|
289 |
Color symbolColor; |
|
290 |
if (getSymbolPreferences().isDefaultSymbolFillColorAleatory()) { |
|
291 |
Random rand = new Random(); |
|
292 |
int numreg = rand.nextInt(255 / 2); |
|
293 |
double div = (1 - rand.nextDouble() * 0.66) * 0.9; |
|
294 |
symbolColor = |
|
295 |
new Color( |
|
296 |
((int) (255 * div + (numreg * rand.nextDouble()))) % 255, |
|
297 |
((int) (255 * div + (numreg * rand.nextDouble()))) % 255, |
|
298 |
((int) (255 * div + (numreg * rand.nextDouble()))) % 255); |
|
299 |
} |
|
300 |
else { |
|
301 |
symbolColor = getSymbolPreferences().getDefaultSymbolFillColor(); |
|
302 |
} |
|
303 |
symbol.setColor(symbolColor); |
|
304 |
// Perform this initialization into the Symbol implementation |
|
305 |
// if (symbol instanceof CartographicSupport) { |
|
306 |
// CartographicSupport cs = (CartographicSupport) symbol; |
|
307 |
// cs.setUnit(getDefaultCartographicSupportMeasureUnit()); |
|
308 |
// cs |
|
309 |
// .setReferenceSystem(getDefaultCartographicSupportReferenceSystem(); |
|
310 |
// } |
|
311 |
|
|
312 |
return symbol; |
|
313 |
} |
|
314 |
} |
tags/v2_0_0_Build_2046/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/symbols/impl/SymbolFileAlreadyExistsException.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {DiSiD Technologies} {{Task}} |
|
26 |
*/ |
|
27 |
package org.gvsig.fmap.mapcontext.rendering.symbols.impl; |
|
28 |
|
|
29 |
import java.io.File; |
|
30 |
|
|
31 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolException; |
|
32 |
|
|
33 |
/** |
|
34 |
* Exception thrown when a symbol file is going to be created and the file |
|
35 |
* already exists. |
|
36 |
* @author gvSIG team |
|
37 |
*/ |
|
38 |
public class SymbolFileAlreadyExistsException extends SymbolException { |
|
39 |
|
|
40 |
private static final long serialVersionUID = 2327496845968384363L; |
|
41 |
|
|
42 |
private static final String KEY = "SymbolFileAlreadyExistsException"; |
|
43 |
|
|
44 |
private static final String MESSAGE = "A symbol was going to be stored on " + |
|
45 |
"the file %(file), which already exists"; |
|
46 |
|
|
47 |
public SymbolFileAlreadyExistsException(File symbolFile) { |
|
48 |
super(MESSAGE, KEY, serialVersionUID); |
|
49 |
setValue("file", symbolFile); |
|
50 |
} |
|
51 |
} |
tags/v2_0_0_Build_2046/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/symbols/CartographicSupport.java | ||
---|---|---|
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 |
package org.gvsig.fmap.mapcontext.rendering.symbols; |
|
42 |
|
|
43 |
import org.gvsig.fmap.geom.Geometry; |
|
44 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
45 |
|
|
46 |
/** |
|
47 |
* <p>This interface enables Cartographic support for those graphical elements that require |
|
48 |
* additional runtime information rather than the feature itself geometric definitions.<br></p> |
|
49 |
* |
|
50 |
* <p>It allows to realworld's measure units dimensioning.<br></p> |
|
51 |
* |
|
52 |
* <p>It also supplies a toolkit to perform operations with centralized static methods. |
|
53 |
* @see CartographicSupportToolkit inner class' methods<br></p> |
|
54 |
* |
|
55 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
56 |
*/ |
|
57 |
public interface CartographicSupport { |
|
58 |
public static final int WORLD = 0; |
|
59 |
public static final int PAPER = 1; |
|
60 |
|
|
61 |
/** |
|
62 |
* Defines the unit used to express measures. It is the position of the unit in the <b>MapContext.NAMES</b> array. |
|
63 |
* @param unitIndex, the index of the unit in the MapContext.NAMES array |
|
64 |
*/ |
|
65 |
public abstract void setUnit(int unitIndex); |
|
66 |
/** |
|
67 |
* Returns the unit used to express measures. It is the position of the unit in the <b>MapContext.NAMES</b> array. |
|
68 |
* @returns an <b>int</b> with the index of the unit in the MapContext.NAMES array, or -1 if the size is specified in pixel |
|
69 |
*/ |
|
70 |
public abstract int getUnit(); |
|
71 |
|
|
72 |
/** |
|
73 |
* Returns the <b>Reference System</b> used to draw the elements of the image.<br> |
|
74 |
* <p> |
|
75 |
* The elements have to be scaled to <b>pixel</b> when the image is bein drawn in |
|
76 |
* order to compose the map. The elements of the map may define its size in |
|
77 |
* other units than pixel.<br> |
|
78 |
* </p> |
|
79 |
* <p><b>CartographicSupport</b> enables the elements to define the size in |
|
80 |
* measure units but these units may refer to different reference system. Two |
|
81 |
* kinds of Reference Systems are allowed in this context: <b>CartographicSupport.WORLD</b>, |
|
82 |
* and <b>CartographicSupport.PAPER</b>. |
|
83 |
* <br></p> |
|
84 |
* <p> |
|
85 |
* Depending on which <b>Reference System</b> is used the unit used by this element |
|
86 |
* refers to distances in the real world (then they are map's CRS-dependant) |
|
87 |
* or screen or printer output (then they are output DPI-dependant)<br> |
|
88 |
* </p> |
|
89 |
* <p> |
|
90 |
* In case the unit used is <b>pixel</b> then the reference system does not |
|
91 |
* have any effect since the source unit is the same than the target unit. |
|
92 |
* <br> |
|
93 |
* </p> |
|
94 |
* @return |
|
95 |
*/ |
|
96 |
public abstract int getReferenceSystem(); |
|
97 |
|
|
98 |
/** |
|
99 |
* Sets the <b>Reference System</b> that defines how this units have to be |
|
100 |
* handled. Possible values are: |
|
101 |
* <ol> |
|
102 |
* <li><b>CartographySupport.WORLD</b>: Defines that the unit values refer |
|
103 |
* to distances in the world. So, the size of the element displayed <b>depends |
|
104 |
* directly on the scale and CRS</b> used by the map. The size of the elements |
|
105 |
* defined to use CartographicSupport.WORLD will match exactly to their |
|
106 |
* actual size in the real world.</li> |
|
107 |
* <li><b>CartographySupport.PAPER</b>: Defines that the unit values refer |
|
108 |
* to the length that the element will have regardless where it appears. If |
|
109 |
* ReferenceSystem is <b>CartographySupport.PAPER</b>, and the length is (e.g.) |
|
110 |
* millimeters the element will be displayed with the <b>same</b> amount of |
|
111 |
* millimeters of length whether in the <b>screen</b> or the <b>printer</b> |
|
112 |
* (screen DPI and printer DPI must be correctly configured).</li> |
|
113 |
* </ol> |
|
114 |
*/ |
|
115 |
public abstract void setReferenceSystem(int referenceSystem); |
|
116 |
|
|
117 |
/** |
|
118 |
* Computes and sets the size (in pixels) of the cartographic element according |
|
119 |
* to the current rendering context (output dpi, map scale, map units) and the |
|
120 |
* symbol cartgraphic settings (unit, size, and unit reference system). |
|
121 |
* |
|
122 |
* @param viewPort, the ViewPort containing the symbol. |
|
123 |
* @param dpi, current output dpi (screen or printer) |
|
124 |
* @param shp, used only for MultiShapeSymbols in order to discriminate the internal symbol to be applied |
|
125 |
* @return a double containing the previous defined size |
|
126 |
*/ |
|
127 |
public abstract double toCartographicSize(ViewPort viewPort, double dpi, Geometry geom); |
|
128 |
|
|
129 |
/** |
|
130 |
* Sets the size of the cartographic element in pixels. |
|
131 |
* |
|
132 |
* @param cartographicSize, the size in pixels of the element |
|
133 |
* @param shp, used only for MultiShapeSymbols in order to discriminate the internal symbol to be applied |
|
134 |
*/ |
|
135 |
public abstract void setCartographicSize(double cartographicSize, Geometry geom); |
|
136 |
|
|
137 |
/** |
|
138 |
* Gets the size (in pixels) of the cartographic element according |
|
139 |
* to the current rendering context (output dpi, map scale, map units) and the |
|
140 |
* symbol cartgraphic settings (unit, size, and unit reference system). |
|
141 |
* @param viewPort |
|
142 |
* @param dpi |
|
143 |
* @param shp |
|
144 |
* @return double containing the size in [screen/printer] pixels for the current symbol |
|
145 |
*/ |
|
146 |
public abstract double getCartographicSize(ViewPort viewPort, double dpi, Geometry geom); |
|
147 |
|
|
148 |
|
|
149 |
} |
tags/v2_0_0_Build_2046/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/symbols/ITextSymbol.java | ||
---|---|---|
1 |
package org.gvsig.fmap.mapcontext.rendering.symbols; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.Font; |
|
5 |
import java.awt.Rectangle; |
|
6 |
|
|
7 |
import org.gvsig.fmap.geom.Geometry; |
|
8 |
import org.gvsig.fmap.geom.primitive.Point; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
* ITextSymbol.java<br> |
|
14 |
* Represents an ISymbol that draws a text. |
|
15 |
* |
|
16 |
* @author jaume dominguez faus - jaume.dominguez@iver.es Dec 11, 2007 |
|
17 |
* |
|
18 |
*/ |
|
19 |
public interface ITextSymbol extends ISymbol { |
|
20 |
|
|
21 |
public static final String SYMBOL_NAME = "text"; |
|
22 |
|
|
23 |
public final static int SYMBOL_STYLE_ALIGNMENT_LEFT = 94; |
|
24 |
public final static int SYMBOL_STYLE_ALIGNMENT_RIGHT = 95; |
|
25 |
public final static int SYMBOL_STYLE_ALIGNMENT_CENTERED = 96; |
|
26 |
public final static int SYMBOL_STYLE_ALIGNMENT_JUSTIFY = 97; |
|
27 |
/** |
|
28 |
* Establishes the font that will be used to render this ITextSymbol. |
|
29 |
* @param font |
|
30 |
*/ |
|
31 |
public abstract void setFont(Font font); |
|
32 |
|
|
33 |
/** |
|
34 |
* Returns the currently set font. |
|
35 |
* @return Font |
|
36 |
*/ |
|
37 |
public abstract Font getFont(); |
|
38 |
|
|
39 |
/** |
|
40 |
* Returns the currently color set to be applied to the text |
|
41 |
* @return Color |
|
42 |
*/ |
|
43 |
public abstract Color getTextColor(); |
|
44 |
|
|
45 |
/** |
|
46 |
* Sets the color of the text |
|
47 |
* @param color |
|
48 |
*/ |
|
49 |
public abstract void setTextColor(Color color); |
|
50 |
|
|
51 |
/** |
|
52 |
* Returns the text contained by this symbol |
|
53 |
* @return |
|
54 |
* @deprecated ?do i need it? |
|
55 |
*/ |
|
56 |
public abstract String getText(); |
|
57 |
|
|
58 |
/** |
|
59 |
* Sets the text to be rendered by this symbol |
|
60 |
* @param text, a String |
|
61 |
*/ |
|
62 |
public abstract void setText(String text); |
|
63 |
|
|
64 |
/** |
|
65 |
* Sets the font size currently set to this symbol |
|
66 |
* @param d |
|
67 |
*/ |
|
68 |
public abstract void setFontSize(double d); |
|
69 |
|
|
70 |
/** |
|
71 |
* Computes a Geometry wrapping the text to be applied |
|
72 |
* @param p target location |
|
73 |
* @return |
|
74 |
*/ |
|
75 |
public abstract Geometry getTextWrappingShape(Point p); |
|
76 |
|
|
77 |
public abstract Rectangle getBounds(); |
|
78 |
|
|
79 |
public abstract void setAutoresizeEnabled(boolean autoresizeFlag); |
|
80 |
|
|
81 |
public abstract boolean isAutoresizeEnabled(); |
|
82 |
} |
tags/v2_0_0_Build_2046/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/symbols/styles/ILabelStyle.java | ||
---|---|---|
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: ILabelStyle.java 20989 2008-05-28 11:05:57Z jmvivo $ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.10 2007-08-16 06:55:30 jvidal |
|
47 |
* javadoc updated |
|
48 |
* |
|
49 |
* Revision 1.9 2007/08/13 11:36:30 jvidal |
|
50 |
* javadoc |
|
51 |
* |
|
52 |
* Revision 1.8 2007/05/08 08:47:39 jaume |
|
53 |
* *** empty log message *** |
|
54 |
* |
|
55 |
* Revision 1.7 2007/04/05 16:07:14 jaume |
|
56 |
* Styled labeling stuff |
|
57 |
* |
|
58 |
* Revision 1.6 2007/04/04 15:42:03 jaume |
|
59 |
* *** empty log message *** |
|
60 |
* |
|
61 |
* Revision 1.5 2007/04/04 15:41:05 jaume |
|
62 |
* *** empty log message *** |
|
63 |
* |
|
64 |
* Revision 1.4 2007/04/02 16:34:56 jaume |
|
65 |
* Styled labeling (start commiting) |
|
66 |
* |
|
67 |
* Revision 1.3 2007/03/29 16:02:01 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* Revision 1.2 2007/03/09 11:20:56 jaume |
|
71 |
* Advanced symbology (start committing) |
|
72 |
* |
|
73 |
* Revision 1.1.2.1 2007/02/15 16:23:44 jaume |
|
74 |
* *** empty log message *** |
|
75 |
* |
|
76 |
* Revision 1.1.2.1 2007/02/09 07:47:05 jaume |
|
77 |
* Isymbol moved |
|
78 |
* |
|
79 |
* |
|
80 |
*/ |
|
81 |
package org.gvsig.fmap.mapcontext.rendering.symbols.styles; |
|
82 |
|
|
83 |
import java.awt.Dimension; |
|
84 |
import java.awt.geom.Point2D; |
|
85 |
import java.awt.geom.Rectangle2D; |
|
86 |
|
|
87 |
|
|
88 |
/** |
|
89 |
* Defines the style that a Label symbol can contain which typically define |
|
90 |
* a background of the label as an Image, the texts that the label holds |
|
91 |
* and their position within the label in rendering time. |
|
92 |
* |
|
93 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
94 |
* |
|
95 |
*/ |
|
96 |
public interface ILabelStyle extends IStyle { |
|
97 |
/** |
|
98 |
* @return int, the amount of fields this style allows |
|
99 |
*/ |
|
100 |
public int getFieldCount(); |
|
101 |
|
|
102 |
/** |
|
103 |
* Sets the texts that will appear in the label. |
|
104 |
* @param texts |
|
105 |
*/ |
|
106 |
public void setTextFields(String[] texts); |
|
107 |
|
|
108 |
|
|
109 |
/** |
|
110 |
* Returns an array of rectangles defining the text boxes where text is |
|
111 |
* placed. |
|
112 |
* @return |
|
113 |
*/ |
|
114 |
public Rectangle2D[] getTextBounds(); |
|
115 |
|
|
116 |
public Dimension getSize(); |
|
117 |
|
|
118 |
/** |
|
119 |
* Returns the position of the point labeled by this label in percent units relative |
|
120 |
* to the label bounds. It determines the offset to be applied to the label to be |
|
121 |
* placed and allows the user to use custom styles. |
|
122 |
*/ |
|
123 |
public Point2D getMarkerPoint(); |
|
124 |
|
|
125 |
/** |
|
126 |
* Sets the position of the point labeled by this in percent units relative to the |
|
127 |
* label bounds |
|
128 |
* @param p |
|
129 |
* @throws IllegalArgumentException if the point coordinates are >0.0 or <1.0 |
|
130 |
*/ |
|
131 |
public void setMarkerPoint(Point2D p) throws IllegalArgumentException; |
|
132 |
|
|
133 |
/** |
|
134 |
* Sets a TextFieldArea using its index. With this method the user can |
|
135 |
* modify the size of the rectangle for the TextFieldArea |
|
136 |
* @param index |
|
137 |
* @param rect |
|
138 |
*/ |
|
139 |
public void setTextFieldArea(int index, Rectangle2D rect); |
|
140 |
|
|
141 |
/** |
|
142 |
* Adds a new TextFieldArea with an specific size which is defined as a rectangle. |
|
143 |
* @param index,int |
|
144 |
* @param rect,Rectangle2D |
|
145 |
*/ |
|
146 |
public void addTextFieldArea(Rectangle2D rect); |
|
147 |
|
|
148 |
/** |
|
149 |
* Delete the TextFieldArea specified by its index. |
|
150 |
* @param index,int |
|
151 |
*/ |
|
152 |
public void deleteTextFieldArea(int index); |
|
153 |
|
|
154 |
/** |
|
155 |
* Sets the size for a laber and stablishes an unit scale factor to not change |
|
156 |
* too much its content |
|
157 |
* @param width |
|
158 |
* @param height |
|
159 |
*/ |
|
160 |
public void setSize(double width, double height); |
|
161 |
|
|
162 |
} |
tags/v2_0_0_Build_2046/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/symbols/styles/IStyle.java | ||
---|---|---|
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: IStyle.java 20989 2008-05-28 11:05:57Z jmvivo $ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.7 2007-09-20 09:33:15 jaume |
|
47 |
* Refactored: fixed name of IPersistAnce to IPersistence |
|
48 |
* |
|
49 |
* Revision 1.6 2007/09/19 16:19:27 jaume |
|
50 |
* removed unnecessary imports |
|
51 |
* |
|
52 |
* Revision 1.5 2007/08/22 09:49:00 jvidal |
|
53 |
* javadoc updated |
|
54 |
* |
|
55 |
* Revision 1.4 2007/08/16 06:55:30 jvidal |
|
56 |
* javadoc updated |
|
57 |
* |
|
58 |
* Revision 1.3 2007/08/13 11:36:41 jvidal |
|
59 |
* javadoc |
|
60 |
* |
|
61 |
* Revision 1.2 2007/04/04 15:41:05 jaume |
|
62 |
* *** empty log message *** |
|
63 |
* |
|
64 |
* Revision 1.1 2007/03/09 11:20:56 jaume |
|
65 |
* Advanced symbology (start committing) |
|
66 |
* |
|
67 |
* Revision 1.1.2.2 2007/02/15 16:23:44 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* Revision 1.1.2.1 2007/02/09 07:47:05 jaume |
|
71 |
* Isymbol moved |
|
72 |
* |
|
73 |
* |
|
74 |
*/ |
|
75 |
package org.gvsig.fmap.mapcontext.rendering.symbols.styles; |
|
76 |
|
|
77 |
import java.awt.Graphics2D; |
|
78 |
import java.awt.Rectangle; |
|
79 |
|
|
80 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
81 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException; |
|
82 |
import org.gvsig.tools.lang.Cloneable; |
|
83 |
import org.gvsig.tools.persistence.Persistent; |
|
84 |
|
|
85 |
/** |
|
86 |
* Used by Objects that have to define an style for them.This interface has |
|
87 |
* methods to stablish a description and get it,to specify if an object |
|
88 |
* that implements this interface is suitable for a kind of symbol and other |
|
89 |
* methods to draw symbols. |
|
90 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
91 |
*/ |
|
92 |
public interface IStyle extends Persistent, Cloneable { |
|
93 |
/** |
|
94 |
* Defines the description of a symbol.It will be specified with an |
|
95 |
* string. |
|
96 |
* @param desc,String |
|
97 |
*/ |
|
98 |
public abstract void setDescription(String desc); |
|
99 |
/** |
|
100 |
* Returns the description of a symbol |
|
101 |
* @return Description of a symbol |
|
102 |
*/ |
|
103 |
public abstract String getDescription(); |
|
104 |
/** |
|
105 |
* Useful to render the symbol inside the TOC, or inside little |
|
106 |
* rectangles. For example, think about rendering a Label with size |
|
107 |
* in meters => You will need to specify a size in pixels. |
|
108 |
* Of course. You may also preffer to render a prepared image, etc. |
|
109 |
* @param g Graphics2D |
|
110 |
* @param r Rectangle |
|
111 |
*/ |
|
112 |
public abstract void drawInsideRectangle(Graphics2D g, Rectangle r) throws SymbolDrawingException; |
|
113 |
|
|
114 |
/** |
|
115 |
* True if this symbol is ok for the style or class. |
|
116 |
* @param symbol ISymbol |
|
117 |
*/ |
|
118 |
|
|
119 |
public abstract boolean isSuitableFor(ISymbol symbol); |
|
120 |
|
|
121 |
/** |
|
122 |
* Used to show an outline of the style to graphically show its properties. |
|
123 |
* @param g, the Graphics2D where to draw |
|
124 |
* @param r, the bounds of the style inside such Graphics2D |
|
125 |
*/ |
|
126 |
public abstract void drawOutline(Graphics2D g, Rectangle r) throws SymbolDrawingException; |
|
127 |
} |
tags/v2_0_0_Build_2046/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/symbols/IWarningSymbol.java | ||
---|---|---|
1 |
package org.gvsig.fmap.mapcontext.rendering.symbols; |
|
2 |
|
|
3 |
public interface IWarningSymbol extends ISymbol { |
|
4 |
|
|
5 |
public static final String SYMBOL_NAME = "warning"; |
|
6 |
|
|
7 |
void setDrawExceptionType(int symbolDrawExceptionType); |
|
8 |
|
|
9 |
void setMessage(String message); |
|
10 |
|
|
11 |
void setDescription(String description); |
|
12 |
|
|
13 |
} |
tags/v2_0_0_Build_2046/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/symbols/SymbolException.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {gvSIG} {{Task}} |
|
26 |
*/ |
|
27 |
package org.gvsig.fmap.mapcontext.rendering.symbols; |
|
28 |
|
|
29 |
import org.gvsig.fmap.mapcontext.MapContextException; |
Also available in: Unified diff