Revision 761
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/DefaultVectorExtrusionLoaderFactory.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl; |
|
2 |
|
|
3 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
4 |
import org.gvsig.view3d.lib.api.loader.Loader; |
|
5 |
import org.gvsig.view3d.lib.api.loader.LoaderFactory; |
|
6 |
import org.gvsig.view3d.lib.api.loader.LoaderParameters; |
|
7 |
import org.gvsig.view3d.vector.lib.api.VectorExtrusionLoaderParameters; |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
12 |
* |
|
13 |
*/ |
|
14 |
public class DefaultVectorExtrusionLoaderFactory implements LoaderFactory { |
|
15 |
|
|
16 |
@Override |
|
17 |
public String getName() { |
|
18 |
return VectorExtrusionLoaderParameters.FACTORY_NAME; |
|
19 |
} |
|
20 |
|
|
21 |
@Override |
|
22 |
public LoaderParameters createParameters(FLayer layer) { |
|
23 |
return new DefaultVectorExtrusionLoaderParameters(layer); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
public Loader createLoader() { |
|
28 |
return new DefaultVectorExtrusionLoader(); |
|
29 |
} |
|
30 |
|
|
31 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/DefaultVectorLoader.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl; |
|
2 |
|
|
3 |
import org.gvsig.view3d.lib.api.exception.LoadException; |
|
4 |
import org.gvsig.view3d.lib.api.loader.Loader; |
|
5 |
import org.gvsig.view3d.lib.api.loader.LoaderParameters; |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
10 |
* |
|
11 |
*/ |
|
12 |
public class DefaultVectorLoader implements Loader{ |
|
13 |
|
|
14 |
@Override |
|
15 |
public Object load(LoaderParameters parameters) throws LoadException { |
|
16 |
// TODO Auto-generated method stub |
|
17 |
return null; |
|
18 |
} |
|
19 |
|
|
20 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/DefaultVectorExtrusionLoader.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl; |
|
2 |
|
|
3 |
import org.gvsig.view3d.lib.api.exception.LoadException; |
|
4 |
import org.gvsig.view3d.lib.api.loader.Loader; |
|
5 |
import org.gvsig.view3d.lib.api.loader.LoaderParameters; |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
10 |
* |
|
11 |
*/ |
|
12 |
public class DefaultVectorExtrusionLoader implements Loader { |
|
13 |
|
|
14 |
@Override |
|
15 |
public Object load(LoaderParameters parameters) throws LoadException { |
|
16 |
// TODO Auto-generated method stub |
|
17 |
return null; |
|
18 |
} |
|
19 |
|
|
20 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/DefaultVectorLoaderParameters.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
|
|
5 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
6 |
import org.gvsig.tools.ToolsLocator; |
|
7 |
import org.gvsig.tools.dynobject.DynStruct; |
|
8 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
9 |
import org.gvsig.tools.persistence.PersistentState; |
|
10 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
11 |
import org.gvsig.view3d.lib.api.loader.AbstractLoaderParameters; |
|
12 |
import org.gvsig.view3d.vector.lib.api.VectorElevationMode; |
|
13 |
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters; |
|
14 |
|
|
15 |
/** |
|
16 |
* |
|
17 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
18 |
* |
|
19 |
*/ |
|
20 |
public class DefaultVectorLoaderParameters extends AbstractLoaderParameters implements VectorLoaderParameters { |
|
21 |
|
|
22 |
public static final String PARAMETERS_DEFINITION_NAME = "VectorLoaderParameters"; |
|
23 |
public static final String PARAMETERS_DEFINITION_DESCRIPTION = "Parameters that defines vector load mode"; |
|
24 |
|
|
25 |
public static final String VECTOR_ELEVATION_MODEL_FIELD_NAME = "vectorElevationModel"; |
|
26 |
public static final String DEFAULT_COLOR_FIELD_NAME = "defaultColor"; |
|
27 |
public static final String CONSTANT_HEIGHT_FIELD_NAME = "constantHeight"; |
|
28 |
|
|
29 |
private VectorElevationMode vectorElevationMode; |
|
30 |
private Color defaultColor; |
|
31 |
private double constantHeight; |
|
32 |
|
|
33 |
public DefaultVectorLoaderParameters(FLayer layer) { |
|
34 |
super(layer); |
|
35 |
} |
|
36 |
|
|
37 |
protected DefaultVectorLoaderParameters() { |
|
38 |
// Do nothing |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public String getName() { |
|
43 |
return VectorLoaderParameters.NAME; |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public VectorElevationMode getVectorElevationMode() { |
|
48 |
return this.vectorElevationMode; |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public void setVectorElevationMode(VectorElevationMode vectorElevationMode) { |
|
53 |
this.vectorElevationMode = vectorElevationMode; |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public Color getDefaultColor() { |
|
58 |
return this.defaultColor; |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
public void setDefaultColor(Color color) { |
|
63 |
this.defaultColor = color; |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public double getConstantHeight() { |
|
68 |
return this.constantHeight; |
|
69 |
} |
|
70 |
|
|
71 |
@Override |
|
72 |
public void setConstantHeight(double height) { |
|
73 |
this.constantHeight = height; |
|
74 |
} |
|
75 |
|
|
76 |
public static void registerPersistenceDefinition() { |
|
77 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
78 |
DynStruct definition = manager.getDefinition(PARAMETERS_DEFINITION_NAME); |
|
79 |
if (definition == null) { |
|
80 |
definition = manager.addDefinition(DefaultVectorLoaderParameters.class, PARAMETERS_DEFINITION_NAME, |
|
81 |
PARAMETERS_DEFINITION_DESCRIPTION, null, null); |
|
82 |
|
|
83 |
definition.addDynFieldObject(VECTOR_ELEVATION_MODEL_FIELD_NAME); |
|
84 |
definition.addDynFieldObject(DEFAULT_COLOR_FIELD_NAME); |
|
85 |
definition.addDynFieldDouble(CONSTANT_HEIGHT_FIELD_NAME); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public Object clone() throws CloneNotSupportedException { |
|
91 |
|
|
92 |
VectorLoaderParameters newParameters = new DefaultVectorLoaderParameters(); |
|
93 |
newParameters.setVectorElevationMode(this.getVectorElevationMode()); |
|
94 |
newParameters.setDefaultColor(this.getDefaultColor()); |
|
95 |
newParameters.setConstantHeight(this.getConstantHeight()); |
|
96 |
newParameters.setLayer(this.getLayer()); |
|
97 |
return newParameters; |
|
98 |
} |
|
99 |
|
|
100 |
@Override |
|
101 |
protected void doSaveToState(PersistentState state) throws PersistenceException { |
|
102 |
state.set(VECTOR_ELEVATION_MODEL_FIELD_NAME, this.vectorElevationMode); |
|
103 |
state.set(DEFAULT_COLOR_FIELD_NAME, this.defaultColor); |
|
104 |
state.set(CONSTANT_HEIGHT_FIELD_NAME, this.constantHeight); |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
protected void doLoadFromState(PersistentState state) throws PersistenceException { |
|
109 |
this.vectorElevationMode = (VectorElevationMode) state.get(VECTOR_ELEVATION_MODEL_FIELD_NAME); |
|
110 |
this.defaultColor = (Color) state.get(DEFAULT_COLOR_FIELD_NAME); |
|
111 |
this.constantHeight = state.getDouble(CONSTANT_HEIGHT_FIELD_NAME); |
|
112 |
} |
|
113 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/DefaultVectorExtrusionLoaderParameters.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
|
|
5 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
6 |
import org.gvsig.tools.ToolsLocator; |
|
7 |
import org.gvsig.tools.dynobject.DynStruct; |
|
8 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
9 |
import org.gvsig.tools.persistence.PersistentState; |
|
10 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
11 |
import org.gvsig.view3d.lib.api.loader.AbstractLoaderParameters; |
|
12 |
import org.gvsig.view3d.vector.lib.api.VectorElevationMode; |
|
13 |
import org.gvsig.view3d.vector.lib.api.VectorExtrusionLoaderParameters; |
|
14 |
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters; |
|
15 |
|
|
16 |
/** |
|
17 |
* |
|
18 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
19 |
* |
|
20 |
*/ |
|
21 |
public class DefaultVectorExtrusionLoaderParameters extends AbstractLoaderParameters |
|
22 |
implements VectorExtrusionLoaderParameters { |
|
23 |
|
|
24 |
public static final String PARAMETERS_DEFINITION_NAME = "VectorExtrusionLoaderParameters"; |
|
25 |
public static final String PARAMETERS_DEFINITION_DESCRIPTION = |
|
26 |
"Parameters that defines vector extrusion load mode"; |
|
27 |
|
|
28 |
public static final String VECTOR_ELEVATION_MODE_FIELD_NAME = "vectorElevationMode"; |
|
29 |
public static final String DEFAULT_COLOR_FIELD_NAME = "defaultColor"; |
|
30 |
public static final String HEIGHT_FIELD_FIELD_NAME = "heightField"; |
|
31 |
public static final String CONSTANT_HEIGHT_FIELD_NAME = "constantHeight"; |
|
32 |
public static final String VERTICAL_EXAGGERATION_FIELD_NAME = "verticalExaggeration"; |
|
33 |
|
|
34 |
private VectorElevationMode vectorElevationMode; |
|
35 |
private Color defaultColor; |
|
36 |
private String heightField; |
|
37 |
private double constantHeight; |
|
38 |
private double verticalExaggeration; |
|
39 |
|
|
40 |
public DefaultVectorExtrusionLoaderParameters(FLayer layer) { |
|
41 |
super(layer); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public String getName() { |
|
46 |
return VectorExtrusionLoaderParameters.NAME; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public VectorElevationMode getVectorElevationMode() { |
|
51 |
return this.vectorElevationMode; |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public void setVectorElevationMode(VectorElevationMode vectorElevationMode) { |
|
56 |
this.vectorElevationMode = vectorElevationMode; |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public Color getDefaultColor() { |
|
61 |
return this.defaultColor; |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public void setDefaultColor(Color color) { |
|
66 |
this.defaultColor = color; |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public String getHeightField() { |
|
71 |
return this.heightField; |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
75 |
public void setHeightField(String heightField) { |
|
76 |
this.heightField = heightField; |
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
public double getConstantHeight() { |
|
81 |
return this.constantHeight; |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public void setConstantHeight(double height) { |
|
86 |
this.constantHeight = height; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public double getVerticalExaggeration() { |
|
91 |
return this.verticalExaggeration; |
|
92 |
} |
|
93 |
|
|
94 |
@Override |
|
95 |
public void setVerticalExaggeration(double verticalExaggeration) { |
|
96 |
this.verticalExaggeration = verticalExaggeration; |
|
97 |
} |
|
98 |
|
|
99 |
public static void registerPersistenceDefinition() { |
|
100 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
101 |
DynStruct definition = manager.getDefinition(PARAMETERS_DEFINITION_NAME); |
|
102 |
if (definition == null) { |
|
103 |
definition = manager.addDefinition(DefaultVectorLoaderParameters.class, PARAMETERS_DEFINITION_NAME, |
|
104 |
PARAMETERS_DEFINITION_DESCRIPTION, null, null); |
|
105 |
|
|
106 |
definition.addDynFieldObject(VECTOR_ELEVATION_MODE_FIELD_NAME); |
|
107 |
definition.addDynFieldObject(DEFAULT_COLOR_FIELD_NAME); |
|
108 |
definition.addDynFieldString(HEIGHT_FIELD_FIELD_NAME); |
|
109 |
definition.addDynFieldDouble(CONSTANT_HEIGHT_FIELD_NAME); |
|
110 |
definition.addDynFieldDouble(VERTICAL_EXAGGERATION_FIELD_NAME); |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
@Override |
|
115 |
public Object clone() throws CloneNotSupportedException { |
|
116 |
|
|
117 |
VectorLoaderParameters newParameters = new DefaultVectorLoaderParameters(); |
|
118 |
newParameters.setVectorElevationMode(this.getVectorElevationMode()); |
|
119 |
newParameters.setDefaultColor(this.getDefaultColor()); |
|
120 |
newParameters.setConstantHeight(this.getConstantHeight()); |
|
121 |
newParameters.setLayer(this.getLayer()); |
|
122 |
return newParameters; |
|
123 |
} |
|
124 |
|
|
125 |
@Override |
|
126 |
protected void doSaveToState(PersistentState state) throws PersistenceException { |
|
127 |
state.set(VECTOR_ELEVATION_MODE_FIELD_NAME, this.vectorElevationMode); |
|
128 |
state.set(DEFAULT_COLOR_FIELD_NAME, this.defaultColor); |
|
129 |
state.set(HEIGHT_FIELD_FIELD_NAME, this.heightField); |
|
130 |
state.set(CONSTANT_HEIGHT_FIELD_NAME, this.constantHeight); |
|
131 |
state.set(VERTICAL_EXAGGERATION_FIELD_NAME, this.verticalExaggeration); |
|
132 |
} |
|
133 |
|
|
134 |
@Override |
|
135 |
protected void doLoadFromState(PersistentState state) throws PersistenceException { |
|
136 |
this.vectorElevationMode = (VectorElevationMode) state.get(VECTOR_ELEVATION_MODE_FIELD_NAME); |
|
137 |
this.defaultColor = (Color) state.get(DEFAULT_COLOR_FIELD_NAME); |
|
138 |
this.heightField = state.getString(HEIGHT_FIELD_FIELD_NAME); |
|
139 |
this.constantHeight = state.getDouble(CONSTANT_HEIGHT_FIELD_NAME); |
|
140 |
this.verticalExaggeration = state.getDouble(VERTICAL_EXAGGERATION_FIELD_NAME); |
|
141 |
} |
|
142 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/DefaultVectorLoaderFactory.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl; |
|
2 |
|
|
3 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
4 |
import org.gvsig.view3d.lib.api.loader.Loader; |
|
5 |
import org.gvsig.view3d.lib.api.loader.LoaderFactory; |
|
6 |
import org.gvsig.view3d.lib.api.loader.LoaderParameters; |
|
7 |
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters; |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
12 |
* |
|
13 |
*/ |
|
14 |
public class DefaultVectorLoaderFactory implements LoaderFactory { |
|
15 |
|
|
16 |
@Override |
|
17 |
public String getName() { |
|
18 |
return VectorLoaderParameters.FACTORY_NAME; |
|
19 |
} |
|
20 |
|
|
21 |
@Override |
|
22 |
public LoaderParameters createParameters(FLayer layer) { |
|
23 |
return new DefaultVectorLoaderParameters(layer); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
public Loader createLoader() { |
|
28 |
return new DefaultVectorLoader(); |
|
29 |
} |
|
30 |
|
|
31 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/extrusion/DefaultVectorExtrusionLoaderFactory.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl.extrusion; |
|
2 |
|
|
3 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
4 |
import org.gvsig.view3d.lib.api.loader.Loader; |
|
5 |
import org.gvsig.view3d.lib.api.loader.LoaderFactory; |
|
6 |
import org.gvsig.view3d.lib.api.loader.LoaderParameters; |
|
7 |
import org.gvsig.view3d.vector.lib.api.VectorExtrusionLoaderParameters; |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
12 |
* |
|
13 |
*/ |
|
14 |
public class DefaultVectorExtrusionLoaderFactory implements LoaderFactory { |
|
15 |
|
|
16 |
@Override |
|
17 |
public String getName() { |
|
18 |
return VectorExtrusionLoaderParameters.FACTORY_NAME; |
|
19 |
} |
|
20 |
|
|
21 |
@Override |
|
22 |
public LoaderParameters createParameters(FLayer layer) { |
|
23 |
return new DefaultVectorExtrusionLoaderParameters(layer); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
public Loader createLoader() { |
|
28 |
return new DefaultVectorExtrusionLoader(); |
|
29 |
} |
|
30 |
|
|
31 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/extrusion/DefaultVectorExtrusionLoader.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl.extrusion; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
4 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
5 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
6 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
7 |
import org.gvsig.view3d.lib.api.exception.LoadException; |
|
8 |
import org.gvsig.view3d.lib.api.loader.Loader; |
|
9 |
import org.gvsig.view3d.lib.api.loader.LoaderParameters; |
|
10 |
import org.gvsig.view3d.vector.lib.api.VectorExtrusionLoaderParameters; |
|
11 |
|
|
12 |
/** |
|
13 |
* |
|
14 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
15 |
* |
|
16 |
*/ |
|
17 |
public class DefaultVectorExtrusionLoader implements Loader { |
|
18 |
|
|
19 |
@Override |
|
20 |
public Object load(LoaderParameters parameters) throws LoadException { |
|
21 |
|
|
22 |
if (parameters == null) { |
|
23 |
throw new IllegalArgumentException("Can not load layer, parameters can not be null"); |
|
24 |
} |
|
25 |
|
|
26 |
if (!(parameters instanceof VectorExtrusionLoaderParameters)) { |
|
27 |
throw new IllegalArgumentException( |
|
28 |
"Can not load layer, parameters must implements VectorExtrusionLoaderParameters interface"); |
|
29 |
} |
|
30 |
|
|
31 |
FLayer layer = parameters.getLayer(); |
|
32 |
if (!(layer instanceof FLyrVect)) { |
|
33 |
throw new IllegalArgumentException("Can not load layer, only vector layers can be load as 'Vector'"); |
|
34 |
} |
|
35 |
FLyrVect layerVect = (FLyrVect) layer; |
|
36 |
FeatureStore featureStore = layerVect.getFeatureStore(); |
|
37 |
IVectorLegend vectorLegend = null; |
|
38 |
if (layerVect.getLegend() instanceof IVectorLegend) { |
|
39 |
vectorLegend = (IVectorLegend) layerVect.getLegend(); |
|
40 |
} |
|
41 |
return new DefaultVectorExtrusionPointRenderableLayer((VectorExtrusionLoaderParameters) parameters, |
|
42 |
featureStore, vectorLegend); |
|
43 |
|
|
44 |
} |
|
45 |
|
|
46 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/extrusion/DefaultVectorExtrusionLoaderParameters.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl.extrusion; |
|
2 |
|
|
3 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
4 |
import org.gvsig.tools.ToolsLocator; |
|
5 |
import org.gvsig.tools.dynobject.DynStruct; |
|
6 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
7 |
import org.gvsig.tools.persistence.PersistentState; |
|
8 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
9 |
import org.gvsig.view3d.vector.lib.api.VectorExtrusionLoaderParameters; |
|
10 |
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters; |
|
11 |
import org.gvsig.view3d.vector.lib.impl.vector.DefaultVectorLoaderParameters; |
|
12 |
|
|
13 |
/** |
|
14 |
* |
|
15 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
16 |
* |
|
17 |
*/ |
|
18 |
public class DefaultVectorExtrusionLoaderParameters extends DefaultVectorLoaderParameters |
|
19 |
implements VectorExtrusionLoaderParameters { |
|
20 |
|
|
21 |
public static final String PARAMETERS_DEFINITION_NAME = "VectorExtrusionLoaderParameters"; |
|
22 |
public static final String PARAMETERS_DEFINITION_DESCRIPTION = "Parameters that defines vector extrusion load mode"; |
|
23 |
|
|
24 |
public static final String VECTOR_ELEVATION_MODE_FIELD_NAME = "vectorElevationMode"; |
|
25 |
public static final String DEFAULT_COLOR_FIELD_NAME = "defaultColor"; |
|
26 |
public static final String HEIGHT_FIELD_FIELD_NAME = "heightField"; |
|
27 |
public static final String CONSTANT_HEIGHT_FIELD_NAME = "constantHeight"; |
|
28 |
public static final String VERTICAL_EXAGGERATION_FIELD_NAME = "verticalExaggeration"; |
|
29 |
|
|
30 |
private String heightField; |
|
31 |
private double verticalExaggeration = 1; |
|
32 |
|
|
33 |
public DefaultVectorExtrusionLoaderParameters(FLayer layer) { |
|
34 |
super(layer); |
|
35 |
} |
|
36 |
|
|
37 |
public DefaultVectorExtrusionLoaderParameters(VectorLoaderParameters vectorParams) { |
|
38 |
this.layer = vectorParams.getLayer(); |
|
39 |
this.vectorElevationMode = vectorParams.getVectorElevationMode(); |
|
40 |
this.defaultColor = vectorParams.getDefaultColor(); |
|
41 |
this.constantHeight = vectorParams.getConstantHeight(); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public String getName() { |
|
46 |
return VectorExtrusionLoaderParameters.NAME; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public String getHeightField() { |
|
51 |
return this.heightField; |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public void setHeightField(String heightField) { |
|
56 |
this.heightField = heightField; |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public double getVerticalExaggeration() { |
|
61 |
return this.verticalExaggeration; |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public void setVerticalExaggeration(double verticalExaggeration) { |
|
66 |
this.verticalExaggeration = verticalExaggeration; |
|
67 |
} |
|
68 |
|
|
69 |
public static void registerPersistenceDefinition() { |
|
70 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
71 |
DynStruct definition = manager.getDefinition(PARAMETERS_DEFINITION_NAME); |
|
72 |
if (definition == null) { |
|
73 |
definition = manager.addDefinition(DefaultVectorLoaderParameters.class, PARAMETERS_DEFINITION_NAME, |
|
74 |
PARAMETERS_DEFINITION_DESCRIPTION, null, null); |
|
75 |
|
|
76 |
definition.extend(manager.getDefinition(DefaultVectorLoaderParameters.PARAMETERS_DEFINITION_NAME)); |
|
77 |
definition.addDynFieldString(HEIGHT_FIELD_FIELD_NAME); |
|
78 |
definition.addDynFieldDouble(VERTICAL_EXAGGERATION_FIELD_NAME); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public Object clone() throws CloneNotSupportedException { |
|
84 |
Object object = super.clone(); |
|
85 |
if (object instanceof VectorLoaderParameters) { |
|
86 |
VectorLoaderParameters vectorParams = (VectorLoaderParameters) object; |
|
87 |
VectorExtrusionLoaderParameters extrusionParams = new DefaultVectorExtrusionLoaderParameters(vectorParams); |
|
88 |
extrusionParams.setHeightField(this.heightField); |
|
89 |
extrusionParams.setVerticalExaggeration(this.verticalExaggeration); |
|
90 |
return extrusionParams; |
|
91 |
} |
|
92 |
throw new CloneNotSupportedException("Can not clone if superclass is not an instance of VectorLoaderParameters"); |
|
93 |
} |
|
94 |
|
|
95 |
@Override |
|
96 |
protected void doSaveToState(PersistentState state) throws PersistenceException { |
|
97 |
super.doSaveToState(state); |
|
98 |
state.set(HEIGHT_FIELD_FIELD_NAME, this.heightField); |
|
99 |
state.set(VERTICAL_EXAGGERATION_FIELD_NAME, this.verticalExaggeration); |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
protected void doLoadFromState(PersistentState state) throws PersistenceException { |
|
104 |
super.doLoadFromState(state); |
|
105 |
this.heightField = state.getString(HEIGHT_FIELD_FIELD_NAME); |
|
106 |
this.verticalExaggeration = state.getDouble(VERTICAL_EXAGGERATION_FIELD_NAME); |
|
107 |
} |
|
108 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/extrusion/DefaultVectorExtrusionPointRenderableLayer.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl.extrusion; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.apache.commons.lang3.StringUtils; |
|
7 |
|
|
8 |
import org.gvsig.fmap.dal.exception.DataException; |
|
9 |
import org.gvsig.fmap.dal.feature.Feature; |
|
10 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
11 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
12 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
13 |
import org.gvsig.fmap.geom.Geometry; |
|
14 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
15 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
|
16 |
import org.gvsig.fmap.geom.primitive.Point; |
|
17 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
18 |
import org.gvsig.view3d.vector.lib.api.VectorElevationMode; |
|
19 |
import org.gvsig.view3d.vector.lib.api.VectorExtrusionLoaderParameters; |
|
20 |
import org.gvsig.view3d.vector.lib.impl.AbstractPointRenderableLayer; |
|
21 |
|
|
22 |
import gov.nasa.worldwind.geom.Position; |
|
23 |
import gov.nasa.worldwind.render.PointPlacemark; |
|
24 |
import gov.nasa.worldwind.render.Renderable; |
|
25 |
|
|
26 |
public class DefaultVectorExtrusionPointRenderableLayer extends AbstractPointRenderableLayer { |
|
27 |
|
|
28 |
public DefaultVectorExtrusionPointRenderableLayer(VectorExtrusionLoaderParameters parameters, FeatureStore featureStore, |
|
29 |
IVectorLegend legend) { |
|
30 |
super(parameters, featureStore, legend); |
|
31 |
} |
|
32 |
|
|
33 |
@Override |
|
34 |
protected List<Renderable> getRenderable(Feature feature) { |
|
35 |
|
|
36 |
double heightFieldValue = 0; |
|
37 |
String heightField = ((VectorExtrusionLoaderParameters) parameters).getHeightField(); |
|
38 |
if (StringUtils.isNoneBlank(heightField)) { |
|
39 |
heightFieldValue = feature.getDouble(heightField); |
|
40 |
} |
|
41 |
|
|
42 |
Geometry geom = feature.getDefaultGeometry(); |
|
43 |
List<Renderable> renderables = new ArrayList<>(); |
|
44 |
if (geom.getGeometryType().isTypeOf(TYPES.MULTIPOINT)) { |
|
45 |
MultiPoint multiPoint = (MultiPoint) geom; |
|
46 |
for (int i = 0; i < multiPoint.getPrimitivesNumber(); i++) { |
|
47 |
renderables.add(getRenderable(multiPoint.getPointAt(i), heightFieldValue)); |
|
48 |
} |
|
49 |
} else { |
|
50 |
renderables.add(getRenderable((Point) geom, heightFieldValue)); |
|
51 |
} |
|
52 |
return renderables; |
|
53 |
} |
|
54 |
|
|
55 |
private PointPlacemark getRenderable(Point point, double heightFieldValue) { |
|
56 |
boolean hasZ = point.getDimension() > 2; |
|
57 |
double h = 0.0; |
|
58 |
double y = point.getY(); |
|
59 |
double x = point.getX(); |
|
60 |
|
|
61 |
if(VectorElevationMode.CLAMP_TO_GROUND.equals(parameters.getVectorElevationMode())) { |
|
62 |
hasZ = false; |
|
63 |
} else { |
|
64 |
if(VectorElevationMode.RELATIVE_TO_GROUND.equals(parameters.getVectorElevationMode())) { |
|
65 |
hasZ = false; |
|
66 |
} |
|
67 |
if (parameters.getConstantHeight() != null) { |
|
68 |
h = parameters.getConstantHeight(); |
|
69 |
} |
|
70 |
} |
|
71 |
h += heightFieldValue; |
|
72 |
h *= ((VectorExtrusionLoaderParameters) parameters).getVerticalExaggeration(); |
|
73 |
PointPlacemark marker; |
|
74 |
if (hasZ) { |
|
75 |
double z = point.getCoordinateAt(2); |
|
76 |
marker = new PointPlacemark(Position.fromDegrees(y, x, z + h)); |
|
77 |
} else { |
|
78 |
Position position = Position.fromDegrees(y, x, h); |
|
79 |
marker = new PointPlacemark(position); |
|
80 |
} |
|
81 |
marker.setAltitudeMode(getAltitudeMode(parameters.getVectorElevationMode())); |
|
82 |
marker.setLineEnabled(true); |
|
83 |
marker.setAttributes(this.markAttributes); |
|
84 |
return marker; |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
protected FeatureQuery getFeatureQuery() throws DataException { |
|
89 |
FeatureType featureType = featureStore.getDefaultFeatureType(); |
|
90 |
String geomAtt = featureType.getDefaultGeometryAttributeName(); |
|
91 |
FeatureQuery featureQuery = featureStore.createFeatureQuery(); |
|
92 |
featureQuery.addAttributeName(geomAtt); |
|
93 |
// Add field height to feature query |
|
94 |
String fieldHeight = ((VectorExtrusionLoaderParameters) parameters).getHeightField(); |
|
95 |
if (StringUtils.isNotBlank(fieldHeight)) { |
|
96 |
featureQuery.addAttributeName(fieldHeight); |
|
97 |
} |
|
98 |
return featureQuery; |
|
99 |
} |
|
100 |
|
|
101 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/vector/DefaultVectorLoader.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl.vector; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
4 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
5 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
6 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
7 |
import org.gvsig.view3d.lib.api.exception.LoadException; |
|
8 |
import org.gvsig.view3d.lib.api.loader.Loader; |
|
9 |
import org.gvsig.view3d.lib.api.loader.LoaderParameters; |
|
10 |
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters; |
|
11 |
|
|
12 |
/** |
|
13 |
* |
|
14 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
15 |
* |
|
16 |
*/ |
|
17 |
public class DefaultVectorLoader implements Loader { |
|
18 |
|
|
19 |
@Override |
|
20 |
public Object load(LoaderParameters parameters) throws LoadException { |
|
21 |
|
|
22 |
if (parameters == null) { |
|
23 |
throw new IllegalArgumentException("Can not load layer, parameters can not be null"); |
|
24 |
} |
|
25 |
|
|
26 |
if (!(parameters instanceof VectorLoaderParameters)) { |
|
27 |
throw new IllegalArgumentException( |
|
28 |
"Can not load layer, parameters must implements VectorLoaderParameter interface"); |
|
29 |
} |
|
30 |
|
|
31 |
FLayer layer = parameters.getLayer(); |
|
32 |
if (!(layer instanceof FLyrVect)) { |
|
33 |
throw new IllegalArgumentException("Can not load layer, only vector layers can be load as 'Vector'"); |
|
34 |
} |
|
35 |
FLyrVect layerVect = (FLyrVect) layer; |
|
36 |
FeatureStore featureStore = layerVect.getFeatureStore(); |
|
37 |
IVectorLegend vectorLegend = null; |
|
38 |
if (layerVect.getLegend() instanceof IVectorLegend) { |
|
39 |
vectorLegend = (IVectorLegend) layerVect.getLegend(); |
|
40 |
} |
|
41 |
return new DefeaultVectorPointRenderableLayer((VectorLoaderParameters) parameters, featureStore, vectorLegend); |
|
42 |
} |
|
43 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/vector/DefaultVectorLoaderParameters.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl.vector; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
|
|
5 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
6 |
import org.gvsig.tools.ToolsLocator; |
|
7 |
import org.gvsig.tools.dynobject.DynStruct; |
|
8 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
9 |
import org.gvsig.tools.persistence.PersistentState; |
|
10 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
11 |
import org.gvsig.view3d.lib.api.loader.AbstractLoaderParameters; |
|
12 |
import org.gvsig.view3d.vector.lib.api.VectorElevationMode; |
|
13 |
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters; |
|
14 |
|
|
15 |
/** |
|
16 |
* |
|
17 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
18 |
* |
|
19 |
*/ |
|
20 |
public class DefaultVectorLoaderParameters extends AbstractLoaderParameters implements VectorLoaderParameters { |
|
21 |
|
|
22 |
public static final String PARAMETERS_DEFINITION_NAME = "VectorLoaderParameters"; |
|
23 |
public static final String PARAMETERS_DEFINITION_DESCRIPTION = "Parameters that defines vector load mode"; |
|
24 |
|
|
25 |
public static final String VECTOR_ELEVATION_MODEL_FIELD_NAME = "vectorElevationModel"; |
|
26 |
public static final String DEFAULT_COLOR_FIELD_NAME = "defaultColor"; |
|
27 |
public static final String CONSTANT_HEIGHT_FIELD_NAME = "constantHeight"; |
|
28 |
|
|
29 |
protected VectorElevationMode vectorElevationMode; |
|
30 |
protected Color defaultColor; |
|
31 |
protected double constantHeight; |
|
32 |
|
|
33 |
public DefaultVectorLoaderParameters(FLayer layer) { |
|
34 |
super(layer); |
|
35 |
} |
|
36 |
|
|
37 |
protected DefaultVectorLoaderParameters() { |
|
38 |
// Do nothing |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public String getName() { |
|
43 |
return VectorLoaderParameters.NAME; |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public VectorElevationMode getVectorElevationMode() { |
|
48 |
return this.vectorElevationMode; |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public void setVectorElevationMode(VectorElevationMode vectorElevationMode) { |
|
53 |
this.vectorElevationMode = vectorElevationMode; |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public Color getDefaultColor() { |
|
58 |
return this.defaultColor; |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
public void setDefaultColor(Color color) { |
|
63 |
this.defaultColor = color; |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public Double getConstantHeight() { |
|
68 |
return this.constantHeight; |
|
69 |
} |
|
70 |
|
|
71 |
@Override |
|
72 |
public void setConstantHeight(Double height) { |
|
73 |
this.constantHeight = height; |
|
74 |
} |
|
75 |
|
|
76 |
public static void registerPersistenceDefinition() { |
|
77 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
78 |
DynStruct definition = manager.getDefinition(PARAMETERS_DEFINITION_NAME); |
|
79 |
if (definition == null) { |
|
80 |
definition = manager.addDefinition(DefaultVectorLoaderParameters.class, PARAMETERS_DEFINITION_NAME, |
|
81 |
PARAMETERS_DEFINITION_DESCRIPTION, null, null); |
|
82 |
|
|
83 |
definition.addDynFieldObject(VECTOR_ELEVATION_MODEL_FIELD_NAME); |
|
84 |
definition.addDynFieldObject(DEFAULT_COLOR_FIELD_NAME); |
|
85 |
definition.addDynFieldDouble(CONSTANT_HEIGHT_FIELD_NAME); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public Object clone() throws CloneNotSupportedException { |
|
91 |
|
|
92 |
VectorLoaderParameters newParameters = new DefaultVectorLoaderParameters(); |
|
93 |
newParameters.setVectorElevationMode(this.getVectorElevationMode()); |
|
94 |
newParameters.setDefaultColor(this.getDefaultColor()); |
|
95 |
newParameters.setConstantHeight(this.getConstantHeight()); |
|
96 |
newParameters.setLayer(this.getLayer()); |
|
97 |
return newParameters; |
|
98 |
} |
|
99 |
|
|
100 |
@Override |
|
101 |
protected void doSaveToState(PersistentState state) throws PersistenceException { |
|
102 |
state.set(VECTOR_ELEVATION_MODEL_FIELD_NAME, this.vectorElevationMode); |
|
103 |
state.set(DEFAULT_COLOR_FIELD_NAME, this.defaultColor); |
|
104 |
state.set(CONSTANT_HEIGHT_FIELD_NAME, this.constantHeight); |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
protected void doLoadFromState(PersistentState state) throws PersistenceException { |
|
109 |
this.vectorElevationMode = (VectorElevationMode) state.get(VECTOR_ELEVATION_MODEL_FIELD_NAME); |
|
110 |
this.defaultColor = (Color) state.get(DEFAULT_COLOR_FIELD_NAME); |
|
111 |
this.constantHeight = state.getDouble(CONSTANT_HEIGHT_FIELD_NAME); |
|
112 |
} |
|
113 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/vector/DefaultVectorLoaderFactory.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl.vector; |
|
2 |
|
|
3 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
4 |
import org.gvsig.view3d.lib.api.loader.Loader; |
|
5 |
import org.gvsig.view3d.lib.api.loader.LoaderFactory; |
|
6 |
import org.gvsig.view3d.lib.api.loader.LoaderParameters; |
|
7 |
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters; |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
12 |
* |
|
13 |
*/ |
|
14 |
public class DefaultVectorLoaderFactory implements LoaderFactory { |
|
15 |
|
|
16 |
@Override |
|
17 |
public String getName() { |
|
18 |
return VectorLoaderParameters.FACTORY_NAME; |
|
19 |
} |
|
20 |
|
|
21 |
@Override |
|
22 |
public LoaderParameters createParameters(FLayer layer) { |
|
23 |
return new DefaultVectorLoaderParameters(layer); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
public Loader createLoader() { |
|
28 |
return new DefaultVectorLoader(); |
|
29 |
} |
|
30 |
|
|
31 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/vector/DefeaultVectorPointRenderableLayer.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl.vector; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.gvsig.fmap.dal.exception.DataException; |
|
7 |
import org.gvsig.fmap.dal.feature.Feature; |
|
8 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
9 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
10 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
11 |
import org.gvsig.fmap.geom.Geometry; |
|
12 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
13 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
|
14 |
import org.gvsig.fmap.geom.primitive.Point; |
|
15 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
16 |
import org.gvsig.view3d.vector.lib.api.VectorElevationMode; |
|
17 |
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters; |
|
18 |
import org.gvsig.view3d.vector.lib.impl.AbstractPointRenderableLayer; |
|
19 |
|
|
20 |
import gov.nasa.worldwind.geom.Position; |
|
21 |
import gov.nasa.worldwind.render.PointPlacemark; |
|
22 |
import gov.nasa.worldwind.render.Renderable; |
|
23 |
|
|
24 |
public class DefeaultVectorPointRenderableLayer extends AbstractPointRenderableLayer { |
|
25 |
|
|
26 |
public DefeaultVectorPointRenderableLayer(VectorLoaderParameters parameters, FeatureStore featureStore, |
|
27 |
IVectorLegend legend) { |
|
28 |
super(parameters, featureStore, legend); |
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
protected List<Renderable> getRenderable(Feature feature) { |
|
33 |
Geometry geom = feature.getDefaultGeometry(); |
|
34 |
List<Renderable> renderables = new ArrayList<>(); |
|
35 |
if (geom.getGeometryType().isTypeOf(TYPES.MULTIPOINT)) { |
|
36 |
MultiPoint multiPoint = (MultiPoint) geom; |
|
37 |
for (int i = 0; i < multiPoint.getPrimitivesNumber(); i++) { |
|
38 |
renderables.add(getRenderable(multiPoint.getPointAt(i))); |
|
39 |
} |
|
40 |
} else { |
|
41 |
renderables.add(getRenderable((Point) geom)); |
|
42 |
} |
|
43 |
return renderables; |
|
44 |
} |
|
45 |
|
|
46 |
private PointPlacemark getRenderable(Point point) { |
|
47 |
boolean hasZ = point.getDimension() > 2; |
|
48 |
double h = 0.0; |
|
49 |
double y = point.getY(); |
|
50 |
double x = point.getX(); |
|
51 |
|
|
52 |
if(VectorElevationMode.CLAMP_TO_GROUND.equals(parameters.getVectorElevationMode())) { |
|
53 |
hasZ = false; |
|
54 |
} else { |
|
55 |
if(VectorElevationMode.RELATIVE_TO_GROUND.equals(parameters.getVectorElevationMode())) { |
|
56 |
hasZ = false; |
|
57 |
} |
|
58 |
if (parameters.getConstantHeight() != null) { |
|
59 |
h = parameters.getConstantHeight(); |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
PointPlacemark marker; |
|
64 |
if (hasZ) { |
|
65 |
double z = point.getCoordinateAt(2); |
|
66 |
marker = new PointPlacemark(Position.fromDegrees(y, x, z + h)); |
|
67 |
} else { |
|
68 |
Position position = Position.fromDegrees(y, x, h); |
|
69 |
marker = new PointPlacemark(position); |
|
70 |
} |
|
71 |
marker.setAltitudeMode(getAltitudeMode(parameters.getVectorElevationMode())); |
|
72 |
marker.setAttributes(this.markAttributes); |
|
73 |
return marker; |
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
protected FeatureQuery getFeatureQuery() throws DataException { |
|
78 |
FeatureType featureType = featureStore.getDefaultFeatureType(); |
|
79 |
String geomAtt = featureType.getDefaultGeometryAttributeName(); |
|
80 |
FeatureQuery featureQuery = featureStore.createFeatureQuery(); |
|
81 |
featureQuery.addAttributeName(geomAtt); |
|
82 |
return featureQuery; |
|
83 |
} |
|
84 |
|
|
85 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/AbstractPointRenderableLayer.java | ||
---|---|---|
1 |
package org.gvsig.view3d.vector.lib.impl; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.util.List; |
|
5 |
import java.util.concurrent.ExecutorService; |
|
6 |
import java.util.concurrent.Executors; |
|
7 |
|
|
8 |
import org.slf4j.Logger; |
|
9 |
import org.slf4j.LoggerFactory; |
|
10 |
|
|
11 |
import org.gvsig.fmap.dal.exception.DataException; |
|
12 |
import org.gvsig.fmap.dal.feature.Feature; |
|
13 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
14 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
15 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
16 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
17 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
18 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.ISimpleMarkerSymbol; |
|
19 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
20 |
import org.gvsig.view3d.vector.lib.api.VectorElevationMode; |
|
21 |
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters; |
|
22 |
|
|
23 |
import gov.nasa.worldwind.WorldWind; |
|
24 |
import gov.nasa.worldwind.layers.RenderableLayer; |
|
25 |
import gov.nasa.worldwind.render.Material; |
|
26 |
import gov.nasa.worldwind.render.PointPlacemarkAttributes; |
|
27 |
import gov.nasa.worldwind.render.Renderable; |
|
28 |
|
|
29 |
public abstract class AbstractPointRenderableLayer extends RenderableLayer { |
|
30 |
|
|
31 |
private static final Logger LOG = LoggerFactory.getLogger(AbstractPointRenderableLayer.class); |
|
32 |
|
|
33 |
protected FeatureStore featureStore; |
|
34 |
|
|
35 |
protected PointPlacemarkAttributes markAttributes; |
|
36 |
|
|
37 |
protected VectorLoaderParameters parameters; |
|
38 |
|
|
39 |
public AbstractPointRenderableLayer(VectorLoaderParameters parameters, FeatureStore featureStore, |
|
40 |
IVectorLegend legend) { |
|
41 |
this.featureStore = featureStore; |
|
42 |
this.parameters = parameters; |
|
43 |
this.markAttributes = getBasicMarkerAttributes(legend); |
|
44 |
ExecutorService executor = Executors.newSingleThreadExecutor(); |
|
45 |
executor.execute(addRenderableObjects()); |
|
46 |
} |
|
47 |
|
|
48 |
protected Runnable addRenderableObjects() { |
|
49 |
|
|
50 |
return new Runnable() { |
|
51 |
|
|
52 |
@Override |
|
53 |
public void run() { |
|
54 |
FeatureQuery featureQuery; |
|
55 |
try { |
|
56 |
featureQuery = getFeatureQuery(); |
|
57 |
} catch (DataException e) { |
|
58 |
LOG.error(String.format("Can not access to feature type of %1s", featureStore.getFullName()), e); |
|
59 |
removeAllRenderables(); |
|
60 |
return; |
|
61 |
} |
|
62 |
|
|
63 |
FeatureSet featureSet = null; |
|
64 |
DisposableIterator it = null; |
|
65 |
try { |
|
66 |
featureSet = featureStore.getFeatureSet(featureQuery); |
|
67 |
it = featureSet.fastIterator(); |
|
68 |
while (it.hasNext()) { |
|
69 |
Feature feature = (Feature) it.next(); |
|
70 |
List<Renderable> renderables = getRenderable(feature); |
|
71 |
for (Renderable renderable : renderables) { |
|
72 |
addRenderable(renderable); |
|
73 |
} |
|
74 |
} |
|
75 |
} catch (DataException e) { |
|
76 |
LOG.error(String.format("Can not access to %1s data", featureStore.getFullName()), e); |
|
77 |
removeAllRenderables(); |
|
78 |
return; |
|
79 |
} finally { |
|
80 |
if (it != null) { |
|
81 |
it.dispose(); |
|
82 |
} |
|
83 |
if (featureSet != null) { |
|
84 |
featureSet.dispose(); |
|
85 |
} |
|
86 |
} |
|
87 |
} |
|
88 |
}; |
|
89 |
} |
|
90 |
|
|
91 |
protected PointPlacemarkAttributes getBasicMarkerAttributes(IVectorLegend legend) { |
|
92 |
|
|
93 |
if (this.markAttributes != null) { |
|
94 |
return this.markAttributes; |
|
95 |
} |
|
96 |
|
|
97 |
double markerSize = 0; |
|
98 |
Material fillMaterial = null; |
|
99 |
|
|
100 |
if (legend == null) { |
|
101 |
fillMaterial = new Material(parameters.getDefaultColor()); |
|
102 |
markerSize = 0.3; |
|
103 |
} else { |
|
104 |
ISymbol symbol = legend.getDefaultSymbol(); |
|
105 |
if (symbol instanceof ISimpleMarkerSymbol) { |
|
106 |
ISimpleMarkerSymbol markerSymbol = (ISimpleMarkerSymbol) symbol; |
|
107 |
Color fillColor = markerSymbol.getColor(); |
|
108 |
markerSize = markerSymbol.getSize(); |
|
109 |
fillMaterial = new Material(fillColor); |
|
110 |
} else { |
|
111 |
fillMaterial = new Material(parameters.getDefaultColor()); |
|
112 |
markerSize = 4; |
|
113 |
} |
|
114 |
} |
|
115 |
markAttributes = new PointPlacemarkAttributes(); |
|
116 |
Color color = fillMaterial.getDiffuse(); |
|
117 |
markAttributes.setImageColor(color); |
|
118 |
markAttributes.setLineMaterial(fillMaterial); |
|
119 |
markAttributes.setLineWidth(1d); |
|
120 |
markAttributes.setUsePointAsDefaultImage(true); |
|
121 |
markAttributes.setScale(markerSize); |
|
122 |
return markAttributes; |
|
123 |
} |
|
124 |
|
|
125 |
protected int getAltitudeMode(VectorElevationMode mode) { |
|
126 |
switch (mode) { |
|
127 |
case CLAMP_TO_GROUND: |
|
128 |
return WorldWind.CLAMP_TO_GROUND; |
|
129 |
case ABSOLUTE: |
|
130 |
return WorldWind.ABSOLUTE; |
|
131 |
case RELATIVE_TO_GROUND: |
|
132 |
return WorldWind.RELATIVE_TO_GROUND; |
|
133 |
default: |
|
134 |
throw new IllegalArgumentException( |
|
135 |
"Vector elevation mode not reconized. Only CLAMP_TO_GROUND, ABSOLUTE and RELATIVE_TO_GROUND are valid"); |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
protected abstract List<Renderable> getRenderable(Feature feature); |
|
140 |
|
|
141 |
protected abstract FeatureQuery getFeatureQuery() throws DataException; |
|
142 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/src/main/java/org/gvsig/view3d/vector/lib/impl/DefaultVectorView3DLibrary.java | ||
---|---|---|
32 | 32 |
import org.gvsig.view3d.vector.lib.api.VectorExtrusionLoaderParameters; |
33 | 33 |
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters; |
34 | 34 |
import org.gvsig.view3d.vector.lib.api.VectorView3DLibrary; |
35 |
import org.gvsig.view3d.vector.lib.impl.extrusion.DefaultVectorExtrusionLoaderFactory; |
|
36 |
import org.gvsig.view3d.vector.lib.impl.extrusion.DefaultVectorExtrusionLoaderParameters; |
|
37 |
import org.gvsig.view3d.vector.lib.impl.vector.DefaultVectorLoaderFactory; |
|
38 |
import org.gvsig.view3d.vector.lib.impl.vector.DefaultVectorLoaderParameters; |
|
35 | 39 |
|
36 | 40 |
/** |
37 | 41 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.impl/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.view3d.vector.lib</artifactId> |
|
6 |
<version>1.1.0-SNAPSHOT</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.view3d.vector.lib.impl</artifactId> |
|
9 |
<dependencies> |
|
10 |
<dependency> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.view3d.lib.api</artifactId> |
|
13 |
</dependency> |
|
14 |
<dependency> |
|
15 |
<groupId>org.gvsig</groupId> |
|
16 |
<artifactId>org.gvsig.view3d.vector.lib.api</artifactId> |
|
17 |
</dependency> |
|
18 |
</dependencies> |
|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
2 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<parent> |
|
5 |
<groupId>org.gvsig</groupId> |
|
6 |
<artifactId>org.gvsig.view3d.vector.lib</artifactId> |
|
7 |
<version>1.1.0-SNAPSHOT</version> |
|
8 |
</parent> |
|
9 |
<artifactId>org.gvsig.view3d.vector.lib.impl</artifactId> |
|
10 |
<dependencies> |
|
11 |
<dependency> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.view3d.lib.api</artifactId> |
|
14 |
</dependency> |
|
15 |
<dependency> |
|
16 |
<groupId>org.gvsig</groupId> |
|
17 |
<artifactId>org.gvsig.view3d.vector.lib.api</artifactId> |
|
18 |
</dependency> |
|
19 |
<dependency> |
|
20 |
<groupId>org.gvsig</groupId> |
|
21 |
<artifactId>org.gvsig.symbology.lib.api</artifactId> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>gov.nasa</groupId> |
|
25 |
<artifactId>worldwind</artifactId> |
|
26 |
</dependency> |
|
27 |
|
|
28 |
</dependencies> |
|
19 | 29 |
</project> |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.api/src/main/java/org/gvsig/view3d/vector/lib/api/VectorLoaderParameters.java | ||
---|---|---|
53 | 53 |
* |
54 | 54 |
* @return the height of this properties. |
55 | 55 |
*/ |
56 |
public double getConstantHeight();
|
|
56 |
public Double getConstantHeight();
|
|
57 | 57 |
|
58 | 58 |
/** |
59 | 59 |
* Sets the specified constant height to this properties. |
... | ... | |
61 | 61 |
* @param height |
62 | 62 |
* the specified constant height. |
63 | 63 |
*/ |
64 |
public void setConstantHeight(double height);
|
|
64 |
public void setConstantHeight(Double height);
|
|
65 | 65 |
|
66 | 66 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.lib/org.gvsig.view3d.vector.lib.api/src/main/java/org/gvsig/view3d/vector/lib/api/VectorExtrusionLoaderParameters.java | ||
---|---|---|
1 | 1 |
package org.gvsig.view3d.vector.lib.api; |
2 | 2 |
|
3 |
import java.awt.Color; |
|
4 |
|
|
5 |
import org.gvsig.view3d.lib.api.loader.LoaderParameters; |
|
6 |
|
|
7 | 3 |
/** |
8 | 4 |
* |
9 | 5 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
10 | 6 |
* |
11 | 7 |
*/ |
12 |
public interface VectorExtrusionLoaderParameters extends LoaderParameters { |
|
8 |
public interface VectorExtrusionLoaderParameters extends VectorLoaderParameters {
|
|
13 | 9 |
|
14 | 10 |
public static final String NAME = "VectorExtrusionLoaderParameters"; |
15 | 11 |
|
16 | 12 |
public static final String FACTORY_NAME = "VectorExtrusionLoaderParametersFactory"; |
17 | 13 |
|
18 | 14 |
/** |
19 |
* Gets {@link VectorElevationMode} of this vector layer properties. |
|
20 |
* |
|
21 |
* @return |
|
22 |
*/ |
|
23 |
public VectorElevationMode getVectorElevationMode(); |
|
24 |
|
|
25 |
/** |
|
26 |
* Sets the specific {@link VectorElevationMode} to this vector layer |
|
27 |
* properties. |
|
28 |
* |
|
29 |
* @param vectorElevationMode |
|
30 |
* the specific {@link VectorElevationMode} |
|
31 |
*/ |
|
32 |
public void setVectorElevationMode(VectorElevationMode vectorElevationMode); |
|
33 |
|
|
34 |
/** |
|
35 |
* Gets default {@link Color} of vector layer properties. Default color is |
|
36 |
* used when vector layer has a complex legend that can no be represented in |
|
37 |
* 3D. |
|
38 |
* |
|
39 |
* @return |
|
40 |
*/ |
|
41 |
public Color getDefaultColor(); |
|
42 |
|
|
43 |
/** |
|
44 |
* Sets the specified {@link Color} to this vector layer properties. |
|
45 |
* |
|
46 |
* @param color |
|
47 |
* the specific color |
|
48 |
*/ |
|
49 |
public void setDefaultColor(Color color); |
|
50 |
|
|
51 |
/** |
|
52 | 15 |
* Gets name of height field used to set height of extruded features. |
53 | 16 |
* |
54 | 17 |
* @return |
... | ... | |
64 | 27 |
public void setHeightField(String heightField); |
65 | 28 |
|
66 | 29 |
/** |
67 |
* Gets constant height of this vector layer properties. |
|
68 |
* |
|
69 |
* @return the height of this properties. |
|
70 |
*/ |
|
71 |
public double getConstantHeight(); |
|
72 |
|
|
73 |
/** |
|
74 |
* Sets the specified constant height to this properties. |
|
75 |
* |
|
76 |
* @param height |
|
77 |
* the specified constant height. |
|
78 |
*/ |
|
79 |
public void setConstantHeight(double height); |
|
80 |
|
|
81 |
/** |
|
82 | 30 |
* Gets vertical exaggeration |
83 | 31 |
* |
84 | 32 |
* @return |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.vector/org.gvsig.view3d.vector.swing/org.gvsig.view3d.vector.swing.impl/src/main/java/org/gvsig/view3d/vector/swing/impl/JVectorExtrusionLoaderParametersController.java | ||
---|---|---|
3 | 3 |
import java.awt.event.ActionEvent; |
4 | 4 |
import java.awt.event.ActionListener; |
5 | 5 |
import java.util.Arrays; |
6 |
import java.util.Collections; |
|
6 | 7 |
import java.util.List; |
7 | 8 |
|
8 | 9 |
import javax.swing.JComponent; |
9 | 10 |
|
10 | 11 |
import org.apache.commons.lang3.StringUtils; |
12 |
import org.opengis.metadata.Datatype; |
|
11 | 13 |
import org.slf4j.Logger; |
12 | 14 |
import org.slf4j.LoggerFactory; |
13 | 15 |
|
... | ... | |
117 | 119 |
} |
118 | 120 |
FeatureAttributeDescriptor[] attributeDescriptors = featureType.getAttributeDescriptors(); |
119 | 121 |
for (FeatureAttributeDescriptor attDesc : attributeDescriptors) { |
120 |
heightField.addItem(attDesc.getName()); |
|
122 |
if(attDesc.getDataType().isNumeric()) { |
|
123 |
heightField.addItem(attDesc.getName()); |
|
124 |
} |
|
121 | 125 |
} |
126 |
if(StringUtils.isNotBlank(this.parameters.getHeightField()) && |
|
127 |
featureType.getAttributeDescriptor(this.parameters.getHeightField()) != null){ |
|
128 |
heightField.setSelectedItem(this.parameters.getHeightField()); |
|
129 |
constantHeightText.setEnabled(false); |
|
130 |
constantHeight.setEnabled(false); |
|
131 |
} |
|
122 | 132 |
} |
123 | 133 |
|
134 |
|
|
124 | 135 |
// Initialize change listeners |
125 | 136 |
this.heightField.addActionListener(new ActionListener() { |
126 | 137 |
|
Also available in: Unified diff