Revision 5137
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.app/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.legend.urbanhorizontalsignage</artifactId> |
|
6 |
<version>1.0.1</version> |
|
7 |
</parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.legend.urbanhorizontalsignage.app</artifactId> |
|
10 |
<packaging>pom</packaging> |
|
11 |
<name>org.gvsig.legend.urbanhorizontalsignage.app</name> |
|
12 |
|
|
13 |
<modules> |
|
14 |
<module>org.gvsig.legend.urbanhorizontalsignage.app.mainplugin</module> |
|
15 |
</modules> |
|
16 |
|
|
17 |
</project> |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Thu Jul 01 12:56:58 CEST 2021 |
|
2 |
buildNumber=89 |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2013 gvSIG |
|
2 |
Association. This program is free software; you can redistribute it and/or modify |
|
3 |
it under the terms of the GNU General Public License as published by the Free Software |
|
4 |
Foundation; either version 3 of the License, or (at your option) any later version. |
|
5 |
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|
6 |
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
7 |
PURPOSE. See the GNU General Public License for more details. You should have received |
|
8 |
a copy of the GNU General Public License along with this program; if not, write to |
|
9 |
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
|
10 |
USA. For any additional information, do not hesitate to contact us at info AT gvsig.com, |
|
11 |
or visit our website www.gvsig.com. --> |
|
12 |
<assembly> |
|
13 |
<id>gvsig-plugin-package</id> |
|
14 |
<formats> |
|
15 |
<format>zip</format> |
|
16 |
</formats> |
|
17 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
18 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
19 |
<files> |
|
20 |
<file> |
|
21 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
22 |
<outputDirectory>lib</outputDirectory> |
|
23 |
</file> |
|
24 |
<file> |
|
25 |
<source>target/package.info</source> |
|
26 |
</file> |
|
27 |
</files> |
|
28 |
|
|
29 |
<fileSets> |
|
30 |
<fileSet> |
|
31 |
<directory>src/main/resources-plugin</directory> |
|
32 |
<outputDirectory>.</outputDirectory> |
|
33 |
</fileSet> |
|
34 |
</fileSets> |
|
35 |
|
|
36 |
|
|
37 |
<dependencySets> |
|
38 |
<dependencySet> |
|
39 |
<useProjectArtifact>false</useProjectArtifact> |
|
40 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
41 |
<outputDirectory>lib</outputDirectory> |
|
42 |
<includes> |
|
43 |
<include>org.gvsig:org.gvsig.legend.urbanhorizontalsignage.lib.api</include> |
|
44 |
<include>org.gvsig:org.gvsig.legend.urbanhorizontalsignage.lib.impl</include> |
|
45 |
<include>org.gvsig:org.gvsig.legend.urbanhorizontalsignage.swing.api</include> |
|
46 |
<include>org.gvsig:org.gvsig.legend.urbanhorizontalsignage.swing.impl</include> |
|
47 |
</includes> |
|
48 |
</dependencySet> |
|
49 |
</dependencySets> |
|
50 |
|
|
51 |
</assembly> |
|
52 |
|
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/java/org/gvsig/legend/urbanhorizontalsignage/app/UrbanHorizontalSignageExtension.java | ||
---|---|---|
1 |
package org.gvsig.legend.urbanhorizontalsignage.app; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.UUID; |
|
5 |
import javax.swing.JOptionPane; |
|
6 |
import org.gvsig.andami.IconThemeHelper; |
|
7 |
import org.gvsig.andami.plugins.Extension; |
|
8 |
import org.gvsig.app.ApplicationLocator; |
|
9 |
import org.gvsig.app.ApplicationManager; |
|
10 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
11 |
import org.gvsig.app.project.documents.view.ViewManager; |
|
12 |
import org.gvsig.fmap.dal.DALLocator; |
|
13 |
import org.gvsig.fmap.dal.DataManager; |
|
14 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
15 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
16 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
17 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
18 |
import org.gvsig.fmap.dal.feature.Feature; |
|
19 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
20 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
21 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
22 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
23 |
import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters; |
|
24 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer; |
|
25 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
26 |
import org.gvsig.fmap.geom.DataTypes; |
|
27 |
import org.gvsig.fmap.geom.Geometry; |
|
28 |
import org.gvsig.fmap.geom.aggregate.MultiPolygon; |
|
29 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
30 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
31 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData; |
|
32 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_CONT_DISC; |
|
33 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_DISC; |
|
34 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_DISC_CONT; |
|
35 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_DISC_DISC; |
|
36 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLegend; |
|
37 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLocator; |
|
38 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageManager; |
|
39 |
import org.gvsig.tools.ToolsLocator; |
|
40 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
41 |
import org.gvsig.tools.folders.FoldersManager; |
|
42 |
import org.gvsig.tools.i18n.I18nManager; |
|
43 |
import org.gvsig.tools.util.HasAFile; |
|
44 |
import org.slf4j.Logger; |
|
45 |
import org.slf4j.LoggerFactory; |
|
46 |
|
|
47 |
public class UrbanHorizontalSignageExtension extends Extension { |
|
48 |
|
|
49 |
private static final Logger LOGGER = LoggerFactory.getLogger(UrbanHorizontalSignageExtension.class); |
|
50 |
|
|
51 |
@Override |
|
52 |
public void initialize() { |
|
53 |
IconThemeHelper.registerIcon("legend", "legend-overview-vectorial-urbanhorizontalsignage", this); |
|
54 |
IconThemeHelper.registerIcon("action", "layer-modify-clipboard-copy-as-polygons", this); |
|
55 |
|
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public void execute(String actionCommand) { |
|
60 |
|
|
61 |
if (actionCommand.compareToIgnoreCase("layer-modify-clipboard-copy-as-polygons") != 0) { |
|
62 |
return; |
|
63 |
} |
|
64 |
DataManager dataManager = DALLocator.getDataManager(); |
|
65 |
|
|
66 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
67 |
ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
68 |
if (viewdoc == null) { |
|
69 |
return; |
|
70 |
} |
|
71 |
MapContext mapContext = viewdoc.getMapContext(); |
|
72 |
FLyrVect layer = mapContext.getLayers().getFirstActiveVectorLayer(); |
|
73 |
if (layer == null) { |
|
74 |
return; |
|
75 |
} |
|
76 |
UrbanHorizontalSignageManager uhsManager = UrbanHorizontalSignageLocator.getUrbanHorizontalSignageManager(); |
|
77 |
UrbanHorizontalSignageLegend legend = (UrbanHorizontalSignageLegend) layer.getLegend(); |
|
78 |
EditableFeatureType targetFeatureType = createTargetFeatureType(layer.getFeatureStore()); |
|
79 |
FeatureStore targetStore = createTemporalStore(targetFeatureType); |
|
80 |
FeatureSet featureSet = null; |
|
81 |
try { |
|
82 |
targetStore.edit(FeatureStore.MODE_APPEND); |
|
83 |
FeatureSelection selection = layer.getFeatureStore().getFeatureSelection(); |
|
84 |
|
|
85 |
for (Feature feature : selection) { |
|
86 |
|
|
87 |
Geometry originalGeometry = feature.getDefaultGeometry(); |
|
88 |
|
|
89 |
UrbanHorizontalSignageData data = legend.getValues(feature); |
|
90 |
|
|
91 |
uhsManager.calculateGeometries(originalGeometry, data); |
|
92 |
|
|
93 |
MultiPolygon multiGeom = data.getSegmentsGeometry(); |
|
94 |
if (multiGeom != null && multiGeom.getPrimitivesNumber() > 0) { |
|
95 |
for (Geometry geometry : multiGeom) { |
|
96 |
EditableFeature targetFeature = targetStore.createNewFeature(); |
|
97 |
targetFeature.copyFrom(feature, (FeatureAttributeDescriptor t) -> !(t.isPrimaryKey() || (t.isIndexed() && !t.allowIndexDuplicateds()) || t.getType() == DataTypes.GEOMETRY)); |
|
98 |
targetFeature.setDefaultGeometry(geometry); |
|
99 |
targetStore.insert(targetFeature); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
switch (data.getContinuity()) { |
|
104 |
case CONTINUITY_MODE_CONT_DISC: |
|
105 |
case CONTINUITY_MODE_DISC_CONT: |
|
106 |
case CONTINUITY_MODE_DISC: |
|
107 |
case CONTINUITY_MODE_DISC_DISC: |
|
108 |
if (data.isPaintHoles()) { |
|
109 |
multiGeom = data.getHolesGeometry(); |
|
110 |
if (multiGeom != null && multiGeom.getPrimitivesNumber() > 0) { |
|
111 |
for (Geometry geometry : multiGeom) { |
|
112 |
EditableFeature targetFeature = targetStore.createNewFeature(); |
|
113 |
targetFeature.copyFrom(feature, (FeatureAttributeDescriptor t) -> !(t.isPrimaryKey() || (t.isIndexed() && !t.allowIndexDuplicateds()) || t.getType() == DataTypes.GEOMETRY)); |
|
114 |
targetFeature.setDefaultGeometry(geometry); |
|
115 |
targetStore.insert(targetFeature); |
|
116 |
} |
|
117 |
} |
|
118 |
} |
|
119 |
} |
|
120 |
|
|
121 |
} |
|
122 |
|
|
123 |
targetStore.finishEditing(); |
|
124 |
|
|
125 |
featureSet = targetStore.getFeatureSet(); |
|
126 |
|
|
127 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
128 |
int n = application.confirmDialog( |
|
129 |
"_Number_of_geometries_to_be_copied_to_the_clipboard" + " " + featureSet.getSize() + "\n" + "_Do_you_want_to_continue", |
|
130 |
i18n.getTranslation("_Copy_selected_features_as_polygons_to_clipboard"), |
|
131 |
JOptionPane.YES_NO_OPTION, |
|
132 |
JOptionPane.QUESTION_MESSAGE); |
|
133 |
if (n == JOptionPane.YES_OPTION) { |
|
134 |
dataManager.putFeaturesInClipboard(featureSet); |
|
135 |
} |
|
136 |
|
|
137 |
} catch (Exception e) { |
|
138 |
LOGGER.warn("Can't get the selection as JSON.", e); |
|
139 |
} finally { |
|
140 |
DisposeUtils.disposeQuietly(targetStore); |
|
141 |
DisposeUtils.disposeQuietly(featureSet); |
|
142 |
} |
|
143 |
|
|
144 |
} |
|
145 |
|
|
146 |
private EditableFeatureType createTargetFeatureType(FeatureStore store) { |
|
147 |
DataManager dataManager = DALLocator.getDataManager(); |
|
148 |
|
|
149 |
EditableFeatureType featureType = dataManager.createFeatureType(); |
|
150 |
featureType.addAll(store.getDefaultFeatureTypeQuietly()); |
|
151 |
|
|
152 |
EditableFeatureAttributeDescriptor attr = (EditableFeatureAttributeDescriptor) featureType.getDefaultGeometryAttribute(); |
|
153 |
attr.setGeometryType(Geometry.TYPES.POLYGON, Geometry.SUBTYPES.GEOM2D); |
|
154 |
|
|
155 |
return featureType; |
|
156 |
} |
|
157 |
|
|
158 |
private FeatureStore createTemporalStore(EditableFeatureType featType) { |
|
159 |
if (featType.getStore() != null) { |
|
160 |
throw new IllegalArgumentException("Can't create temporal store from a feature type of a already existent store."); |
|
161 |
} |
|
162 |
try { |
|
163 |
// crear ruta de archivo temporal |
|
164 |
FoldersManager foldersManager = ToolsLocator.getFoldersManager(); |
|
165 |
File tempFile = foldersManager.getUniqueTemporaryFile("urbanHorizontalSignage_temporal_store_" + UUID.randomUUID().toString()); |
|
166 |
|
|
167 |
// crear SERVER STORE |
|
168 |
DataManager dataManager = DALLocator.getDataManager(); |
|
169 |
JDBCServerExplorerParameters serverParameters = (JDBCServerExplorerParameters) dataManager.createServerExplorerParameters("H2Spatial"); |
|
170 |
((HasAFile) serverParameters).setFile(tempFile); |
|
171 |
JDBCServerExplorer serverExplorer = (JDBCServerExplorer) dataManager.openServerExplorer("H2Spatial", serverParameters); |
|
172 |
|
|
173 |
//Crear tablas en server store |
|
174 |
JDBCNewStoreParameters parametersResults = serverExplorer.getAddParameters(); |
|
175 |
parametersResults.setDynValue("Table", "results"); |
|
176 |
|
|
177 |
parametersResults.setDefaultFeatureType(featType); |
|
178 |
serverExplorer.add("H2Spatial", parametersResults, true); |
|
179 |
|
|
180 |
DataStoreParameters storeParametersResults = dataManager.createStoreParameters("H2Spatial"); |
|
181 |
storeParametersResults.setDynValue("database_file", tempFile); |
|
182 |
storeParametersResults.setDynValue("Table", "results"); |
|
183 |
|
|
184 |
//Creaci?n del store con los resultados |
|
185 |
FeatureStore storeResults = (FeatureStore) dataManager.openStore("H2Spatial", storeParametersResults); |
|
186 |
|
|
187 |
return storeResults; |
|
188 |
} catch (Exception ex) { |
|
189 |
LOGGER.debug("Can't create temporal store.", ex); |
|
190 |
return null; |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
194 |
@Override |
|
195 |
public boolean isEnabled() { |
|
196 |
// it's enabled if there is exactly one vector layer in the active view |
|
197 |
// and it has a selection |
|
198 |
|
|
199 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
200 |
ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
201 |
if (viewdoc == null) { |
|
202 |
return false; |
|
203 |
} |
|
204 |
MapContext mapContext = viewdoc.getMapContext(); |
|
205 |
FLyrVect layer = mapContext.getLayers().getFirstActiveVectorLayer(); |
|
206 |
if (layer == null) { |
|
207 |
return false; |
|
208 |
} |
|
209 |
if (!layer.isAvailable()) { |
|
210 |
// This can happen when opening a persisted project |
|
211 |
// and there is a "slow" layer (GeoDB) |
|
212 |
return false; |
|
213 |
} |
|
214 |
try { |
|
215 |
FeatureStore store = layer.getFeatureStore(); |
|
216 |
FeatureSelection selection = store.getFeatureSelection(); |
|
217 |
if (selection.isEmpty()) { |
|
218 |
return false; |
|
219 |
} |
|
220 |
return (layer.getLegend() instanceof UrbanHorizontalSignageLegend); |
|
221 |
// return !selection.isEmpty(); |
|
222 |
} catch (Exception ex) { |
|
223 |
LOGGER.warn("Can't get selection from layer '" + layer.getName() + "'.", ex); |
|
224 |
return false; |
|
225 |
} |
|
226 |
} |
|
227 |
|
|
228 |
@Override |
|
229 |
public boolean isVisible() { |
|
230 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
231 |
return application.getActiveDocument(ViewManager.TYPENAME) != null; |
|
232 |
} |
|
233 |
|
|
234 |
} |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2013 gvSIG |
|
3 |
Association. This program is free software; you can redistribute it and/or modify |
|
4 |
it under the terms of the GNU General Public License as published by the Free Software |
|
5 |
Foundation; either version 3 of the License, or (at your option) any later version. |
|
6 |
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|
7 |
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
8 |
PURPOSE. See the GNU General Public License for more details. You should have received |
|
9 |
a copy of the GNU General Public License along with this program; if not, write to |
|
10 |
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
|
11 |
USA. For any additional information, do not hesitate to contact us at info AT gvsig.com, |
|
12 |
or visit our website www.gvsig.com. --> |
|
13 |
<plugin-config> |
|
14 |
<depends plugin-name="org.gvsig.app.mainplugin" /> |
|
15 |
<resourceBundle name="text" /> |
|
16 |
<libraries library-dir="lib" /> |
|
17 |
<extensions> |
|
18 |
<extension class-name="org.gvsig.legend.urbanhorizontalsignage.app.UrbanHorizontalSignageExtension" |
|
19 |
description="" active="true" priority="1"> |
|
20 |
|
|
21 |
<action |
|
22 |
name="layer-modify-clipboard-copy-as-polygons" |
|
23 |
label="_Copy_selected_features_as_polygons_to_clipboard" |
|
24 |
tooltip="_Copy_selected_features_as_polygons_to_clipboard" |
|
25 |
position="601105001" |
|
26 |
action-command="layer-modify-clipboard-copy-as-polygons" |
|
27 |
icon="layer-modify-clipboard-copy-as-polygons" |
|
28 |
accelerator="" |
|
29 |
/> |
|
30 |
|
|
31 |
<menu |
|
32 |
name="layer-modify-clipboard-copy-as-polygons" |
|
33 |
text="Layer/Modify/_Copy_selected_features_as_polygons_to_clipboard" |
|
34 |
/> |
|
35 |
|
|
36 |
<!-- <tool-bar name="edit"> |
|
37 |
<action-tool |
|
38 |
name="layer-modify-clipboard-copy-as-polygons" |
|
39 |
/> |
|
40 |
</tool-bar>--> |
|
41 |
|
|
42 |
|
|
43 |
</extension> |
|
44 |
|
|
45 |
</extensions> |
|
46 |
</plugin-config> |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/resources-plugin/plugin-persistence.def | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<!-- |
|
3 |
Definitions of plugin persistence org.gvsig.aggregatelegend.app.mainplugin |
|
4 |
--> |
|
5 |
<definitions> |
|
6 |
<version>1.0.0</version> |
|
7 |
<classes> |
|
8 |
<class name="org.gvsig.legend.urbanhorizontalsignage.app.mainplugin"> |
|
9 |
<extends> |
|
10 |
</extends> |
|
11 |
<description>Persistence of the legend of urban horizontal signage</description> |
|
12 |
<fields> |
|
13 |
</fields> |
|
14 |
</class> |
|
15 |
</classes> |
|
16 |
</definitions> |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
1 |
_Urban_horizontal_signage_legend_description=Urban horizontal signage legend |
|
2 |
_Urban_horizontal_signage_legend=Urban horizontal signage |
|
3 |
_Width_field=Width field |
|
4 |
_Continuity_field=Continuity field |
|
5 |
_Segments_color_field=Segments color field |
|
6 |
_Segments_length_field=Segments length field |
|
7 |
_Paint_holes_field=Paint holes field |
|
8 |
_Holes_color_field=Holes color field |
|
9 |
_Holes_length_field=Holes length field |
|
10 |
_Round_vertex_field=Round vertex field |
|
11 |
_Gap_width_between_lines=Gap width between lines |
|
12 |
_Copy_selected_features_as_polygons_to_clipboard=Copy selected features as polygons to clipboard |
|
13 |
_Number_of_geometries_to_be_copied_to_the_clipboard=Number of geometries to be copied to the clipboard |
|
14 |
_Do_you_want_to_continue=Do you want to continue? |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
1 |
_Urban_horizontal_signage_legend_description=Leyenda para la se\u00f1alizaci\u00f3n urbana horizontal |
|
2 |
_Urban_horizontal_signage_legend=Se\u00f1alizaci\u00f3n urbana horizontal |
|
3 |
_Width_field=Campo para la anchura |
|
4 |
_Continuity_field=Campo para la continuidad |
|
5 |
_Segments_color_field=Campo para el color de los segmentos |
|
6 |
_Segments_length_field=Campo para la longitud de los segmentos |
|
7 |
_Paint_holes_field=Campo para el pintado de los huecos |
|
8 |
_Holes_color_field=Campo para el color de los huecos |
|
9 |
_Holes_length_field=Campo para la longitud de los huecos |
|
10 |
_Round_vertex_field=Campo para el redondeo de los v\u00e9rtices |
|
11 |
_Gap_width_between_lines=Separaci\u00f3n entre l\u00edneas |
|
12 |
_Copy_selected_features_as_polygons_to_clipboard=Copiar elementos seleccionados como pol\u00edgonos al portapapeles |
|
13 |
_Number_of_geometries_to_be_copied_to_the_clipboard=N\u00famero de geometr\u00edas a ser copiadas al portapapeles |
|
14 |
_Do_you_want_to_continue=\u00bfDesea continuar? |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.legend.urbanhorizontalsignage.app</artifactId> |
|
6 |
<version>1.0.1</version> |
|
7 |
</parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.legend.urbanhorizontalsignage.app.mainplugin</artifactId> |
|
10 |
<version>1.0.1</version> |
|
11 |
<name>org.gvsig.legend.urbanhorizontalsignage.app.mainplugin</name> |
|
12 |
|
|
13 |
<properties> |
|
14 |
<!-- Package info property values --> |
|
15 |
<gvsig.package.info.state>testing</gvsig.package.info.state> |
|
16 |
<gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.4.0-A</gvsig.package.info.dependencies> |
|
17 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
18 |
<gvsig.package.info.name>Vector legend: urban horizaontal signage</gvsig.package.info.name> |
|
19 |
<gvsig.package.info.description>Legend for urban horizaontal signage.</gvsig.package.info.description> |
|
20 |
<gvsig.package.info.categories>View,Vector,Symbology</gvsig.package.info.categories> |
|
21 |
<gvsig.package.info.javaVM>j1_8</gvsig.package.info.javaVM> |
|
22 |
<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-base-legends/pool</gvsig.package.info.poolURL> |
|
23 |
</properties> |
|
24 |
|
|
25 |
<dependencies> |
|
26 |
<dependency> |
|
27 |
<groupId>org.gvsig</groupId> |
|
28 |
<artifactId>org.gvsig.andami</artifactId> |
|
29 |
<scope>compile</scope> |
|
30 |
</dependency> |
|
31 |
<dependency> |
|
32 |
<groupId>org.gvsig</groupId> |
|
33 |
<artifactId>org.gvsig.legend.urbanhorizontalsignage.swing.api</artifactId> |
|
34 |
<scope>compile</scope> |
|
35 |
</dependency> |
|
36 |
<dependency> |
|
37 |
<groupId>org.gvsig</groupId> |
|
38 |
<artifactId>org.gvsig.legend.urbanhorizontalsignage.lib.api</artifactId> |
|
39 |
<scope>compile</scope> |
|
40 |
</dependency> |
|
41 |
<dependency> |
|
42 |
<groupId>org.gvsig</groupId> |
|
43 |
<artifactId>org.gvsig.legend.urbanhorizontalsignage.lib.impl</artifactId> |
|
44 |
<scope>runtime</scope> |
|
45 |
</dependency> |
|
46 |
<dependency> |
|
47 |
<groupId>org.gvsig</groupId> |
|
48 |
<artifactId>org.gvsig.legend.urbanhorizontalsignage.swing.impl</artifactId> |
|
49 |
<scope>runtime</scope> |
|
50 |
</dependency> |
|
51 |
<dependency> |
|
52 |
<groupId>org.gvsig</groupId> |
|
53 |
<artifactId>org.gvsig.app.mainplugin</artifactId> |
|
54 |
<scope>compile</scope> |
|
55 |
</dependency> |
|
56 |
</dependencies> |
|
57 |
</project> |
|
0 | 58 |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.impl/src/test/java/org/gvsig/legend/urbanhorizontalsignage/lib/impl/Test01CalculateGeometries.java | ||
---|---|---|
1 |
package org.gvsig.legend.urbanhorizontalsignage.lib.impl; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.geom.GeometryUtils; |
|
6 |
import org.gvsig.fmap.geom.primitive.Line; |
|
7 |
import org.gvsig.fmap.geom.primitive.Point; |
|
8 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData; |
|
9 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLocator; |
|
10 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
11 |
import org.slf4j.Logger; |
|
12 |
import org.slf4j.LoggerFactory; |
|
13 |
|
|
14 |
public class Test01CalculateGeometries extends TestCase { |
|
15 |
|
|
16 |
private static final Logger LOGGER = LoggerFactory.getLogger(Test01CalculateGeometries.class); |
|
17 |
|
|
18 |
public Test01CalculateGeometries(String testName) { |
|
19 |
super(testName); |
|
20 |
} |
|
21 |
|
|
22 |
@Override |
|
23 |
protected void setUp() throws Exception { |
|
24 |
super.setUp(); |
|
25 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
26 |
} |
|
27 |
|
|
28 |
@Override |
|
29 |
protected void tearDown() throws Exception { |
|
30 |
super.tearDown(); |
|
31 |
} |
|
32 |
|
|
33 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
34 |
// public void testHello() {} |
|
35 |
public void test01CalculateIntermediatePoint() { |
|
36 |
final String testid = "calculateIntermediatePoint"; |
|
37 |
Point p1 = GeometryUtils.createPoint(0,0); |
|
38 |
Point p2 = GeometryUtils.createPoint(10,0); |
|
39 |
|
|
40 |
DefaultUrbanHorizontalSignageManager uhsManager = (DefaultUrbanHorizontalSignageManager)UrbanHorizontalSignageLocator.getUrbanHorizontalSignageManager(); |
|
41 |
try { |
|
42 |
for (double lambda = 0; lambda <= 1; lambda += 0.1) { |
|
43 |
Point intermediatePoint = uhsManager.calculateIntermediatePoint(p1, p2, lambda); |
|
44 |
assertEquals(10*lambda, intermediatePoint.getCoordinateAt(0)); |
|
45 |
assertEquals(0.0, intermediatePoint.getCoordinateAt(1)); |
|
46 |
} |
|
47 |
} catch (Exception ex) { |
|
48 |
//TODO: |
|
49 |
fail(ex.getMessage()); |
|
50 |
} |
|
51 |
|
|
52 |
|
|
53 |
} |
|
54 |
|
|
55 |
public void test02SplitLine() throws Exception { |
|
56 |
final String testid = "splitLine"; |
|
57 |
|
|
58 |
Point p1 = GeometryUtils.createPoint(0,0); |
|
59 |
Point p2 = GeometryUtils.createPoint(10,0); |
|
60 |
Line line = GeometryUtils.createLine(p1, p2, 0); |
|
61 |
|
|
62 |
DefaultUrbanHorizontalSignageManager uhsManager = (DefaultUrbanHorizontalSignageManager)UrbanHorizontalSignageLocator.getUrbanHorizontalSignageManager(); |
|
63 |
// UrbanHorizontalSignageData data = uhsManager.createUrbanHorizontalSignageData(); |
|
64 |
|
|
65 |
// data.setWidth(20); |
|
66 |
// data.setContinuity(UrbanHorizontalSignageData.DEFAULT_CONTINUITY_VALUE); |
|
67 |
// data.setSegmentsLength(100); |
|
68 |
// data.setHolesLength(50); |
|
69 |
// data.setGapWith(10); |
|
70 |
// data.setSegmentsColor(Color.RED); |
|
71 |
// data.setHolesColor(Color.BLACK); |
|
72 |
// data.setRoundVertex(false); |
|
73 |
// data.setPaintHoles(true); |
|
74 |
|
|
75 |
DefaultUrbanHorizontalSignageManager.SplittedLine splittedLine = uhsManager.splitLine(line, 1, 0.5); |
|
76 |
|
|
77 |
List<Line> segments = splittedLine.getSegments(); |
|
78 |
List<Line> holes = splittedLine.getHoles(); |
|
79 |
|
|
80 |
assertEquals(7, segments.size()); |
|
81 |
assertEquals(6, holes.size()); |
|
82 |
|
|
83 |
double x = 0; |
|
84 |
for (Line segment : segments) { |
|
85 |
assertEquals(x, segment.getVertex(0).getX()); |
|
86 |
assertEquals(x+1.0, segment.getVertex(1).getX()); |
|
87 |
x += 1.50; |
|
88 |
} |
|
89 |
x = 1.0; |
|
90 |
for (Line hole : holes) { |
|
91 |
assertEquals(x, hole.getVertex(0).getX()); |
|
92 |
assertEquals(x+0.5, hole.getVertex(1).getX()); |
|
93 |
x += 1.50; |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
|
|
98 |
} |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.impl/src/main/resources/org/gvsig/legend/urbanhorizontalsignage/lib/impl/UrbanHorizontalSignagePersistence.xml | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<definitions> |
|
3 |
<version>1.0.0</version> |
|
4 |
<classes> |
|
5 |
<class name="DefaultUrbanHorizontalSignageLegend"> |
|
6 |
<extends> |
|
7 |
<class name="VectorialLegend" namespace="persistence"/> |
|
8 |
</extends> |
|
9 |
<fields> |
|
10 |
<field name="widthFieldName" type="String" defaultValue=""> |
|
11 |
<description></description> |
|
12 |
</field> |
|
13 |
<field name="continuityFieldName" type="String" defaultValue=""> |
|
14 |
<description></description> |
|
15 |
</field> |
|
16 |
<field name="segmentsColorFieldName" type="String" defaultValue=""> |
|
17 |
<description></description> |
|
18 |
</field> |
|
19 |
<field name="segmentsLengthFieldName" type="String" defaultValue=""> |
|
20 |
<description></description> |
|
21 |
</field> |
|
22 |
<field name="holesLengthFieldName" type="String" defaultValue=""> |
|
23 |
<description></description> |
|
24 |
</field> |
|
25 |
<field name="paintHolesFieldName" type="String" defaultValue=""> |
|
26 |
<description></description> |
|
27 |
</field> |
|
28 |
<field name="holesColorFieldName" type="String" defaultValue=""> |
|
29 |
<description></description> |
|
30 |
</field> |
|
31 |
<field name="roundVertexFieldName" type="String" defaultValue=""> |
|
32 |
<description></description> |
|
33 |
</field> |
|
34 |
<field name="gapWidth" type="Integer" defaultValue="15"> |
|
35 |
<description></description> |
|
36 |
</field> |
|
37 |
|
|
38 |
</fields> |
|
39 |
</class> |
|
40 |
|
|
41 |
|
|
42 |
<class name="UrbanHorizontalSignageSymbol"> |
|
43 |
<extends> |
|
44 |
<class name="Symbol" namespace="persistence"/> |
|
45 |
</extends> |
|
46 |
<fields> |
|
47 |
<field name="width" type="Double" defaultValue="0.15" mandatory="false"> |
|
48 |
<description></description> |
|
49 |
</field> |
|
50 |
<field name="continuity" type="Integer" defaultValue="1" mandatory="false"> |
|
51 |
<description></description> |
|
52 |
</field> |
|
53 |
<field name="segmentsColor" type="Object" ClassOfValue="java.awt.Color" defaultValue="blue" mandatory="false"> |
|
54 |
<description></description> |
|
55 |
</field> |
|
56 |
<field name="segmentsLength" type="Double" defaultValue="0.5" mandatory="false"> |
|
57 |
<description></description> |
|
58 |
</field> |
|
59 |
<field name="holesColor" type="Object" ClassOfValue="java.awt.Color" defaultValue="black" mandatory="false"> |
|
60 |
<description></description> |
|
61 |
</field> |
|
62 |
<field name="holesLength" type="Double" defaultValue="0.5" mandatory="false"> |
|
63 |
<description></description> |
|
64 |
</field> |
|
65 |
<field name="paintHoles" type="Boolean" defaultValue="false" mandatory="false"> |
|
66 |
<description></description> |
|
67 |
</field> |
|
68 |
<field name="gapWidth" type="Double" defaultValue="0.15" mandatory="false"> |
|
69 |
<description></description> |
|
70 |
</field> |
|
71 |
<field name="roundVertex" type="Boolean" defaultValue="false" mandatory="false"> |
|
72 |
<description></description> |
|
73 |
</field> |
|
74 |
<field name="transparency" type="Double" defaultValue="1.0" mandatory="false"> |
|
75 |
<description></description> |
|
76 |
</field> |
|
77 |
<field name="mustDrawOriginalGeometry" type="Boolean" defaultValue="false" mandatory="false"> |
|
78 |
<description></description> |
|
79 |
</field> |
|
80 |
<field name="colorForOriginalGeometry" type="Object" ClassOfValue="java.awt.Color" defaultValue="yellow" mandatory="false"> |
|
81 |
<description></description> |
|
82 |
</field> |
|
83 |
</fields> |
|
84 |
</class> |
|
85 |
|
|
86 |
</classes> |
|
87 |
</definitions> |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.legend.urbanhorizontalsignage.lib.impl.UrbanHorizontalSignageLibraryImpl |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.impl/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/impl/UrbanHorizontalSignageSymbol.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.legend.urbanhorizontalsignage.lib.impl; |
|
25 |
|
|
26 |
import java.awt.Color; |
|
27 |
import java.awt.Graphics2D; |
|
28 |
import java.awt.Rectangle; |
|
29 |
import java.awt.geom.AffineTransform; |
|
30 |
import java.util.concurrent.Callable; |
|
31 |
import org.gvsig.compat.print.PrintAttributes; |
|
32 |
import org.gvsig.fmap.dal.feature.Feature; |
|
33 |
import org.gvsig.fmap.geom.Geometry; |
|
34 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
35 |
import org.gvsig.fmap.geom.GeometryManager; |
|
36 |
import org.gvsig.fmap.geom.GeometryUtils; |
|
37 |
import org.gvsig.fmap.geom.aggregate.MultiPolygon; |
|
38 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
39 |
import org.gvsig.fmap.geom.primitive.Line; |
|
40 |
import org.gvsig.fmap.geom.primitive.Point; |
|
41 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
42 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
43 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
44 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
45 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol_v2; |
|
46 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException; |
|
47 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager; |
|
48 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData; |
|
49 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_CONT_DISC; |
|
50 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_DISC; |
|
51 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_DISC_CONT; |
|
52 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_DISC_DISC; |
|
53 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLocator; |
|
54 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageManager; |
|
55 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.AbstractSymbol; |
|
56 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.CartographicSupportToolkit; |
|
57 |
import org.gvsig.tools.persistence.PersistentState; |
|
58 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
59 |
import org.gvsig.tools.swing.api.TransparencySupport; |
|
60 |
import org.gvsig.tools.task.Cancellable; |
|
61 |
import org.slf4j.Logger; |
|
62 |
import org.slf4j.LoggerFactory; |
|
63 |
|
|
64 |
public class UrbanHorizontalSignageSymbol extends AbstractSymbol implements ISymbol_v2, TransparencySupport { |
|
65 |
|
|
66 |
private static final Logger LOG = LoggerFactory.getLogger(UrbanHorizontalSignageSymbol.class); |
|
67 |
private static final String SYMBOL_NAME = "UrbanHorizontalSignageSymbol"; |
|
68 |
private static final String URBAN_HORIZONTAL_SIGNAGE_SYMBOL_PERSISTENCE_DEFINITION_NAME = "UrbanHorizontalSignageSymbol"; |
|
69 |
|
|
70 |
private static final String FIELD_WIDTH = "width"; |
|
71 |
private static final String FIELD_CONTINUITY = "continuity"; |
|
72 |
private static final String FIELD_SEGMENTS_COLOR = "segmentsColor"; |
|
73 |
private static final String FIELD_SEGMENTS_LENGTH = "segmentsLength"; |
|
74 |
private static final String FIELD_HOLES_COLOR = "holesColor"; |
|
75 |
private static final String FIELD_HOLES_LENGTH = "holesLength"; |
|
76 |
private static final String FIELD_PAINT_HOLES = "paintHoles"; |
|
77 |
private static final String FIELD_GAP_WIDTH = "gapWidth"; |
|
78 |
private static final String FIELD_ROUND_VERTEX = "roundVertex"; |
|
79 |
private static final String FIELD_SEGMENTS_GEOMETRY = "segmentsGeometry"; |
|
80 |
private static final String FIELD_HOLES_GEOMETRY = "holesGeometry"; |
|
81 |
private static final String FIELD_TRANSPARENCY = "transparency"; |
|
82 |
private static final String FIELD_MUST_DRAW_ORIGINAL_GEOMETRY = "mustDrawOriginalGeometry"; |
|
83 |
private static final String FIELD_COLOR_FOR_ORIGINAL_GEOMETRY = "colorForOriginalGeometry"; |
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
// private static final String FIELD_SYMBOL_FOR_SELECTION = "symbolForSelection"; |
|
88 |
private UrbanHorizontalSignageData data; |
|
89 |
|
|
90 |
transient private UrbanHorizontalSignageSymbol symbolForSelection; |
|
91 |
|
|
92 |
private boolean mustDrawOriginalGeometry; |
|
93 |
private Color colorForOriginalGeometry; |
|
94 |
private double cartographicSize; |
|
95 |
private double transparency; //[0.0, 1.0] |
|
96 |
|
|
97 |
public UrbanHorizontalSignageSymbol() { |
|
98 |
super(); |
|
99 |
this.mustDrawOriginalGeometry = false; |
|
100 |
this.transparency = 1.0; |
|
101 |
} |
|
102 |
|
|
103 |
public void setData(UrbanHorizontalSignageData data) { |
|
104 |
this.data = data; |
|
105 |
} |
|
106 |
|
|
107 |
public UrbanHorizontalSignageData getData() { |
|
108 |
return data; |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* Sets the transparency for symbol. The valid values are in [0.0, 1.0] |
|
113 |
* |
|
114 |
* @param transparency |
|
115 |
*/ |
|
116 |
@Override |
|
117 |
public void setTransparency(double transparency) { |
|
118 |
if(transparency < 0 || transparency > 1.0){ |
|
119 |
throw new IllegalArgumentException("Transparency value must be in [0.0, 1.0] ("+transparency+")"); |
|
120 |
} |
|
121 |
this.transparency = transparency; |
|
122 |
} |
|
123 |
|
|
124 |
@Override |
|
125 |
public double getTransparency() { |
|
126 |
return transparency; |
|
127 |
} |
|
128 |
|
|
129 |
@Override |
|
130 |
public ISymbol getSymbolForSelection() { |
|
131 |
if (symbolForSelection == null) { |
|
132 |
symbolForSelection = (UrbanHorizontalSignageSymbol) cloneForSelection(); |
|
133 |
symbolForSelection.mustDrawOriginalGeometry = true; |
|
134 |
} else { |
|
135 |
symbolForSelection.setColor(MapContext.getSelectionColor()); |
|
136 |
} |
|
137 |
return symbolForSelection; |
|
138 |
} |
|
139 |
|
|
140 |
@Override |
|
141 |
public void draw(Graphics2D g, AffineTransform affineTransform, |
|
142 |
Geometry originalGeometry, Feature feature, Cancellable cancel) { |
|
143 |
|
|
144 |
if (true) { |
|
145 |
// Esto deberia ser para optimizar el pintado de |
|
146 |
// geometrias grandes. |
|
147 |
try { |
|
148 |
Geometry env = originalGeometry.getEnvelope().getGeometry(); |
|
149 |
env.transform(affineTransform); |
|
150 |
Envelope env2 = env.getEnvelope(); |
|
151 |
if (env2.getLength(0) < 1.5 && env2.getLength(1) < 1.5) { |
|
152 |
Color color = data.getSegmentsColor(); |
|
153 |
Color transparentColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int)(transparency*color.getAlpha())); |
|
154 |
g.setColor(transparentColor); |
|
155 |
Point upperCorner = env2.getUpperCorner(); |
|
156 |
int x = (int) upperCorner.getX(); |
|
157 |
int y = (int) upperCorner.getY(); |
|
158 |
g.drawLine(x, y, x, y); |
|
159 |
return; |
|
160 |
} |
|
161 |
} catch (Exception ex) { |
|
162 |
LOG.warn("Error optimizing the drawing of the geometry. Continues with normal drawing.", ex); |
|
163 |
// Do nothing, continue with the draw of the original geometry |
|
164 |
} |
|
165 |
} |
|
166 |
|
|
167 |
UrbanHorizontalSignageManager uhsManager = UrbanHorizontalSignageLocator.getUrbanHorizontalSignageManager(); |
|
168 |
uhsManager.calculateGeometries(originalGeometry, data); |
|
169 |
|
|
170 |
MultiPolygon geom = data.getSegmentsGeometry(); |
|
171 |
if (geom != null && geom.getPrimitivesNumber() > 0) { |
|
172 |
Color color = data.getSegmentsColor(); |
|
173 |
Color transparentColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int)(transparency*color.getAlpha())); |
|
174 |
g.setColor(transparentColor); |
|
175 |
g.fill(geom.getShape(affineTransform)); |
|
176 |
} |
|
177 |
|
|
178 |
switch (data.getContinuity()) { |
|
179 |
case CONTINUITY_MODE_CONT_DISC: |
|
180 |
case CONTINUITY_MODE_DISC_CONT: |
|
181 |
case CONTINUITY_MODE_DISC: |
|
182 |
case CONTINUITY_MODE_DISC_DISC: |
|
183 |
if (data.isPaintHoles()) { |
|
184 |
geom = data.getHolesGeometry(); |
|
185 |
if (geom != null && geom.getPrimitivesNumber() > 0) { |
|
186 |
Color color = data.getHolesColor(); |
|
187 |
Color transparentColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int)(transparency*color.getAlpha())); |
|
188 |
g.setColor(transparentColor); |
|
189 |
g.fill(geom.getShape(affineTransform)); |
|
190 |
} |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
194 |
//For debug purposse only |
|
195 |
if(mustDrawOriginalGeometry){ |
|
196 |
g.setColor(getColor()); |
|
197 |
g.draw(originalGeometry.getShape(affineTransform)); |
|
198 |
} |
|
199 |
|
|
200 |
} |
|
201 |
|
|
202 |
@Override |
|
203 |
public int getOnePointRgb() { |
|
204 |
return data.getSegmentsColor().getRGB(); |
|
205 |
} |
|
206 |
|
|
207 |
@Override |
|
208 |
public void drawInsideRectangle(Graphics2D g, |
|
209 |
AffineTransform scaleInstance, Rectangle r, PrintAttributes properties) throws SymbolDrawingException { |
|
210 |
|
|
211 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
212 |
|
|
213 |
final int hGap = (int) (r.getWidth() * 0.1); // the left and right margins |
|
214 |
final int vPos = 1; // the top and bottom margins |
|
215 |
final int splitCount = 3; // number of lines |
|
216 |
final int splitHSize = (r.width - hGap - hGap) / splitCount; |
|
217 |
int hPos = hGap; |
|
218 |
boolean swap = false; |
|
219 |
|
|
220 |
Line geom = GeometryUtils.createLine(Geometry.SUBTYPES.GEOM2D); |
|
221 |
geom.addVertex(r.x + hPos, r.y + r.height - vPos); |
|
222 |
|
|
223 |
for (int i = 0; i < splitCount; i++) { |
|
224 |
swap = !swap; |
|
225 |
geom.addVertex(r.x + hPos + splitHSize, (swap ? vPos : r.height - vPos) + r.y); |
|
226 |
hPos += splitHSize; |
|
227 |
} |
|
228 |
|
|
229 |
try { |
|
230 |
if (properties == null) { |
|
231 |
draw(g, new AffineTransform(), geom, null, null); |
|
232 |
} else { |
|
233 |
print(g, new AffineTransform(), geom, properties); |
|
234 |
} |
|
235 |
} catch (Exception e) { |
|
236 |
throw new SymbolDrawingException(SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS); |
|
237 |
} |
|
238 |
|
|
239 |
} |
|
240 |
|
|
241 |
@Override |
|
242 |
public Object clone() throws CloneNotSupportedException { |
|
243 |
UrbanHorizontalSignageSymbol copy = (UrbanHorizontalSignageSymbol) super.clone(); |
|
244 |
|
|
245 |
if (symbolForSelection != null) { |
|
246 |
copy.symbolForSelection = (UrbanHorizontalSignageSymbol) symbolForSelection |
|
247 |
.clone(); |
|
248 |
} |
|
249 |
|
|
250 |
return copy; |
|
251 |
} |
|
252 |
|
|
253 |
@Override |
|
254 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
255 |
// Set parent style properties |
|
256 |
super.loadFromState(state); |
|
257 |
|
|
258 |
UrbanHorizontalSignageData data = new DefaultUrbanHorizontalSignageData(); |
|
259 |
data.setWidth(state.getDouble(FIELD_WIDTH, UrbanHorizontalSignageData.DEFAULT_WIDTH_VALUE)); |
|
260 |
data.setContinuity(state.getInt(FIELD_CONTINUITY, UrbanHorizontalSignageData.DEFAULT_CONTINUITY_VALUE)); |
|
261 |
|
|
262 |
Color color = (Color) state.get(FIELD_SEGMENTS_COLOR); |
|
263 |
data.setSegmentsColor(color != null ? color : UrbanHorizontalSignageData.DEFAULT_SEGMENT_COLOR_VALUE); |
|
264 |
|
|
265 |
data.setSegmentsLength(state.getDouble(FIELD_SEGMENTS_LENGTH, UrbanHorizontalSignageData.DEFAULT_SEGMENT_LENGTH_VALUE)); |
|
266 |
|
|
267 |
color = (Color) state.get(FIELD_HOLES_COLOR); |
|
268 |
data.setHolesColor(color != null ? color : UrbanHorizontalSignageData.DEFAULT_HOLES_COLOR_VALUE); |
|
269 |
|
|
270 |
data.setHolesLength(state.getDouble(FIELD_HOLES_LENGTH, UrbanHorizontalSignageData.DEFAULT_HOLES_LENGTH_VALUE)); |
|
271 |
data.setGapWidth(state.getDouble(FIELD_GAP_WIDTH, UrbanHorizontalSignageData.DEFAULT_GAP_WIDTH_VALUE)); |
|
272 |
data.setRoundVertex(state.getBoolean(FIELD_ROUND_VERTEX, UrbanHorizontalSignageData.DEFAULT_ROUND_VERTEX_VALUE)); |
|
273 |
|
|
274 |
this.transparency = state.getDouble(FIELD_TRANSPARENCY, 1.0); |
|
275 |
this.mustDrawOriginalGeometry = state.getBoolean(FIELD_MUST_DRAW_ORIGINAL_GEOMETRY, false); |
|
276 |
color = (Color) state.get(FIELD_COLOR_FOR_ORIGINAL_GEOMETRY); |
|
277 |
this.colorForOriginalGeometry = color != null ? color : MapContext.getSelectionColor(); |
|
278 |
this.data = data; |
|
279 |
|
|
280 |
} |
|
281 |
|
|
282 |
@Override |
|
283 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
284 |
// Save parent fill symbol properties |
|
285 |
super.saveToState(state); |
|
286 |
|
|
287 |
// Save own properties |
|
288 |
|
|
289 |
if(data != null){ |
|
290 |
state.set(FIELD_WIDTH, data.getWidth()); |
|
291 |
state.set(FIELD_CONTINUITY, data.getContinuity()); |
|
292 |
state.set(FIELD_SEGMENTS_COLOR, data.getSegmentsColor()); |
|
293 |
state.set(FIELD_SEGMENTS_LENGTH, data.getSegmentsLength()); |
|
294 |
state.set(FIELD_HOLES_COLOR, data.getHolesColor()); |
|
295 |
state.set(FIELD_HOLES_LENGTH, data.getHolesLength()); |
|
296 |
state.set(FIELD_PAINT_HOLES, data.isPaintHoles()); |
|
297 |
state.set(FIELD_GAP_WIDTH, data.getGapWidth()); |
|
298 |
state.set(FIELD_ROUND_VERTEX, data.isRoundVertex()); |
|
299 |
} |
|
300 |
state.set(FIELD_MUST_DRAW_ORIGINAL_GEOMETRY, mustDrawOriginalGeometry); |
|
301 |
state.set(FIELD_COLOR_FOR_ORIGINAL_GEOMETRY, colorForOriginalGeometry); |
|
302 |
state.set(FIELD_TRANSPARENCY, this.getTransparency()); |
|
303 |
} |
|
304 |
|
|
305 |
@Override |
|
306 |
public void getPixExtentPlus(Geometry geom, float[] distances, ViewPort viewPort, int dpi) { |
|
307 |
float cs = (float) getCartographicSize(viewPort, dpi, geom); |
|
308 |
// TODO and add the line offset |
|
309 |
distances[0] = cs; |
|
310 |
distances[1] = cs; |
|
311 |
} |
|
312 |
|
|
313 |
@Override |
|
314 |
public int getSymbolType() { |
|
315 |
return Geometry.TYPES.CURVE; |
|
316 |
} |
|
317 |
|
|
318 |
@Override |
|
319 |
public boolean isSuitableFor(Geometry geom) { |
|
320 |
return geom.getGeometryType().isTypeOf(Geometry.TYPES.CURVE); |
|
321 |
} |
|
322 |
|
|
323 |
@Override |
|
324 |
public Color getColor() { |
|
325 |
return this.colorForOriginalGeometry; |
|
326 |
} |
|
327 |
|
|
328 |
@Override |
|
329 |
public void setColor(Color color) { |
|
330 |
this.colorForOriginalGeometry = color; |
|
331 |
} |
|
332 |
|
|
333 |
@Override |
|
334 |
public void print(Graphics2D g, AffineTransform at, Geometry shape, PrintAttributes properties) { |
|
335 |
draw(g, at, shape, null, null); |
|
336 |
// double originalSize = getLineWidth(); |
|
337 |
// double size=originalSize; |
|
338 |
// // scale it to size |
|
339 |
// int pq = properties.getPrintQuality(); |
|
340 |
// if (pq == PrintAttributes.PRINT_QUALITY_NORMAL){ |
|
341 |
// size *= (double) 300/72; |
|
342 |
// }else if (pq == PrintAttributes.PRINT_QUALITY_HIGH){ |
|
343 |
// size *= (double) 600/72; |
|
344 |
// }else if (pq == PrintAttributes.PRINT_QUALITY_DRAFT){ |
|
345 |
// // size *= 72/72; // (which is the same than doing nothing) |
|
346 |
// } |
|
347 |
// setLineWidth(size); |
|
348 |
// draw(g,at,geom,null, null); |
|
349 |
// setLineWidth(originalSize); |
|
350 |
} |
|
351 |
|
|
352 |
@Override |
|
353 |
public double toCartographicSize(ViewPort viewPort, double dpi, Geometry geom) { |
|
354 |
double oldSize = getData().getWidth(); |
|
355 |
setCartographicSize(getCartographicSize( |
|
356 |
viewPort, |
|
357 |
dpi, |
|
358 |
geom), |
|
359 |
geom); |
|
360 |
return oldSize; |
|
361 |
|
|
362 |
// return 0; |
|
363 |
} |
|
364 |
|
|
365 |
@Override |
|
366 |
public void setCartographicSize(double cartographicSize, Geometry geom) { |
|
367 |
//DO NOTHING |
|
368 |
this.getData().setWidth(cartographicSize); |
|
369 |
} |
|
370 |
|
|
371 |
@Override |
|
372 |
public double getCartographicSize(ViewPort viewPort, double dpi, Geometry geom) { |
|
373 |
return CartographicSupportToolkit.getCartographicLength( |
|
374 |
this, |
|
375 |
getData().getWidth(), |
|
376 |
viewPort, |
|
377 |
dpi |
|
378 |
); |
|
379 |
|
|
380 |
// return 0; |
|
381 |
} |
|
382 |
|
|
383 |
// public static class RegisterPersistence implements Callable { |
|
384 |
// |
|
385 |
// @Override |
|
386 |
// public Object call() throws Exception { |
|
387 |
// PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
388 |
// if (manager.getDefinition(URBAN_HORIZONTAL_SIGNAGE_SYMBOL_PERSISTENCE_DEFINITION_NAME) == null) { |
|
389 |
// DynStruct definition = manager.addDefinition( |
|
390 |
// UrbanHorizontalSignageSymbol.class, |
|
391 |
// URBAN_HORIZONTAL_SIGNAGE_SYMBOL_PERSISTENCE_DEFINITION_NAME, |
|
392 |
// URBAN_HORIZONTAL_SIGNAGE_SYMBOL_PERSISTENCE_DEFINITION_NAME + " Persistence definition", |
|
393 |
// null, |
|
394 |
// null |
|
395 |
// ); |
|
396 |
// // Extend the LineSymbol base definition |
|
397 |
// definition.extend(manager.getDefinition(AbstractSymbol.SYMBOL_PERSISTENCE_DEFINITION_NAME)); |
|
398 |
// |
|
399 |
// definition.addDynFieldDouble(FIELD_WIDTH).setMandatory(false); |
|
400 |
// definition.addDynFieldInt(FIELD_CONTINUITY).setMandatory(false); |
|
401 |
// definition.addDynFieldObject(FIELD_SEGMENTS_COLOR).setClassOfValue(Color.class).setMandatory(false); |
|
402 |
// definition.addDynFieldDouble(FIELD_SEGMENTS_LENGTH).setMandatory(false); |
|
403 |
// definition.addDynFieldObject(FIELD_HOLES_COLOR).setClassOfValue(Color.class).setMandatory(false); |
|
404 |
// definition.addDynFieldDouble(FIELD_HOLES_LENGTH).setMandatory(false); |
|
405 |
// definition.addDynFieldBoolean(FIELD_PAINT_HOLES).setMandatory(false); |
|
406 |
// definition.addDynFieldDouble(FIELD_GAP_WIDTH).setMandatory(false); |
|
407 |
// definition.addDynFieldBoolean(FIELD_ROUND_VERTEX).setMandatory(false); |
|
408 |
// definition.addDynFieldDouble(FIELD_TRANSPARENCY).setMandatory(false); |
|
409 |
// definition.addDynFieldBoolean(FIELD_MUST_DRAW_ORIGINAL_GEOMETRY).setMandatory(false); |
|
410 |
// definition.addDynFieldObject(FIELD_COLOR_FOR_ORIGINAL_GEOMETRY).setClassOfValue(Color.class).setMandatory(false); |
|
411 |
// } |
|
412 |
// return Boolean.TRUE; |
|
413 |
// } |
|
414 |
// |
|
415 |
// } |
|
416 |
|
|
417 |
public static class RegisterSymbol implements Callable { |
|
418 |
|
|
419 |
@Override |
|
420 |
public Object call() throws Exception { |
|
421 |
int[] shapeTypes; |
|
422 |
SymbolManager manager = MapContextLocator.getSymbolManager(); |
|
423 |
|
|
424 |
shapeTypes = new int[]{Geometry.TYPES.CURVE, Geometry.TYPES.ARC, |
|
425 |
Geometry.TYPES.MULTICURVE, Geometry.TYPES.CIRCUMFERENCE, |
|
426 |
Geometry.TYPES.PERIELLIPSE, Geometry.TYPES.SPLINE, |
|
427 |
Geometry.TYPES.LINE, Geometry.TYPES.MULTILINE}; |
|
428 |
manager.registerSymbol(SYMBOL_NAME, |
|
429 |
shapeTypes, |
|
430 |
UrbanHorizontalSignageSymbol.class); |
|
431 |
|
|
432 |
return Boolean.TRUE; |
|
433 |
} |
|
434 |
|
|
435 |
} |
|
436 |
|
|
437 |
} |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.impl/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/impl/UrbanHorizontalSignageLibraryImpl.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright ? 2007-2015 gvSIG Association |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
|
|
25 |
package org.gvsig.legend.urbanhorizontalsignage.lib.impl; |
|
26 |
|
|
27 |
import java.io.InputStream; |
|
28 |
import java.util.Map; |
|
29 |
import org.gvsig.fmap.mapcontext.MapContextLibrary; |
|
30 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
31 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
32 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLibrary; |
|
33 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLocator; |
|
34 |
import org.gvsig.symbology.impl.SymbologyDefaultImplLibrary; |
|
35 |
import org.gvsig.tools.ToolsLocator; |
|
36 |
import org.gvsig.tools.dynobject.DynStruct; |
|
37 |
import org.gvsig.tools.library.AbstractLibrary; |
|
38 |
import org.gvsig.tools.library.LibraryException; |
|
39 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
40 |
|
|
41 |
public class UrbanHorizontalSignageLibraryImpl extends AbstractLibrary { |
|
42 |
|
|
43 |
@Override |
|
44 |
public void doRegistration() { |
|
45 |
registerAsImplementationOf(UrbanHorizontalSignageLibrary.class); |
|
46 |
this.require(MapContextLibrary.class); |
|
47 |
this.require(SymbologyDefaultImplLibrary.class); |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
protected void doInitialize() throws LibraryException { |
|
52 |
UrbanHorizontalSignageLocator.registerUrbanHorizontalSignageManager(DefaultUrbanHorizontalSignageManager.class); |
|
53 |
MapContextManager mcmanager = MapContextLocator.getMapContextManager(); |
|
54 |
mcmanager.registerLegend("UrbanHorizontalSignageLegend", DefaultUrbanHorizontalSignageLegend.class); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
protected void doPostInitialize() throws LibraryException { |
|
59 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
|
60 |
InputStream is = this.getClass().getResourceAsStream("UrbanHorizontalSignagePersistence.xml"); |
|
61 |
Map<String,DynStruct> definitions; |
|
62 |
try { |
|
63 |
definitions = ToolsLocator.getDynObjectManager().importDynClassDefinitions(is, this.getClass().getClassLoader()); |
|
64 |
} catch (Exception ex) { |
|
65 |
throw new LibraryException(this.getClass(), ex); |
|
66 |
} |
|
67 |
|
|
68 |
persistenceManager.addDefinition( |
|
69 |
DefaultUrbanHorizontalSignageLegend.class, |
|
70 |
"DefaultUrbanHorizontalSignageLegend", |
|
71 |
definitions, |
|
72 |
null, |
|
73 |
null); |
|
74 |
persistenceManager.addDefinition( |
|
75 |
UrbanHorizontalSignageSymbol.class, |
|
76 |
"UrbanHorizontalSignageSymbol", |
|
77 |
definitions, |
|
78 |
null, |
|
79 |
null); |
|
80 |
} |
|
81 |
|
|
82 |
} |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.impl/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/impl/DefaultUrbanHorizontalSignageData.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.legend.urbanhorizontalsignage.lib.impl; |
|
7 |
|
|
8 |
import java.awt.Color; |
|
9 |
import org.gvsig.fmap.geom.Geometry; |
|
10 |
import org.gvsig.fmap.geom.aggregate.MultiPolygon; |
|
11 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData; |
|
12 |
|
|
13 |
/** |
|
14 |
* |
|
15 |
* @author fdiaz |
|
16 |
*/ |
|
17 |
public class DefaultUrbanHorizontalSignageData implements UrbanHorizontalSignageData { |
|
18 |
|
|
19 |
private double width; |
|
20 |
private int continuity; |
|
21 |
private Color segmentsColor; |
|
22 |
private double segmentsLength; |
|
23 |
private MultiPolygon segmentsGeometry; |
|
24 |
private boolean isPaintHoles; |
|
25 |
private Color holesColor; |
|
26 |
private double holesLength; |
|
27 |
private MultiPolygon holesGeometry; |
|
28 |
private double gapWidth; |
|
29 |
private Geometry originalGeometry; |
|
30 |
private boolean roundVertex; |
|
31 |
|
|
32 |
public DefaultUrbanHorizontalSignageData() { |
|
33 |
width = DEFAULT_WIDTH_VALUE; |
|
34 |
continuity = DEFAULT_CONTINUITY_VALUE; |
|
35 |
segmentsColor = DEFAULT_SEGMENT_COLOR_VALUE; |
|
36 |
segmentsLength = DEFAULT_SEGMENT_LENGTH_VALUE; |
|
37 |
isPaintHoles = DEFAULT_PAINT_HOLES_VALUE; |
|
38 |
holesColor = DEFAULT_HOLES_COLOR_VALUE; |
|
39 |
holesLength = DEFAULT_HOLES_LENGTH_VALUE; |
|
40 |
gapWidth = DEFAULT_GAP_WIDTH_VALUE; |
|
41 |
roundVertex = DEFAULT_ROUND_VERTEX_VALUE; |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public double getWidth() { |
|
46 |
return this.width; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public void setWidth(double value) { |
|
51 |
this.width = value; |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public int getContinuity() { |
|
56 |
return this.continuity; |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public void setContinuity(int value) { |
|
61 |
this.continuity = value; |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public Color getSegmentsColor() { |
|
66 |
return this.segmentsColor; |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public void setSegmentsColor(Color value) { |
|
71 |
this.segmentsColor = value; |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
75 |
public double getSegmentsLength() { |
|
76 |
return this.segmentsLength; |
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
public void setSegmentsLength(double value) { |
|
81 |
this.segmentsLength = value; |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public MultiPolygon getSegmentsGeometry() { |
|
86 |
return this.segmentsGeometry; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public void setSegmentsGeometry(MultiPolygon value) { |
|
91 |
this.segmentsGeometry = value; |
|
92 |
} |
|
93 |
|
|
94 |
@Override |
|
95 |
public boolean isPaintHoles() { |
|
96 |
return this.isPaintHoles; |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public void setPaintHoles(boolean value) { |
|
101 |
this.isPaintHoles = value; |
|
102 |
} |
|
103 |
|
|
104 |
@Override |
|
105 |
public Color getHolesColor() { |
|
106 |
return this.holesColor; |
|
107 |
} |
|
108 |
|
|
109 |
@Override |
|
110 |
public void setHolesColor(Color value) { |
|
111 |
this.holesColor = value; |
|
112 |
} |
|
113 |
|
|
114 |
@Override |
|
115 |
public double getHolesLength() { |
|
116 |
return this.holesLength; |
|
117 |
} |
|
118 |
|
|
119 |
@Override |
|
120 |
public void setHolesLength(double value) { |
|
121 |
this.holesLength = value; |
|
122 |
} |
|
123 |
|
|
124 |
@Override |
|
125 |
public MultiPolygon getHolesGeometry() { |
|
126 |
return this.holesGeometry; |
|
127 |
} |
|
128 |
|
|
129 |
@Override |
|
130 |
public void setHolesGeometry(MultiPolygon value) { |
|
131 |
this.holesGeometry = value; |
|
132 |
} |
|
133 |
|
|
134 |
@Override |
|
135 |
public double getGapWidth() { |
|
136 |
return this.gapWidth; |
|
137 |
} |
|
138 |
|
|
139 |
@Override |
|
140 |
public void setGapWidth(double value) { |
|
141 |
this.gapWidth = value; |
|
142 |
} |
|
143 |
|
|
144 |
public boolean isRoundVertex(){ |
|
145 |
return this.roundVertex; |
|
146 |
} |
|
147 |
|
|
148 |
public void setRoundVertex(boolean value){ |
|
149 |
this.roundVertex = value; |
|
150 |
} |
|
151 |
|
|
152 |
|
|
153 |
} |
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.1/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.impl/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/impl/DefaultUrbanHorizontalSignageManager.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2015 gvSIG Association |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.legend.urbanhorizontalsignage.lib.impl; |
|
24 |
|
|
25 |
import java.util.ArrayList; |
|
26 |
import java.util.Iterator; |
|
27 |
import java.util.List; |
|
28 |
import org.apache.commons.lang3.tuple.MutablePair; |
|
29 |
import org.gvsig.fmap.geom.Geometry; |
|
30 |
import static org.gvsig.fmap.geom.Geometry.JOIN_STYLE_BEVEL; |
|
31 |
import static org.gvsig.fmap.geom.Geometry.JOIN_STYLE_MITRE; |
|
32 |
import static org.gvsig.fmap.geom.Geometry.JOIN_STYLE_ROUND; |
|
33 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
34 |
import org.gvsig.fmap.geom.GeometryManager; |
|
35 |
import org.gvsig.fmap.geom.aggregate.MultiLine; |
|
36 |
import org.gvsig.fmap.geom.aggregate.MultiPolygon; |
|
37 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
38 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
39 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
40 |
import org.gvsig.fmap.geom.primitive.Line; |
|
41 |
import org.gvsig.fmap.geom.primitive.Point; |
|
42 |
import org.gvsig.fmap.geom.primitive.Primitive; |
|
43 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
44 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData; |
|
45 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_CONT; |
|
46 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_CONT_CONT; |
|
47 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_CONT_DISC; |
|
48 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_DISC; |
|
49 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_DISC_CONT; |
|
50 |
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData.CONTINUITY_MODE_DISC_DISC; |
|
51 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLegend; |
|
52 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageManager; |
Also available in: Unified diff