fixes_special_measure_units.patch

Jorge López Fernández, 06/18/2012 01:04 PM

Download (5.82 KB)

View differences:

applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/Attributes.java (working copy)
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;
applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/FLayoutUtilities.java (working copy)
53 53

  
54 54
import org.cresques.cts.IProjection;
55 55

  
56
import com.iver.cit.gvsig.fmap.MapContext;
56 57
import com.iver.cit.gvsig.fmap.ViewPort;
57 58

  
58 59

  
......
313 314
			return 0;
314 315
		}
315 316

  
317
		double change[] = MapContext.getDistanceTrans2Centimeter();
316 318
		if (proj == null || viewPort.getImageSize() == null) {
317
			return (long) (viewPort.getAdjustedExtent().getHeight() / wcm * Attributes.CHANGE[viewPort
319
			return (long) (viewPort.getAdjustedExtent().getHeight() / wcm * change[viewPort
318 320
																					.getMapUnits()]);
319 321
		}
320 322

  
applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/fframes/FFrameScaleBar.java (working copy)
97 97
    private int m_numleft = 2;
98 98
    private double m_height = 0;
99 99
    private FFrameView fframeview = null;
100
    private double m_typeUnit = Attributes.CHANGE[1]; //METROS;
100
    private double m_typeUnit = MapContext.
101
			getDistanceTrans2Centimeter()[MapContext.
102
			                              getDistancePosition("Metros")]; //METROS;
101 103
    private String m_nameUnit = null;
102 104
    private double m_numUnit = 0;
103 105
    private double m_dif = 1;
libraries/libFMap/src/com/iver/cit/gvsig/fmap/MapContext.java (working copy)
230 230
		}
231 231
		return trans2meters;
232 232
	}
233
	public static double[] getDistanceTrans2Centimeter(){
234
		int size=DISTANCETRANS2METER.size();
235
		double[] trans2centimeters=new double[size];
236
		for (int i = 0; i < size; i++) {
237
			trans2centimeters[i]=((Double)DISTANCETRANS2METER.get(i)).doubleValue()*100;
238
		}
239
		return trans2centimeters;
240
	}
233 241
	public static int getDistancePosition(String s){
234 242
		for (int i = 0; i < DISTANCENAMES.size(); i++) {
235 243
			if (DISTANCENAMES.get(i).equals(s)){