[Schmitzm-commits] r415 - in branches/1.0-gt2-2.6/src: gtmig/org/geotools/swing schmitzm/geotools/gui schmitzm/geotools/styling skrueger/geotools skrueger/geotools/selection
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Sep 24 19:58:33 CEST 2009
Author: alfonx
Date: 2009-09-24 19:58:32 +0200 (Thu, 24 Sep 2009)
New Revision: 415
Added:
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_DHDN.java
branches/1.0-gt2-2.6/src/skrueger/geotools/MapPaneToolSelectedListener.java
Modified:
branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeoMapPane.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanel.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_WGS84.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java
branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java
Log:
* GP-Feature: In the MapComposer it is now BASICALLY possible to change the CRS and format of the Grid/Ruler on the left/bottom. At the moment only two formatters are available, one for DHDN in Germany, and one for lat/lon.
Modified: branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java 2009-09-24 13:23:08 UTC (rev 414)
+++ branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java 2009-09-24 17:58:32 UTC (rev 415)
@@ -58,7 +58,6 @@
import javax.swing.JPanel;
import org.apache.log4j.Logger;
-import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.map.MapContext;
import org.geotools.map.event.MapLayerListEvent;
import org.geotools.map.event.MapLayerListListener;
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeoMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeoMapPane.java 2009-09-24 13:23:08 UTC (rev 414)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeoMapPane.java 2009-09-24 17:58:32 UTC (rev 415)
@@ -104,12 +104,12 @@
* Vertikale Koordinaten-Leiste (Grid). Zeigt die Latitude-Koordinate in
* Grad und Minutenm an.
*/
- protected GridPanel vertGrid = null;
+ private GridPanel vertGrid = null;
/**
* Horizontale Koordinaten-Leiste (Grid). Zeigt die Longitude-Koordinate in
* Grad und Minutenm an.
*/
- protected GridPanel horGrid = null;
+ private GridPanel horGrid = null;
/**
* A flag indicating if dispose() was already called. If true, then further
@@ -159,10 +159,10 @@
// Karte
this.mapPane = (mapPane != null) ? mapPane : new JMapPane(null,null,renderer, null, getDefaultRendererHints());
// Koordinaten-Leisten
- this.vertGrid = (vGrid != null) ? vGrid : new GridPanel(
- GridPanel.VERTICAL, this.mapPane);
- this.horGrid = (hGrid != null) ? hGrid : new GridPanel(
- GridPanel.HORIZONTAL, this.mapPane);
+ this.setVertGrid((vGrid != null) ? vGrid : new GridPanel(
+ GridPanel.VERTICAL, this.mapPane));
+ this.setHorGrid((hGrid != null) ? hGrid : new GridPanel(
+ GridPanel.HORIZONTAL, this.mapPane));
// Massstab-Balken
this.scalePane = (scalePane != null) ? scalePane : new ScalePane();
@@ -205,15 +205,15 @@
scalePane.setScale(sce.getNewScale());
}
if (e instanceof MapAreaChangedEvent) {
- vertGrid.repaint();
- horGrid.repaint();
+ getVertGrid().repaint();
+ getHorGrid().repaint();
}
}
});
// Komponenten in Layout anordnen
- this.add(vertGrid, layoutConstraints.get(DLC_VGRID));
- this.add(horGrid, layoutConstraints.get(DLC_HGRID));
+ this.add(getVertGrid(), layoutConstraints.get(DLC_VGRID));
+ this.add(getHorGrid(), layoutConstraints.get(DLC_HGRID));
this.add(scalePane, layoutConstraints.get(DLC_SCALE));
// WICHTIG: mapPane als LETZTES einfuegen, damit es beim Re-Paint ALS
// ERSTES
@@ -340,5 +340,21 @@
return defaultRendererHints;
}
+ public void setVertGrid(GridPanel vertGrid) {
+ this.vertGrid = vertGrid;
+ }
+ public GridPanel getVertGrid() {
+ return vertGrid;
+ }
+
+ public void setHorGrid(GridPanel horGrid) {
+ this.horGrid = horGrid;
+ }
+
+ public GridPanel getHorGrid() {
+ return horGrid;
+ }
+
+
}
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanel.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanel.java 2009-09-24 13:23:08 UTC (rev 414)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanel.java 2009-09-24 17:58:32 UTC (rev 415)
@@ -33,12 +33,14 @@
import java.awt.Graphics;
import java.awt.geom.AffineTransform;
+import javax.measure.unit.Unit;
+
import org.apache.log4j.Logger;
import org.geotools.referencing.CRS;
import org.geotools.referencing.operation.projection.PointOutsideEnvelopeException;
+import org.geotools.resources.CRSUtilities;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.operation.MathTransform;
import schmitzm.lang.LangUtil;
@@ -56,10 +58,10 @@
/** Laenge der Grid-Abschnitts-Linien. */
private static final int GRID_LINE_SIZE = 10;
- /** Container-Breite bei vertikalem Grid. */
- public static final int VERT_WIDTH = 50;
- /** Container-Hoehe bei horizontalem Grid. */
- public static final int HOR_HEIGHT = 20;
+// /** Container-Breite bei vertikalem Grid. */
+// public static final int VERT_WIDTH = 50;
+// /** Container-Hoehe bei horizontalem Grid. */
+// public static final int HOR_HEIGHT = 20;
/** Flag fuer ein horizontales Grid. */
public static final int HORIZONTAL = 1;
@@ -104,16 +106,15 @@
* verwendet)
*/
public GridPanel(int orientation, JMapPane mapPane, GridPanelFormatter formatter) {
- super();
this.orientation = orientation;
this.mapPane = mapPane;
setGridFormatter(formatter);
setXYIndexSwitchForced(false);
if ( isVertical() )
- SwingUtil.setPreferredWidth(this,VERT_WIDTH);
+ SwingUtil.setPreferredWidth(this,getGridFormatter().getWidthForVertical());
else
- SwingUtil.setPreferredHeight(this,HOR_HEIGHT);
+ SwingUtil.setPreferredHeight(this,getGridFormatter().getHeightForHorizontal());
}
/**
@@ -154,16 +155,34 @@
* wird ein {@link GridPanelFormatter_WGS84} verwendet)
*/
public void setGridFormatter(GridPanelFormatter formatter) {
- GridPanelFormatter oldFormatter = getGridFormatter();
+// GridPanelFormatter oldFormatter = getGridFormatter();
if ( formatter == null )
formatter = new GridPanelFormatter_WGS84();
this.formatter = formatter;
// wenn sich der Formatter geaendert hat, die Transformation initialisieren,
// diese beim naechsten paint(.) erneuert werden
- if ( getGridFormatter() != oldFormatter ) {
+
+// SK: Es kann auch der selbe GridFormatter mit einem anderen CRS sein.. deshalb erstmal trivial immer updaten.
+// if ( getGridFormatter() != oldFormatter || ) {
mapToGrid = null;
gridToMap = null;
- }
+// }
+
+ if ( isVertical() )
+ SwingUtil.setPreferredWidth(this,getGridFormatter().getWidthForVertical());
+ else
+ SwingUtil.setPreferredHeight(this,getGridFormatter().getHeightForHorizontal());
+
+
+ if (getParent() != null) {
+ getParent().invalidate();
+ getParent().repaint();
+ }
+
+ Unit<?> unit = CRSUtilities.getUnit( formatter.getCRS().getCoordinateSystem() );
+ if (unit != null) {
+ setToolTipText("Einheit: "+unit.toString()); //TODO i8n
+ } else setToolTipText(null);
}
@@ -267,12 +286,14 @@
// Neuer Versuch des WORKAROUND:
// Default: {Longitude,Latitude}, also {X,Y}
int idx = isHorizontal() ? 0 : 1;
+
+
// Wenn die CRS verdreht sind, ist auch das Resultat der Transformation verdreht
- boolean switchXY = isXYIndexSwitchForced() || !(mapCRS instanceof GeographicCRS ^ gridCRS instanceof GeographicCRS);
- if ( switchXY ) {
- LOGGER.debug("Coordinates switched!");
- idx = 1-idx;
- }
+// boolean switchXY = isXYIndexSwitchForced() || !(mapCRS instanceof GeographicCRS ^ gridCRS instanceof GeographicCRS);
+// if ( switchXY ) {
+// LOGGER.debug("Coordinates switched!");
+// idx = 1-idx;
+// }
// LOGGER.debug( isVertical() ? "V" : "H" );
// LOGGER.debug( "Min MCRS: "+mapMin_MCRS[0]+", "+mapMin_MCRS[1]+" GCRS:"+mapMin_GCRS[0]+", "+mapMin_GCRS[1]);
@@ -285,12 +306,12 @@
int maxSize = isHorizontal() ? getParent().getWidth() : getParent().getHeight();
// Passende Grid-Unterteilung in Grad
- double gridDist = formatter.determineGridDistance(mapMin,mapMax,maxSize);
+ double gridDist = formatter.determineGridDistance(this, mapMin,mapMax,maxSize);
// Leiste zeichnen
if ( isHorizontal() )
g.drawLine(0,0,maxSize,0);
else
- g.drawLine(VERT_WIDTH-1,0,VERT_WIDTH-1,maxSize);
+ g.drawLine(formatter.getWidthForVertical()-1,0,formatter.getWidthForVertical()-1,maxSize);
// Abschnitte zeichnen
double firstGrid = Math.ceil(mapMin/gridDist)*gridDist; // 1. Abschnitt in Lat bzw. Lon
@@ -310,13 +331,16 @@
}
// Grid-Abschnitt zeichnen
- int x1 = isVertical() ? VERT_WIDTH-GRID_LINE_SIZE : (int)grid_WINDOW[0];
+ int x1 = isVertical() ? formatter.getWidthForVertical()-GRID_LINE_SIZE : (int)grid_WINDOW[0];
int y1 = isVertical() ? (int)grid_WINDOW[1] : 0;
int x2 = isVertical() ? x1+GRID_LINE_SIZE : x1;
int y2 = isVertical() ? y1 : y1+GRID_LINE_SIZE;
g.drawLine(x1,y1,x2,y2);
- // Koordinate anzeigen
+ // Koordinate anzeigen, evt. Font setzen
+ if (formatter.getFont() != null) {
+ g.setFont( formatter.getFont() );
+ }
String coordStr = formatter.formatCoordinate(this, grid_GCRS[idx]);
x1 = isVertical() ? 5 : x1 + 5;
y1 = isVertical() ? y1-2 : y1 + 12;
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter.java 2009-09-24 13:23:08 UTC (rev 414)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter.java 2009-09-24 17:58:32 UTC (rev 415)
@@ -30,48 +30,106 @@
package schmitzm.geotools.gui;
+import java.awt.Font;
+import java.util.Vector;
+
+import org.apache.log4j.Logger;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import schmitzm.lang.LangUtil;
+
/**
- * This class defines how the {@link GridPanel} shows the coordinate
- * grid and the coordinates.
+ * This class defines how the {@link GridPanel} shows the coordinate grid and
+ * the coordinates.
+ *
* @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
*/
public abstract class GridPanelFormatter {
- /** CRS the formatter is created for. */
- protected CoordinateReferenceSystem crs = null;
-
- /**
- * Creates a new formatter.
- * @param crs the CRS the formatter can format
- */
- public GridPanelFormatter(CoordinateReferenceSystem crs) {
- this.crs = crs;
- }
-
- /**
- * Returns the CRS the formatter can format.
- */
- public CoordinateReferenceSystem getCRS() {
- return crs;
- }
-
-
- /**
- * Determines a "fitting" fragmentation for the grid.
- * @param mapMinCoord minimal coordinate to show in the grid (in the grid CRS)
- * @param mapMaxCoord maximal coordinate to show in the grid (in the grid CRS)
- * @param panelSize size of the grid panel in pixels
- */
- public abstract double determineGridDistance(double mapMinCoord, double mapMaxCoord, int panelSize);
+ private static final Logger LOGGER = LangUtil
+ .createLogger(GridPanelFormatter.class);
+
+ /** A human readable title**/
+ public abstract String getTitle();
-
- /**
- * Formats a coordinate for the grid CRS.
- * @param coord the coordinate
- * @param gridPanel indicates (amongst others) the grid orientation
- * @return
- */
- public abstract String formatCoordinate(GridPanel panel, double coord);
+ /** CRS the formatter is created for. */
+ protected CoordinateReferenceSystem crs = null;
+ /**
+ * @return List of instances of all available formatters.
+ */
+ static public Vector<GridPanelFormatter> getAvailableFormatters() {
+ Vector<GridPanelFormatter> formatters = new Vector<GridPanelFormatter>();
+ formatters.add(new GridPanelFormatter_WGS84());
+ try {
+ formatters.add(new GridPanelFormatter_DHDN());
+ } catch (Exception e) {
+ LOGGER.error("No able to create the default DHDN CRS", e);
+ }
+ return formatters;
+ }
+
+ /**
+ * Creates a new formatter.
+ *
+ * @param crs
+ * the CRS the formatter can format
+ */
+ public GridPanelFormatter(CoordinateReferenceSystem crs) {
+ this.crs = crs;
+ }
+
+ /**
+ * Returns the CRS the formatter can format.
+ */
+ public CoordinateReferenceSystem getCRS() {
+ return crs;
+ }
+
+ /**
+ * Returns the CRS the formatter can format.
+ */
+ public void setCRS(CoordinateReferenceSystem crs) {
+ this.crs = crs;
+ }
+
+ /**
+ * Determines a "fitting" fragmentation for the grid.
+ *
+ * @param gridPanel
+ * indicates (amongst others) the grid orientation
+ * @param mapMinCoord
+ * minimal coordinate to show in the grid (in the grid CRS)
+ * @param mapMaxCoord
+ * maximal coordinate to show in the grid (in the grid CRS)
+ * @param panelSize
+ * size of the grid panel in pixels
+ */
+ public abstract double determineGridDistance(GridPanel panel,
+ double mapMinCoord, double mapMaxCoord, int panelSize);
+
+ /**
+ * Formats a coordinate for the grid CRS.
+ *
+ * @param coord
+ * the coordinate
+ * @param gridPanel
+ * indicates (amongst others) the grid orientation
+ * @return
+ */
+ public abstract String formatCoordinate(GridPanel panel, double coord);
+
+ /**
+ * Returns the default width for a vertical Grid
+ */
+ public abstract int getWidthForVertical();
+
+ /**
+ * Returns the default height for a horizontal Grid
+ */
+ public abstract int getHeightForHorizontal();
+
+ public Font getFont() {
+ return null;
+ }
+
}
Added: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_DHDN.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_DHDN.java 2009-09-24 13:23:08 UTC (rev 414)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_DHDN.java 2009-09-24 17:58:32 UTC (rev 415)
@@ -0,0 +1,100 @@
+package schmitzm.geotools.gui;
+
+import java.awt.Font;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
+
+import javax.swing.JLabel;
+
+import org.geotools.referencing.CRS;
+import org.opengis.referencing.FactoryException;
+import org.opengis.referencing.NoSuchAuthorityCodeException;
+
+public class GridPanelFormatter_DHDN extends GridPanelFormatter {
+
+ /**
+ * Creates a new formatter with DHDN / 3-degree Gauss zone 1 as CRS
+ *
+ * @param crs
+ * the CRS the formatter can format
+ * @throws FactoryException
+ * @throws NoSuchAuthorityCodeException
+ */
+ public GridPanelFormatter_DHDN() throws NoSuchAuthorityCodeException,
+ FactoryException {
+
+ // # DHDN / 3-degree Gauss zone 1
+ // <31461> +proj=tmerc +lat_0=0 +lon_0=3 +k=1.000000 +x_0=1500000 +y_0=0
+
+ super(CRS.decode("EPSG:31461"));
+ }
+
+ @Override
+ public double determineGridDistance(GridPanel panel, double mapMinCoord,
+ double mapMaxCoord, int panelSize) {
+ double diff = Math.abs(mapMinCoord - mapMaxCoord);
+
+ double dist;
+ if (diff > 100000) {
+ dist = Math.round(diff / 10000.) * 1000.;
+ } else if (diff > 10000) {
+ dist = Math.round(diff / 1000.) * 100.;
+ }
+ if (diff > 1000) {
+ dist = Math.round(diff / 100.) * 10.;
+ } else
+ dist = 10;
+
+ // Solange der Abstand zwischen 2 Unterteilungen weniger als 40/100
+ // Pixel
+ // betraegt --> Unterteilung verdoppeln
+ while (diff != 0 && dist != 0
+ && panelSize / (diff / dist) < (panel.isVertical() ? 40 : 100))
+ dist *= 2;
+
+ // Solange der Abstand zwischen 2 Unterteilungen mehr als 120/300 Pixel
+ // betraegt --> Unterteilung habieren
+ while (diff != 0 && dist != 0
+ && panelSize / (diff / dist) > (panel.isVertical() ? 120 : 300))
+ dist /= 2;
+
+ return dist;
+ }
+
+ DecimalFormat numFormat = new DecimalFormat("###,###,###", new DecimalFormatSymbols(Locale.getDefault()));
+ @Override
+ public String formatCoordinate(GridPanel panel, double coord) {
+
+
+ if (panel.isVertical()) {
+ return numFormat.format(coord) + "H";
+ } else {
+ return numFormat.format(coord) + "R";
+ }
+
+ }
+
+ private static final Font font = new Font(Font.MONOSPACED, Font.PLAIN, 11);
+
+ @Override
+ public Font getFont() {
+ return font;
+ }
+
+ @Override
+ public int getHeightForHorizontal() {
+ return new JLabel().getFontMetrics(font).getHeight() + 2;
+ }
+
+ @Override
+ public int getWidthForVertical() {
+ return 80;
+ }
+
+ @Override
+ public String getTitle() {
+ // TODO localize
+ return numFormat.format(1234567)+" R";
+ }
+}
Property changes on: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_DHDN.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id URL
Name: svn:eol-style
+ native
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_WGS84.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_WGS84.java 2009-09-24 13:23:08 UTC (rev 414)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_WGS84.java 2009-09-24 17:58:32 UTC (rev 415)
@@ -30,8 +30,11 @@
package schmitzm.geotools.gui;
+import java.awt.Font;
import java.text.DecimalFormat;
+import javax.swing.JLabel;
+
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
@@ -39,83 +42,123 @@
/**
* This class defines a {@link GridPanelFormatter} for the WGS84
- * {@link CoordinateReferenceSystem}.
- * The coordinates are formated in degrees and minutes along with
- * the wind direction abbreviation (E/W, N/S).
- * grid and the coordinates. * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ * {@link CoordinateReferenceSystem}. The coordinates are formated in degrees
+ * and minutes along with the wind direction abbreviation (E/W, N/S). grid and
+ * the coordinates. * @author <a href="mailto:martin.schmitz at koeln.de">Martin
+ * Schmitz</a>
*/
public class GridPanelFormatter_WGS84 extends GridPanelFormatter {
- private static final ResourceProvider RES = GeotoolsGUIUtil.RESOURCE;
- private static final DecimalFormat numFormat = new DecimalFormat("###,###,##0");
+ private static final ResourceProvider RES = GeotoolsGUIUtil.RESOURCE;
+ private static final DecimalFormat numFormat = new DecimalFormat(
+ "###,###,##0");
- /**
- * Creates a new formatter.
- * @param crs the CRS the formatter can format
- */
- public GridPanelFormatter_WGS84() {
- //super(GTUtil.WGS84);
- super(DefaultGeographicCRS.WGS84);
- }
-
- /**
- * Formats a coordinate to degrees and minutes.
- * @param coord the lat/lon coordinate
- * @param gridPanel indicates (amongst others) the grid orientation
- * @return
- */
- @Override
- public String formatCoordinate(GridPanel panel, double coord) {
- int degrees = (int)coord;
- int minutes = (int)Math.round((coord-degrees)*60 );
- // Aufgrund des Minuten-Systems kann schlecht im Vorhinein gerundet
- // werden. Deshalb wird im Nachhinein ein etwaiger Rundungsfehler
- // ausgeglichen
- if ( Math.abs(minutes) >= 60 ) {
- degrees += Math.signum(minutes);
- minutes -= Math.signum(minutes) * 60;
- }
- String coordStr = Math.abs(degrees)+"°"+Math.abs(minutes)+"'";
- if ( degrees != 0 || minutes != 0 ) {
- if (panel.isVertical())
- coordStr += RES.getString( (coord < 0) ? "schmitzm.geotools.gui.GeotoolsGUIUtil.SOUTH.Abb" : "schmitzm.geotools.gui.GeotoolsGUIUtil.NORTH.Abb" );
- else
- coordStr += RES.getString( (coord < 0) ? "schmitzm.geotools.gui.GeotoolsGUIUtil.WEST.Abb" : "schmitzm.geotools.gui.GeotoolsGUIUtil.EAST.Abb" );
- }
- return coordStr;
- }
+ /**
+ * Creates a new formatter.
+ *
+ * @param crs
+ * the CRS the formatter can format
+ */
+ public GridPanelFormatter_WGS84() {
+ // super(GTUtil.WGS84);
+ super(DefaultGeographicCRS.WGS84);
+ }
- /**
- * Determines a "fitting" fragmentation for the grid.
- * @param mapMin_LL minimal Lat/Lon coordinate to show in the grid
- * @param mapMax_LL maximal Lat/Lon coordinate to show in the grid
- * @param panelSize size of the grid panel in pixels
- */
- @Override
- public double determineGridDistance(double mapMin_LL, double mapMax_LL, int panelSize) {
- // Differenz zwischen Min/Max-Koordinaten = darzustellender Bereich in Grad
- double diff = Math.abs( mapMin_LL - mapMax_LL );
- // Distanz zwischen zwei Unterteilungen in Grad
- double dist = 0.0;
- if ( diff < 10/60.0 ) // < 10 Min. --> 1 Min.-Aufteilung
- dist = 1/60.0;
- else if ( diff < 30/60.0 ) // < 30 Min. --> 5 Min.-Aufteilung
- dist = 5/60.0;
- else if ( diff < 1 ) // < 1? --> 10 Min.-Aufteilung
- dist = 10/60.0;
- else if ( diff < 3 ) // < 3? --> 15 Min.-Aufteilung
- dist = 15/60.0;
- else if ( diff < 5 ) // < 5? --> 30 Min.-Aufteilung
- dist = 30/60.0;
- else if ( diff < 11 ) // < 11? --> 1?-Aufteilung
- dist = 1;
- else // sonst --> 2?-Aufteilung
- dist = 2;
+ /**
+ * Formats a coordinate to degrees and minutes.
+ *
+ * @param coord
+ * the lat/lon coordinate
+ * @param gridPanel
+ * indicates (amongst others) the grid orientation
+ * @return
+ */
+ @Override
+ public String formatCoordinate(GridPanel panel, double coord) {
+ int degrees = (int) coord;
+ int minutes = (int) Math.round((coord - degrees) * 60);
+ // Aufgrund des Minuten-Systems kann schlecht im Vorhinein gerundet
+ // werden. Deshalb wird im Nachhinein ein etwaiger Rundungsfehler
+ // ausgeglichen
+ if (Math.abs(minutes) >= 60) {
+ degrees += Math.signum(minutes);
+ minutes -= Math.signum(minutes) * 60;
+ }
+ String coordStr = Math.abs(degrees) + "°" + Math.abs(minutes) + "'";
+ if (degrees != 0 || minutes != 0) {
+ if (panel.isVertical())
+ coordStr += RES
+ .getString((coord < 0) ? "schmitzm.geotools.gui.GeotoolsGUIUtil.SOUTH.Abb"
+ : "schmitzm.geotools.gui.GeotoolsGUIUtil.NORTH.Abb");
+ else
+ coordStr += RES
+ .getString((coord < 0) ? "schmitzm.geotools.gui.GeotoolsGUIUtil.WEST.Abb"
+ : "schmitzm.geotools.gui.GeotoolsGUIUtil.EAST.Abb");
+ }
+ return coordStr;
+ }
- // Solange der Abstand zwischen 2 Unterteilungen weniger als 40 Pixel
- // betraegt --> Unterteilung verdoppeln
- while ( diff != 0 && dist != 0 && panelSize / (diff / dist) < 40 )
- dist *=2;
+ /**
+ * Determines a "fitting" fragmentation for the grid.
+ *
+ * @param mapMin_LL
+ * minimal Lat/Lon coordinate to show in the grid
+ * @param mapMax_LL
+ * maximal Lat/Lon coordinate to show in the grid
+ * @param panelSize
+ * size of the grid panel in pixels
+ */
+ @Override
+ public double determineGridDistance(GridPanel panel, double mapMin_LL,
+ double mapMax_LL, int panelSize) {
+ // Differenz zwischen Min/Max-Koordinaten = darzustellender Bereich in
+ // Grad
+ double diff = Math.abs(mapMin_LL - mapMax_LL);
+ // Distanz zwischen zwei Unterteilungen in Grad
+ double dist = 0.0;
+ if (diff < 10 / 60.0) // < 10 Min. --> 1 Min.-Aufteilung
+ dist = 1 / 60.0;
+ else if (diff < 30 / 60.0) // < 30 Min. --> 5 Min.-Aufteilung
+ dist = 5 / 60.0;
+ else if (diff < 1) // < 1? --> 10 Min.-Aufteilung
+ dist = 10 / 60.0;
+ else if (diff < 3) // < 3? --> 15 Min.-Aufteilung
+ dist = 15 / 60.0;
+ else if (diff < 5) // < 5? --> 30 Min.-Aufteilung
+ dist = 30 / 60.0;
+ else if (diff < 11) // < 11? --> 1?-Aufteilung
+ dist = 1;
+ else
+ // sonst --> 2?-Aufteilung
+ dist = 2;
- return dist;
- }
+ // Solange der Abstand zwischen 2 Unterteilungen weniger als 40 Pixel
+ // betraegt --> Unterteilung verdoppeln
+ while (diff != 0 && dist != 0 && panelSize / (diff / dist) < 40)
+ dist *= 2;
+
+ return dist;
+ }
+
+ private static final Font font = new Font(Font.MONOSPACED, Font.PLAIN, 11);
+
+ @Override
+ public Font getFont() {
+ return font;
+ }
+
+ @Override
+ public int getHeightForHorizontal() {
+ return new JLabel().getFontMetrics(font).getHeight() + 2;
+ }
+
+ @Override
+ public int getWidthForVertical() {
+ return new JLabel().getFontMetrics(font).stringWidth("90°30' N") + 2;
+ }
+
+ @Override
+ public String getTitle() {
+ // TODO localize
+ return "22°33'44 N";
+ }
}
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java 2009-09-24 13:23:08 UTC (rev 414)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java 2009-09-24 17:58:32 UTC (rev 415)
@@ -1565,6 +1565,7 @@
Symbolizer[] symbolizers = new Symbolizer[0];
+
switch (geometryForm) {
case POINT:
@@ -1611,43 +1612,8 @@
.createPolygonSymbolizer(outline, fill);
symbolizers = LangUtil.extendArray(symbolizers, polS0);
}
-// { // White
-// Mark dots = STYLE_BUILDER.createMark("shape://slash");
-// dots.setStroke(STYLE_BUILDER.createStroke(Color.white, 2.));
-// Graphic fillGraphic = STYLE_BUILDER.createGraphic(null, dots,
-// null);
-// fillGraphic.setSize(FILTER_FACTORY.literal(4.));
-// Fill fill = STYLE_BUILDER.createFill();
-// fill.setGraphicFill(fillGraphic);
-// PolygonSymbolizer polS0 = STYLE_BUILDER
-// .createPolygonSymbolizer(null, fill);
+// PolygonSymbolizer polS0 = STYLE_BUILDER.createPolygonSymbolizer(Color.RED);
// symbolizers = LangUtil.extendArray(symbolizers, polS0);
-// }
-// { // Black
-// Mark dots = STYLE_BUILDER.createMark("shape://slash");
-// dots.setStroke(STYLE_BUILDER.createStroke(Color.black, 2.));
-// Graphic fillGraphic = STYLE_BUILDER.createGraphic(null, dots,
-// null);
-// fillGraphic.setSize(FILTER_FACTORY.literal(8.));
-// Fill fill = STYLE_BUILDER.createFill();
-// fill.setGraphicFill(fillGraphic);
-// PolygonSymbolizer polS0 = STYLE_BUILDER
-// .createPolygonSymbolizer(outline, fill);
-// symbolizers = LangUtil.extendArray(symbolizers, polS0);
-// }
-//
-// { // Yellow
-// Mark dots = STYLE_BUILDER.createMark("shape://dot");
-// dots.setStroke(STYLE_BUILDER.createStroke(Color.yellow.brighter()));
-// Graphic fillGraphic = STYLE_BUILDER.createGraphic(null, dots,
-// null);
-// fillGraphic.setSize(FILTER_FACTORY.literal(5.));
-// Fill fill = STYLE_BUILDER.createFill();
-// fill.setGraphicFill(fillGraphic);
-// PolygonSymbolizer polS0 = STYLE_BUILDER
-// .createPolygonSymbolizer(null, fill);
-// symbolizers = LangUtil.extendArray(symbolizers, polS0);
-// }
break;
Added: branches/1.0-gt2-2.6/src/skrueger/geotools/MapPaneToolSelectedListener.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/MapPaneToolSelectedListener.java 2009-09-24 13:23:08 UTC (rev 414)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/MapPaneToolSelectedListener.java 2009-09-24 17:58:32 UTC (rev 415)
@@ -0,0 +1,7 @@
+package skrueger.geotools;
+
+public interface MapPaneToolSelectedListener {
+
+ public void toolSelected( int toolId) ;
+
+}
Property changes on: branches/1.0-gt2-2.6/src/skrueger/geotools/MapPaneToolSelectedListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id URL
Name: svn:eol-style
+ native
Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java 2009-09-24 13:23:08 UTC (rev 414)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java 2009-09-24 17:58:32 UTC (rev 415)
@@ -169,6 +169,13 @@
*/
private void changeLayerStyle(final Vector<String> newSelection) {
try {
+// GTRenderer r = mapPane.getRenderer();
+// if (r instanceof ShapefileRenderer) {
+// ShapefileRenderer sfr = (ShapefileRenderer)r;
+// sfr.setCaching(false);
+// }
+//
+
Style originalStyle = mapLayer.getStyle();
if (newSelection.isEmpty()) {
@@ -244,7 +251,13 @@
// Refresh the map
mapPane.refresh();
}
+//
+// if (r instanceof ShapefileRenderer) {
+// ShapefileRenderer sfr = (ShapefileRenderer)r;
+// sfr.setCaching(true);
+// }
+
} catch (Exception e) {
LOGGER.error("Error while trying to create a selection style", e);
}
More information about the Schmitzm-commits
mailing list