[Schmitzm-commits] r856 - trunk/src/schmitzm/geotools/gui
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri May 21 15:25:56 CEST 2010
Author: mojays
Date: 2010-05-21 15:25:55 +0200 (Fri, 21 May 2010)
New Revision: 856
Modified:
trunk/src/schmitzm/geotools/gui/ScalePanel.java
Log:
new enum DistanceUnit in ScalePanel
Modified: trunk/src/schmitzm/geotools/gui/ScalePanel.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/ScalePanel.java 2010-05-21 13:16:28 UTC (rev 855)
+++ trunk/src/schmitzm/geotools/gui/ScalePanel.java 2010-05-21 13:25:55 UTC (rev 856)
@@ -259,9 +259,18 @@
// maximale Breite fuer Skala (abzgl. 25 Pixel fuer Meter-Angabe)
final int maxW_pixel = getParent().getWidth() - 30;
final double maxW_meter = maxW_pixel * getScaleInMeters();
- // Ausmasse der Skala (stellt immer volle 10/100/1000/... Meter dar)
- final long scaleW_meter = (long)Math.pow(10, (long)Math.log10(maxW_meter));
- final int scaleW_pixel = (int)Math.round( scaleW_meter * getScaleInPixels() );
+
+ // Breite in Darstellungseinheit umrechnen
+ DistanceUnit dispUnit = units.getMainUnit();
+ double maxW_unit = DistanceUnit.METER.convertDistanceTo(maxW_meter, dispUnit);
+ if ( maxW_unit < 1 ) {
+ dispUnit = units.getSecondaryUnit();
+ units.getMainUnit().convertDistanceTo(maxW_unit, dispUnit);
+ }
+
+ // Ausmasse der Skala (stellt immer volle 10/100/1000/... Einheiten dar)
+ final long scaleW_unit = (long)Math.pow(10, (long)Math.log10(maxW_unit));
+ final int scaleW_pixel = (int)Math.round( scaleW_unit * getScaleInPixels() );
final int scaleH_pixel = getHeight()-1;
// Aufteilung in der Skala Teil-Balken
@@ -283,9 +292,7 @@
// Laengen-Angabe
g2.setFont( new JLabel().getFont() );
- //TODO This should be switchable from km to miles
- final String scaleString = convertScaleToLabelUnit(scaleW_meter,DistanceUnit.METER,units);
-
+ final String scaleString = convertScaleToLabelUnit(scaleW_unit,dispUnit,units);
g2.drawString(scaleString,scaleW_pixel+3,tileScaleHeight);
}
More information about the Schmitzm-commits
mailing list