82 |
82 |
|
83 |
83 |
private static Logger logger = Logger.getLogger(Attributes.class);
|
84 |
84 |
/** Array of doubles containg the change factro from <b>CENTIMETERS</b> to KILOMETERS, METERS, CENTIMETERS, MILLIMETERS, MILES, YARDS, FEET, INCHES, DECIMAL DEGREES*/
|
85 |
|
/* Do not alter the order and the values of this array, if you need append values.*/
|
86 |
|
public static final double[] CHANGE = {
|
87 |
|
100000, 100, 1, 0.1, 160934.4, 91.44, 30.48, 2.54, 8.983152841195214E-6
|
88 |
|
};
|
|
85 |
/* Do not alter the order and the values of this array, if you need append values.
|
|
86 |
* jlopez: this array should not be used any longer, as MapContext has the updated
|
|
87 |
* array of units, not Attributes. It's kept as a legacy in case any extension
|
|
88 |
* still uses it, but it's not guaranteed to work with units added by extensions. */
|
|
89 |
public static final double[] CHANGE = MapContext.getDistanceTrans2Centimeter();
|
89 |
90 |
public static final String DEGREES="Grados";
|
90 |
|
/* Do not alter the order and the values of this array, if you need append values.*/
|
|
91 |
/* Do not alter the order and the values of this array, if you need append values.
|
|
92 |
* jlopez: this code should not be here, MapContext should store all the info
|
|
93 |
* related to measure units. This duplicity can lead to future problems. */
|
91 |
94 |
public static final double[] UNIT = {
|
92 |
95 |
0.0000025, 0.0025, 0.25, 2.5, 0.0000025, 0.025, 0.025, 0.25, 8.8E-7
|
93 |
96 |
};
|
... | ... | |
182 |
185 |
private MediaSizeName m_type = MediaSizeName.ISO_A4;
|
183 |
186 |
private boolean m_isLandSel;
|
184 |
187 |
private OrientationRequested m_Orientation;
|
185 |
|
private double m_TypeUnit = CHANGE[2]; //CENTIMETROS;
|
|
188 |
private double m_TypeUnit = MapContext.
|
|
189 |
getDistanceTrans2Centimeter()[MapContext.
|
|
190 |
getDistancePosition("Centimetros")]; //CENTIMETROS;
|
186 |
191 |
private String m_NameUnit;
|
187 |
192 |
private Double m_numX=null;
|
188 |
193 |
private Double m_numY=null;
|
... | ... | |
1008 |
1013 |
* @param sel Type of unit.
|
1009 |
1014 |
*/
|
1010 |
1015 |
public void setUnit(int sel) {
|
|
1016 |
double[] CHANGE = MapContext.getDistanceTrans2Centimeter();
|
1011 |
1017 |
m_selTypeUnit = sel;
|
1012 |
1018 |
m_TypeUnit = CHANGE[sel];
|
1013 |
1019 |
m_NameUnit = PluginServices.getText(this,MapContext.getDistanceNames()[sel]);
|
1014 |
|
m_numX = m_numY = new Double(UNIT[sel]);
|
|
1020 |
m_numX = m_numY = (sel >= UNIT.length) ? new Double(UNIT[2] / CHANGE[sel]) : new Double(UNIT[sel]);
|
1015 |
1021 |
}
|
1016 |
1022 |
|
1017 |
1023 |
/**
|
... | ... | |
1067 |
1073 |
*/
|
1068 |
1074 |
public double getPixXCm(Rectangle2D rect) {
|
1069 |
1075 |
double value = m_sizePaper.getAncho();
|
1070 |
|
double cm = CHANGE[2];
|
|
1076 |
int cmPos = MapContext.getDistancePosition("Centimetros");
|
|
1077 |
double cm = MapContext.getDistanceTrans2Centimeter()[cmPos];
|
1071 |
1078 |
double unidades = 0;
|
1072 |
1079 |
unidades = ((rect.getMaxX() - rect.getMinX()) /((value / cm)));
|
1073 |
1080 |
return unidades;
|