gvsig-3d / 2.1 / branches / extrusion / org.gvsig.view3d.lib / org.gvsig.view3d.lib.api / src / main / java / org / gvsig / view3d / lib / api / E3DElevationModes.java @ 657
History | View | Annotate | Download (4.65 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright © 2007-2016 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.view3d.lib.api; |
26 |
|
27 |
import org.gvsig.fmap.dal.exception.ReadException; |
28 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
29 |
import org.gvsig.fmap.geom.type.GeometryType; |
30 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
31 |
import org.gvsig.tools.ToolsLocator; |
32 |
|
33 |
import gov.nasa.worldwind.WorldWind; |
34 |
|
35 |
/**
|
36 |
* The available elevation modes that can be used for 3d.
|
37 |
*
|
38 |
* @author Andrea Antonello andrea.antonello@gmail.com
|
39 |
*/
|
40 |
public enum E3DElevationModes { |
41 |
ABSOLUTE(ToolsLocator.getI18nManager().getTranslation("Absolute"), WorldWind.ABSOLUTE), // |
42 |
RELATIVE_TO_GROUND(ToolsLocator.getI18nManager().getTranslation("Relative to ground"),
|
43 |
WorldWind.RELATIVE_TO_GROUND), //
|
44 |
CLAMP_TO_GROUND(ToolsLocator.getI18nManager().getTranslation("Clamp to ground"), WorldWind.CLAMP_TO_GROUND), // |
45 |
CONSTANT(ToolsLocator.getI18nManager().getTranslation("Constant"), WorldWind.CONSTANT);// |
46 |
|
47 |
private String title; |
48 |
private int value; |
49 |
|
50 |
/**
|
51 |
*
|
52 |
* @param title
|
53 |
* a title/name to be used in labels.
|
54 |
* @param isRaster
|
55 |
* if <code>true</code>, the mode has to be available for
|
56 |
* raster data types.
|
57 |
*/
|
58 |
private E3DElevationModes(String title, int value) { |
59 |
this.title = title;
|
60 |
this.value = value;
|
61 |
} |
62 |
|
63 |
public int getValue() { |
64 |
return value;
|
65 |
} |
66 |
|
67 |
public String getTitle() { |
68 |
return title;
|
69 |
} |
70 |
|
71 |
public static String[] getExtrudedModeNames(FLyrVect vectorLayer) throws ReadException { |
72 |
GeometryType geometryType = vectorLayer.getGeometryType(); |
73 |
if (geometryType.isTypeOf(TYPES.SURFACE) || geometryType.isTypeOf(TYPES.MULTISURFACE)) {
|
74 |
return new String[] { RELATIVE_TO_GROUND.getTitle(), ABSOLUTE.getTitle() }; |
75 |
} else if (geometryType.isTypeOf(TYPES.CURVE) || geometryType.isTypeOf(TYPES.MULTICURVE)) { |
76 |
return new String[] { RELATIVE_TO_GROUND.getTitle(), ABSOLUTE.getTitle() }; |
77 |
} else if (geometryType.isTypeOf(TYPES.POINT) || geometryType.isTypeOf(TYPES.MULTIPOINT)) { |
78 |
return new String[] { RELATIVE_TO_GROUND.getTitle(), ABSOLUTE.getTitle() }; |
79 |
} else {
|
80 |
throw new IllegalArgumentException("Unable to load layer of type: " + geometryType); |
81 |
} |
82 |
} |
83 |
|
84 |
public static String[] getNormalModeNames(FLyrVect vectorLayer) throws ReadException { |
85 |
GeometryType geometryType = vectorLayer.getGeometryType(); |
86 |
if (geometryType.isTypeOf(TYPES.SURFACE) || geometryType.isTypeOf(TYPES.MULTISURFACE)) {
|
87 |
return new String[] { CLAMP_TO_GROUND.getTitle(), ABSOLUTE.getTitle(), RELATIVE_TO_GROUND.getTitle() }; |
88 |
} else if (geometryType.isTypeOf(TYPES.CURVE) || geometryType.isTypeOf(TYPES.MULTICURVE)) { |
89 |
return new String[] { CLAMP_TO_GROUND.getTitle(), ABSOLUTE.getTitle(), RELATIVE_TO_GROUND.getTitle() }; |
90 |
} else if (geometryType.isTypeOf(TYPES.POINT) || geometryType.isTypeOf(TYPES.MULTIPOINT)) { |
91 |
return new String[] { CLAMP_TO_GROUND.getTitle(), ABSOLUTE.getTitle(), RELATIVE_TO_GROUND.getTitle() }; |
92 |
} else {
|
93 |
throw new IllegalArgumentException("Unable to load layer of type: " + geometryType); |
94 |
} |
95 |
} |
96 |
|
97 |
public static E3DElevationModes getModeFromValue(int value) { |
98 |
for (E3DElevationModes mode : values()) {
|
99 |
if (mode.getValue() == value) {
|
100 |
return mode;
|
101 |
} |
102 |
} |
103 |
throw new RuntimeException("Can't understand mode: " + value); |
104 |
} |
105 |
|
106 |
public static E3DElevationModes getModeFromTitle(String title) { |
107 |
for (E3DElevationModes mode : values()) {
|
108 |
if (mode.getTitle().equals(title)) {
|
109 |
return mode;
|
110 |
} |
111 |
} |
112 |
throw new RuntimeException("Can't understand mode: " + title); |
113 |
} |
114 |
|
115 |
} |