Revision 45732 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/toolListeners/StatusBarListener.java

View differences:

StatusBarListener.java
33 33

  
34 34
import org.gvsig.andami.PluginServices;
35 35
import org.gvsig.andami.ui.mdiFrame.MainFrame;
36
import org.gvsig.fmap.geom.GeometryUtils;
36 37
import org.gvsig.fmap.mapcontext.MapContext;
37 38
import org.gvsig.fmap.mapcontrol.MapControl;
38 39
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
......
92 93
 */
93 94
public class StatusBarListener implements PointListener {
94 95
    
95
    private static Logger logger =
96
        LoggerFactory.getLogger(StatusBarListener.class);
97
	/**
96
    private static Logger logger = LoggerFactory.getLogger(StatusBarListener.class);
97

  
98
    private static final String DEGRESS_FORMAT = "%-%d? %m' %.0s''";
99
    
100
    /**
98 101
	 * Reference to the <code>MapControl</code> object that uses.
99 102
	 */
100 103
	private MapControl mapControl = null;
......
245 248
		return axisText;
246 249
	}
247 250

  
248
	/**
249
	 * <p>Converts a decimal value (expected latitude or longitude) in degrees, and formats it according this pattern:<br>
250
	 *  <code><b><i>S?G? M' S''</i></b></code>, having:<br>
251
	 *  <ul>
252
	 *   <li><i>S?</i> : optionally, if the value is negative, sets a "-" symbol.</li>
253
	 *   <li><i>G</i> : equivalent grades.</li>
254
	 *   <li><i>M</i> : equivalent minutes.</li>
255
	 *   <li><i>S</i> : equivalent seconds.</li>
256
	 *  </ul>
257
	 * </p>
258
	 *
259
	 * @param d the latitude or longitude value to convert
260
	 *
261
	 * @return value formatted in degrees
262
	 */
263
	private String formatDegrees(double d) {
264
		String signo = d<0 ? "-" : "";
265
		d = Math.abs(d);
266
		long grado = 0;
267
		double minuto = 0;
268
		double segundo = 0;
251
//	/**
252
//	 * <p>Converts a decimal value (expected latitude or longitude) in degrees, and formats it according this pattern:<br>
253
//	 *  <code><b><i>S?G? M' S''</i></b></code>, having:<br>
254
//	 *  <ul>
255
//	 *   <li><i>S?</i> : optionally, if the value is negative, sets a "-" symbol.</li>
256
//	 *   <li><i>G</i> : equivalent grades.</li>
257
//	 *   <li><i>M</i> : equivalent minutes.</li>
258
//	 *   <li><i>S</i> : equivalent seconds.</li>
259
//	 *  </ul>
260
//	 * </p>
261
//	 *
262
//	 * @param d the latitude or longitude value to convert
263
//	 *
264
//	 * @return value formatted in degrees
265
//	 */
266
//	private String formatDegrees(double d) {
267
////		String signo = d<0 ? "-" : "";
268
////		d = Math.abs(d);
269
////		long grado = 0;
270
////		double minuto = 0;
271
////		double segundo = 0;
272
////
273
////		grado = (long)(d);
274
////		minuto = (d - grado) * 60;
275
////		segundo = (minuto - (long) minuto)*60;
276
//////		System.out.println("Grados: " + grado);
277
//////		System.out.println("Minutos: " + minuto);
278
//////		System.out.println("Segundos: " + segundo);
279
////		return signo+grado+"? "+(long) minuto+"' "+(long)segundo+"''";
280
//                return GeometryUtils.formatCoordinate("%-%d? %m' %s''", d);
281
//	}
269 282

  
270
		grado = (long)(d);
271
		minuto = (d - grado) * 60;
272
		segundo = (minuto - (long) minuto)*60;
273
//		System.out.println("Grados: " + grado);
274
//		System.out.println("Minutos: " + minuto);
275
//		System.out.println("Segundos: " + segundo);
276
		return signo+grado+"? "+(long) minuto+"' "+(long)segundo+"''";
277
	}
278

  
279 283
	/**
280 284
	 * <p>Returns the coordinates equivalent to <code>p</code>:
281 285
	 *  <ul>
......
296 300
		String[] coords=new String[2];
297 301
		IProjection iProj = mapControl.getMapContext().getProjection();
298 302
		if (!iProj.isProjected()) {
299
			coords[0]=String.valueOf(formatDegrees(p.getX()));
300
			coords[1]=String.valueOf(formatDegrees(p.getY()));
303
			coords[0]=String.valueOf(GeometryUtils.formatCoordinate(DEGRESS_FORMAT, p.getX()));
304
			coords[1]=String.valueOf(GeometryUtils.formatCoordinate(DEGRESS_FORMAT, p.getY()));
301 305
		} else {
302 306
			double[] trans2Meter=MapContext.getDistanceTrans2Meter();
303 307
			if (PluginServices.getText(this,MapContext.getDistanceNames()[mapControl.getViewPort().getDistanceUnits()]).equals(PluginServices.getText(this,"Grados"))) {
......
305 309
				Point2D pgeo = null;
306 310
				try {
307 311
				    pgeo = iProj.toGeo(p);
308
	                coords[0]=String.valueOf(formatDegrees(pgeo.getX()));
309
	                coords[1]=String.valueOf(formatDegrees(pgeo.getY()));
312
	                coords[0]=String.valueOf(GeometryUtils.formatCoordinate(DEGRESS_FORMAT, pgeo.getX()));
313
	                coords[1]=String.valueOf(GeometryUtils.formatCoordinate(DEGRESS_FORMAT, pgeo.getY()));
310 314
				} catch (Exception exc) {
311 315
				    
312 316
				    if ((System.currentTimeMillis() - lastLogTime) > 5000) {

Also available in: Unified diff