Revision 37960 trunk/extensions/extGPE-gvSIG/src/org/gvsig/fmap/drivers/gpe/utils/GPETypesConversion.java
GPETypesConversion.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.drivers.gpe.utils; |
2 | 2 |
|
3 |
import java.awt.Color; |
|
4 |
|
|
3 | 5 |
import com.hardcode.gdbms.engine.values.Value; |
4 | 6 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
5 | 7 |
|
... | ... | |
54 | 56 |
*/ |
55 | 57 |
public class GPETypesConversion { |
56 | 58 |
|
59 |
public static Color fromABGRtoColor(String abgr) { |
|
60 |
long in = Long.decode("#"+ abgr); |
|
61 |
int alpha = (int) (in >> 24) & 0xFF; |
|
62 |
int blue = (int) (in >> 16) & 0xFF; |
|
63 |
int green = (int) (in >> 8) & 0xFF; |
|
64 |
int red = (int) (in >> 0) & 0xFF; |
|
65 |
return new Color(red, green, blue, alpha); |
|
66 |
} |
|
67 |
|
|
57 | 68 |
/** |
58 | 69 |
* Convert types from java to gvSIG |
70 |
* |
|
59 | 71 |
* @param obj |
60 | 72 |
* @return |
61 | 73 |
*/ |
62 |
public static Value fromJavaTogvSIG(Object obj){ |
|
63 |
if (obj instanceof String){ |
|
64 |
return ValueFactory.createValue((String)obj); |
|
74 |
public static Value fromJavaTogvSIG(Object obj) {
|
|
75 |
if (obj instanceof String) {
|
|
76 |
return ValueFactory.createValue((String) obj);
|
|
65 | 77 |
} |
66 |
if (obj instanceof Integer){ |
|
67 |
return ValueFactory.createValue(((Integer)obj).intValue()); |
|
78 |
if (obj instanceof Integer) {
|
|
79 |
return ValueFactory.createValue(((Integer) obj).intValue());
|
|
68 | 80 |
} |
69 |
if (obj instanceof Double){ |
|
70 |
return ValueFactory.createValue(((Double)obj).doubleValue()); |
|
81 |
if (obj instanceof Double) {
|
|
82 |
return ValueFactory.createValue(((Double) obj).doubleValue());
|
|
71 | 83 |
} |
72 |
if (obj instanceof Float){ |
|
73 |
return ValueFactory.createValue(((Float)obj).floatValue()); |
|
84 |
if (obj instanceof Float) {
|
|
85 |
return ValueFactory.createValue(((Float) obj).floatValue());
|
|
74 | 86 |
} |
75 |
if (obj instanceof Long){ |
|
76 |
return ValueFactory.createValue(((Long)obj).longValue()); |
|
87 |
if (obj instanceof Long) {
|
|
88 |
return ValueFactory.createValue(((Long) obj).longValue());
|
|
77 | 89 |
} |
78 |
if (obj instanceof Boolean){ |
|
79 |
return ValueFactory.createValue(((Boolean)obj).booleanValue()); |
|
90 |
if (obj instanceof Boolean) {
|
|
91 |
return ValueFactory.createValue(((Boolean) obj).booleanValue());
|
|
80 | 92 |
} |
81 | 93 |
return ValueFactory.createValue(""); |
82 |
} |
|
94 |
} |
|
95 |
|
|
96 |
public static double kmlDegToRad(double angleDegree) { |
|
97 |
double deg = 90-angleDegree; |
|
98 |
return Math.toRadians(angleDegree); |
|
99 |
} |
|
100 |
|
|
101 |
public static double RadTokmlDeg(double rad) { |
|
102 |
double angleDegree = Math.toDegrees(rad); |
|
103 |
double deg = angleDegree+90; |
|
104 |
return deg; |
|
105 |
} |
|
106 |
|
|
83 | 107 |
} |
Also available in: Unified diff