[Schmitzm-commits] r551 - in branches/1.0-gt2-2.6/src: schmitzm/geotools/gui schmitzm/geotools/styling skrueger/geotools skrueger/geotools/labelsearch

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Nov 23 16:47:08 CET 2009


Author: alfonx
Date: 2009-11-23 16:47:04 +0100 (Mon, 23 Nov 2009)
New Revision: 551

Modified:
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureCollectionFilterPanel.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureLayerFilterDialog.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureTablePane.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/JEditorPane.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/LayeredMapFrame.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/LayeredMapPane.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/MapContextControlPane.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/RasterPositionLabel.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/SelectXMapPaneMouseListener.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/labelsearch/LabelSearch.java
Log:
* FilterTableDialog now a bit faster again because restructure is only called once...* 
* Renamed XMapPane.getConext to getMapContext

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureCollectionFilterPanel.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureCollectionFilterPanel.java	2009-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureCollectionFilterPanel.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -70,10 +70,10 @@
 import schmitzm.swing.SwingUtil;
 
 /**
- * Diese Klasse stellt ein Panel zur Verfuegung, mit der ein
- * {@link Filter} in Form einer arithmetischen (und boolschen) Formel
- * erstellt werden kann. Wie der String geparst wird (z.B. CQL), wird durch einen
- * {@link FilterParser} bestimmt.<br>
+ * Diese Klasse stellt ein Panel zur Verfuegung, mit der ein {@link Filter} in
+ * Form einer arithmetischen (und boolschen) Formel erstellt werden kann. Wie
+ * der String geparst wird (z.B. CQL), wird durch einen {@link FilterParser}
+ * bestimmt.<br>
  * Neben den Komponenten zur Definition/Eingabe des Filters enthaelt das Panel
  * einen Vorschau-Bereich, in dem eine {@link FeatureCollection} angezeigt wird,
  * auf der der Filter angewandt wird.
@@ -165,7 +165,7 @@
 	/** Speichert, ob im Vorschau-Panel eine grafische Anzeige erscheinen soll */
 	private boolean geomPrev = false;
 	/** Speichert, die FeatureCollection */
-	private FeatureCollection<SimpleFeatureType,SimpleFeature> fullFeatureCollection = null;
+	private FeatureCollection<SimpleFeatureType, SimpleFeature> fullFeatureCollection = null;
 
 	/** Speichert den letzten Fehler in der Filter-Regel. */
 	protected Throwable testError = null;
@@ -175,38 +175,50 @@
 	 * filter
 	 */
 	protected JPanel defineFilterPanel;
+	private AttributeTypeFilter attributeFilter = AttributeTypeFilter.NO_GEOMETRY;
 
 	/**
 	 * Erzeugt ein neues Panel.
-     * @param parser
-     *            Parser um aus dem im Panel eingegebenen String einen {@link Filter}
-     *            zu erstellen.
+	 * 
+	 * @param parser
+	 *            Parser um aus dem im Panel eingegebenen String einen
+	 *            {@link Filter} zu erstellen.
 	 * @param fc
-	 *            definiert die zur Verfuegung gestellten SimpleFeature-Attribute
+	 *            definiert die zur Verfuegung gestellten
+	 *            SimpleFeature-Attribute
 	 * @param geomPrev
 	 *            bestimmt, ob ein Preview-Bereich angezeigt wird ({@code true})
 	 *            oder nicht ({@code false})
 	 * @see FeatureCollection#getSchema()
 	 */
-	public FeatureCollectionFilterPanel(FilterParser parser, FeatureCollection<SimpleFeatureType,SimpleFeature> fc, boolean geomPrev) {
-		this(parser, fc, geomPrev, true);
+	public FeatureCollectionFilterPanel(FilterParser parser,
+			FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
+			boolean geomPrev, AttributeTypeFilter attributeFilter) {
+		this(parser, fc, geomPrev, true, attributeFilter);
 	}
 
 	/**
 	 * Erzeugt ein neues Panel
-     * @param parser
-     *            Parser um aus dem im Panel eingegebenen String einen {@link Filter}
-     *            zu erstellen.
+	 * 
+	 * @param parser
+	 *            Parser um aus dem im Panel eingegebenen String einen
+	 *            {@link Filter} zu erstellen.
 	 * @param fc
-	 *            definiert die zur Verfuegung gestellten SimpleFeature-Attribute
+	 *            definiert die zur Verfuegung gestellten
+	 *            SimpleFeature-Attribute
 	 * @param initGUI
 	 *            Flag, ob {@link #initGUI()} am Ende des Konstruktor aufgerufen
 	 *            werden soll (wenn {@code false} muss die explizit durch die
 	 *            Unterklasse erfolgen!)
+	 * @param attributeFilter
+	 *            If null <code>null</code>,
+	 *            {@value AttributeTypeFilter#NO_GEOMETRY} will be used.
 	 */
-	protected FeatureCollectionFilterPanel(FilterParser parser, FeatureCollection<SimpleFeatureType,SimpleFeature> fc,
-			boolean geomPrev, boolean initGUI) {
-		super(parser,fc.getSchema(), false);
+	protected FeatureCollectionFilterPanel(FilterParser parser,
+			FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
+			boolean geomPrev, boolean initGUI,
+			AttributeTypeFilter attributeFilter) {
+		super(parser, fc.getSchema(), false);
 		this.geomPrev = geomPrev;
 
 		// Layout-Anordnung fuer GUI
@@ -228,6 +240,9 @@
 		layoutConstraints.put(PREVIEW_PANEL, new GridBagConstraints(0, 5, 3, 1,
 				0, 0.7, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
 				new Insets(5, 10, 10, 10), 0, 0));
+		
+		if (attributeFilter != null)
+			this.attributeFilter = attributeFilter;
 
 		if (initGUI)
 			initGUI();
@@ -281,12 +296,14 @@
 				protected void initGUI(boolean geomPreview) {
 					super.initGUI(geomPreview);
 
-					mapPane.setToolTipText(
-					    GeotoolsGUIUtil.R(FeatureCollectionFilterPanel.PREVIEW_MAPPANE_TOOLTIP));
+					mapPane
+							.setToolTipText(GeotoolsGUIUtil
+									.R(FeatureCollectionFilterPanel.PREVIEW_MAPPANE_TOOLTIP));
 
 					// nur einzelne Zellen duerfen selektiert werden
 					featuresTable.setColumnSelectionAllowed(true);
-					featuresTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+					featuresTable
+							.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
 					// beim Klick auf eine Tabellenzelle, soll der Wert in die
 					// Formel
 					// uebernommen werden
@@ -343,25 +360,27 @@
 					if (getPreviewPanel() == null)
 						return;
 
-					FeatureCollection<SimpleFeatureType,SimpleFeature> specialFeatureCollection = getFeatureCollection();
+					FeatureCollection<SimpleFeatureType, SimpleFeature> specialFeatureCollection = getFeatureCollection();
 
-					final FeatureCollection<SimpleFeatureType,SimpleFeature> allFeatures = FeatureCollectionFilterPanel.this
+					final FeatureCollection<SimpleFeatureType, SimpleFeature> allFeatures = FeatureCollectionFilterPanel.this
 							.getFeatureCollection();
+					//
+					// if (specialFeatureCollection != null && allFeatures !=
+					// null)
+					// LOGGER.debug("The result to show contains "
+					// + specialFeatureCollection.size()
+					// + " of total " + allFeatures.size());
 
-					if (specialFeatureCollection != null && allFeatures != null)
-						LOGGER.debug("The result to show contains "
-								+ specialFeatureCollection.size()
-								+ " of total " + allFeatures.size());
+					if (getPreviewPanel().mapPane.getMapContext()
+							.getLayerCount() == 0) {
 
-					if (getPreviewPanel().mapPane.getContext().getLayerCount() == 0) {
-
 						if (allFeatures != null) {
 							/**
 							 * Als unterstes layer sollen alle Features in grau
 							 * dargestellt werden. Dieses Layer soll nur einmal
 							 * eingefügt werden
 							 */
-							getPreviewPanel().mapPane.getContext().addLayer(
+							getPreviewPanel().mapPane.getMapContext().addLayer(
 									new DefaultMapLayer(allFeatures,
 											StylingUtil.createStyleSimple(
 													allFeatures,
@@ -370,7 +389,8 @@
 
 							// This thows an exception... We have to move to GT
 							// filters i guess.
-							getPreviewPanel().mapPane.zoomTo(allFeatures);
+							getPreviewPanel().mapPane.getMapContext()
+									.setAreaOfInterest(allFeatures.getBounds());
 						}
 					}
 
@@ -379,15 +399,15 @@
 						 * Der Inhalt der Tabelle soll in rot darüber gezeichnet
 						 * werden. Dieses layer wird jedes mal neu erstellt.
 						 */
-						if (getPreviewPanel().mapPane.getContext()
+						if (getPreviewPanel().mapPane.getMapContext()
 								.getLayerCount() > 1)
-							getPreviewPanel().mapPane.getContext().removeLayer(
-									1);
+							getPreviewPanel().mapPane.getMapContext()
+									.removeLayer(1);
 
 						// nur neues Layer erzeugen, wenn FeatureCollection
 						// NICHT leer (sonst Exception im StreamingRenderer!)
 						if (specialFeatureCollection.size() > 0)
-							getPreviewPanel().mapPane.getContext().addLayer(
+							getPreviewPanel().mapPane.getMapContext().addLayer(
 									new DefaultMapLayer(
 											specialFeatureCollection,
 											StylingUtil.createStyleSimple(
@@ -404,8 +424,9 @@
 
 			// SwingUtil.setPreferredWidth(getPreviewPanel(), 600);
 		}
-		// Geometry-Attribute sollen nicht angezeigt werden
-		getPreviewPanel().setAttributeFilter(AttributeTypeFilter.NO_GEOMETRY);
+		
+		// Der Filter kann im Construktor übergeben werden und ist sonst per default ein NO_GEOMETRY-Filter
+		getPreviewPanel().setAttributeFilter(attributeFilter);
 
 		SwingUtil.setPreferredHeight(getPreviewPanel(), 150);
 
@@ -505,8 +526,8 @@
 		// Nur numerische Werte direkt in Formel einfuegen.
 		// Andere Werte als String in Anfuehrungsstrichen gekapselt.
 		if (!(value instanceof Number))
-//		  ruleValue = "\"" + ruleValue + "\"";
-		  ruleValue = "'" + ruleValue + "'";  // more common (e.g. for CQL)
+			// ruleValue = "\"" + ruleValue + "\"";
+			ruleValue = "'" + ruleValue + "'"; // more common (e.g. for CQL)
 		// Wert in Formel einfuegen
 		performOperatorInsert(ruleValue, (JTextField) this.rule
 				.getInputComponent());
@@ -537,7 +558,7 @@
 	 */
 	protected void performRuleTest() {
 		try {
-			FeatureCollection<SimpleFeatureType,SimpleFeature> subCollection = filterFeatureCollection();
+			FeatureCollection<SimpleFeatureType, SimpleFeature> subCollection = filterFeatureCollection();
 			getPreviewPanel().setFeatureCollection(subCollection);
 			resetComponentsAfterTest(null);
 		} catch (Exception err) {
@@ -566,14 +587,15 @@
 	 * angezeigt wird.
 	 * 
 	 * @param fc
-	 *            eine {@link FeatureCollection}, die zum SimpleFeature-Type (Schema)
-	 *            des Formel-Panels passt
+	 *            eine {@link FeatureCollection}, die zum SimpleFeature-Type
+	 *            (Schema) des Formel-Panels passt
 	 * @exception IllegalArgumentException
 	 *                falls die FeatureCollection nicht zum Schema des Panels
 	 *                passt
 	 * @see FeatureCollection#getSchema()
 	 */
-	public void setFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> fc) {
+	public void setFeatureCollection(
+			FeatureCollection<SimpleFeatureType, SimpleFeature> fc) {
 		if (getFeatureType() == null)
 			setFeatureType(fc.getSchema());
 		if (!fc.getSchema().equals(getFeatureType()))
@@ -582,6 +604,7 @@
 		this.fullFeatureCollection = fc;
 
 		if (getPreviewPanel() != null) {
+			LOGGER.info("calling set FC");
 			getPreviewPanel().setFeatureCollection(fc);
 		}
 	}
@@ -590,7 +613,7 @@
 	 * Liefert die ungefilterte {@link FeatureCollection}, auf der gefiltert
 	 * wird.
 	 */
-	public FeatureCollection<SimpleFeatureType,SimpleFeature> getFeatureCollection() {
+	public FeatureCollection<SimpleFeatureType, SimpleFeature> getFeatureCollection() {
 		return fullFeatureCollection;
 	}
 
@@ -621,9 +644,9 @@
 	 */
 	public FeatureCollection<SimpleFeatureType, SimpleFeature> filterFeatureCollection() {
 		final Filter filterParsed = createFilter();
-		
+
 		if (filterParsed == Filter.EXCLUDE) {
-			// If no Filter String has been entered, just show all Features  
+			// If no Filter String has been entered, just show all Features
 			return new EmptyFeatureCollection(getFeatureType());
 		}
 		return getFeatureCollection().subCollection(filterParsed);
@@ -636,7 +659,8 @@
 	 * 
 	 * @see FeatureCollection#subCollection(Filter)
 	 */
-	public FeatureCollection<SimpleFeatureType,SimpleFeature> filterFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> fc) {
+	public FeatureCollection<SimpleFeatureType, SimpleFeature> filterFeatureCollection(
+			FeatureCollection<SimpleFeatureType, SimpleFeature> fc) {
 		return fc.subCollection(createFilter());
 	}
 

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java	2009-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureCollectionTableModel.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -34,6 +34,7 @@
 
 import javax.swing.table.AbstractTableModel;
 
+import org.apache.log4j.Logger;
 import org.geotools.feature.FeatureCollection;
 import org.geotools.feature.FeatureCollections;
 import org.geotools.feature.FeatureIterator;
@@ -62,6 +63,11 @@
  * @version 1.0
  */
 public class FeatureCollectionTableModel extends AbstractTableModel {
+
+	/** Logger for debug messages. */
+	protected static final Logger LOGGER = Logger
+			.getLogger(FeatureCollectionTableModel.class);
+
   /** Holds the feature table that will be represented by this model. */
   protected FeatureCollection<SimpleFeatureType,SimpleFeature> featureTable = null;
   /** Array mit den Daten von {@link #featureTable}. Wird nur beim Aufruf von
@@ -93,11 +99,19 @@
   }
 
   /**
-   * Erzeugt ein neues Tabellen-Modell.
+   * Erzeugt ein neues Tabellen-Modell und setzt gleichzeitig einen Attributfilter. Das soll zweimaliges reorganizen der Tabelle verhindern.
    * @param features Daten fuer die Tabelle
    */
+  public FeatureCollectionTableModel(final FeatureCollection<SimpleFeatureType,SimpleFeature> features, AttributeTypeFilter attFilter) {
+	this.attrFilter = attFilter;
+    setFeatureCollection(features);
+  }
+  
+  /**
+   * Erzeugt ein neues Tabellen-Modell
+   * @param features Daten fuer die Tabelle
+   */
   public FeatureCollectionTableModel(final FeatureCollection<SimpleFeatureType,SimpleFeature> features) {
-    super();
     setFeatureCollection(features);
   }
 
@@ -120,6 +134,8 @@
    *        ein entsprechendes Event initiiert wird
    */
   protected void reorganize(boolean fireTableStructureChanged) {
+	long startTime = System.currentTimeMillis();
+	  
     featureArray = FeatureUtil.featuresToArray(featureTable);
     if ( featureArray == null || featureArray.length == 0 ) {
       colNames = new String[0];
@@ -157,6 +173,8 @@
       if ( featureArray[i] != null )
         featureIdx.put(featureArray[i].getID(), i);
     
+    LOGGER.info("took "+ (System.currentTimeMillis()-startTime) +"ms to reorganize");
+    
     if ( fireTableStructureChanged )
       fireTableStructureChanged();
   }
@@ -170,7 +188,7 @@
    */
   public void setFeatureCollection(final FeatureCollection<SimpleFeatureType,SimpleFeature> features) {
       featureTable = features;
-      reorganize();
+      reorganize(features != null);
    }
 
   /**

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureLayerFilterDialog.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureLayerFilterDialog.java	2009-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureLayerFilterDialog.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -30,6 +30,7 @@
 package schmitzm.geotools.gui;
 
 import java.awt.BorderLayout;
+import java.awt.Component;
 import java.awt.FlowLayout;
 import java.awt.Frame;
 import java.awt.Window;
@@ -175,9 +176,9 @@
 	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
 	 *         Kr&uuml;ger</a>
 	 */
-	protected FeatureLayerFilterDialog(Window parent, SelectableXMapPane mapPane,
+	protected FeatureLayerFilterDialog(Component parent, SelectableXMapPane mapPane,
 			MapLayer mapLayer, boolean initGUI) {
-		super(parent);
+		super(SwingUtil.getParentWindow(parent));
 		setModal(true);
 		if (mapLayer != null)
 			this.setTitle(frameTitle + " [" + mapLayer.getTitle() + "]");
@@ -266,7 +267,7 @@
 
 				filterPanel = new FeatureCollectionFilterPanel(FILTER_PARSER,
 						(FeatureCollection<SimpleFeatureType, SimpleFeature>) layer
-								.getFeatureSource().getFeatures(), true) {
+								.getFeatureSource().getFeatures(), true, null) {
 					@Override
 					protected void resetComponentsAfterTest(Throwable err) {
 						super.resetComponentsAfterTest(err);

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureTablePane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureTablePane.java	2009-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/FeatureTablePane.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -45,11 +45,14 @@
 
 import org.apache.log4j.Logger;
 import org.geotools.feature.FeatureCollection;
+import org.geotools.map.DefaultMapContext;
 import org.geotools.map.DefaultMapLayer;
 import org.geotools.styling.Style;
+import org.geotools.swing.JMapPane;
 import org.opengis.feature.simple.SimpleFeature;
 import org.opengis.feature.simple.SimpleFeatureType;
 
+import schmitzm.geotools.GTUtil;
 import schmitzm.geotools.feature.AttributeTypeFilter;
 import schmitzm.geotools.feature.FeatureUtil;
 import schmitzm.geotools.styling.StylingUtil;
@@ -82,7 +85,7 @@
 	/** Tabellen-Modell der SimpleFeature-Tabelle. */
 	protected FeatureCollectionTableModel featuresTableModel = null;
 	/** Preview-Bereich fuer die in der Tabelle selektierten Features. */
-	protected XMapPane mapPane = null;
+	protected SelectableXMapPane mapPane = null;
 	/** Style, in dem die Features in der Karte dargestellt werden */
 	protected Style featureStyle = null;
 
@@ -220,8 +223,9 @@
 	protected void initGUI(boolean geomPreview) {
 		setLayout(new BorderLayout());
 		// MapPane fuer Preview der in der Tabelle selektieren Features
+		
 		if (geomPreview) {
-			this.mapPane = new XMapPane();
+			this.mapPane = new SelectableXMapPane();
 			
 			// {
 			// // Bei Links-Klick auf das gesamte Layer zoomen
@@ -241,7 +245,8 @@
 			// };
 			mapPane.setToolTipText(GeotoolsGUIUtil.R(PREVIEW_MAPPANE_TOOLTIP));
 
-			mapPane.setState(SelectableXMapPane.NONE);
+//			mapPane.setState(SelectableXMapPane.NONE);
+			
 			mapPane.setMinimumSize(new Dimension(100, 100));
 			SwingUtil.setPreferredWidth(mapPane, 200);
 			mapPane.setBorder(BorderFactory.createLoweredBevelBorder());
@@ -268,12 +273,16 @@
 		// selektierten rot angezeigt. Der rest grau.
 		featuresTableModel.addTableModelListener(new TableModelListener() {
 			public void tableChanged(TableModelEvent e) {
+				
+				LOGGER.info("tableChanged");
+				
 				// showFeaturesInMap(getSelectedFeatures());
 				if (mapPane != null) {
 					// falls diese TableContextChange durch einen neu
 					// angewendeten filter passiert ist, soll sich auch das
 					// hintergund layer ändern.
-					mapPane.getContext().clearLayerList();
+					if (mapPane.getMapContext() != null)
+						mapPane.getMapContext().clearLayerList();
 				}
 				showFeaturesInMap();
 			}
@@ -385,7 +394,7 @@
 		 * Das layer mit allen features soll nicht immer neu eingefügt werden.
 		 * Deshalb wird es nur einmal eingefügt.
 		 */
-		if (mapPane.getContext().getLayerCount() == 0) {
+		if (mapPane.getMapContext().getLayerCount() == 0) {
 
 			final FeatureCollection<SimpleFeatureType,SimpleFeature> allFeatures = getFeatureCollection();
 
@@ -395,16 +404,23 @@
 			 */
 			if (allFeatures != null && mapPane != null) {
 				
-				mapPane.getContext().addLayer(
-						new DefaultMapLayer(FeatureUtil.createMemoryFeatureSource(allFeatures), StylingUtil
-								.createStyleSimple(allFeatures,
-										Color.lightGray, Color.darkGray)));
+// Let's try not to use a MemoryFeatureCollection				
+//				mapPane.getMapContext().addLayer(
+//						new DefaultMapLayer(FeatureUtil.createMemoryFeatureSource(allFeatures), StylingUtil
+//								.createStyleSimple(allFeatures,
+//										Color.lightGray, Color.darkGray)));
+
+				mapPane.getMapContext().addLayer(
+				new DefaultMapLayer(allFeatures, StylingUtil
+						.createStyleSimple(allFeatures,
+								Color.lightGray, Color.darkGray)));
+				
 			}
 		}
 
 		// Das zweite Layer entfernen (wenn es schon vorhanden ist)
-		if (mapPane.getContext().getLayerCount() > 1)
-			mapPane.getContext().removeLayer(1);
+		if (mapPane.getMapContext().getLayerCount() > 1)
+			mapPane.getMapContext().removeLayer(1);
 
 		// Und ggf. neu hinzufügen
 		if (selectedFeatures != null && selectedFeatures.size() > 0  &&
@@ -414,7 +430,7 @@
 				setFeatureStyle(StylingUtil.createStyleSimple(selectedFeatures,
 						Color.red, Color.white));
 			}
-			mapPane.getContext().addLayer(selectedFeatures, getFeatureStyle());
+			mapPane.getMapContext().addLayer(selectedFeatures, getFeatureStyle());
 
 			/**
 			 * TODO Das schmeisst eine blöde exception

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-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeoMapPane.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -258,7 +258,7 @@
 	 * Liefert den {@link MapContext} der die einzelnen Karten-Layer verwaltet.
 	 */
 	public final MapContext getMapContext() {
-		return mapPane.getContext();
+		return mapPane.getMapContext();
 	}
 
 	/**

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-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanel.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -30,6 +30,7 @@
 package schmitzm.geotools.gui;
 
 import java.awt.Color;
+import java.awt.FontMetrics;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
@@ -213,7 +214,7 @@
     if ( getParent() == null || !mapPane.isWellDefined())
       return;
 
-    CoordinateReferenceSystem mapCRS = mapPane.getContext().getCoordinateReferenceSystem();   // (aktuelles) CRS des MapPane
+    CoordinateReferenceSystem mapCRS = mapPane.getMapContext().getCoordinateReferenceSystem();   // (aktuelles) CRS des MapPane
     CoordinateReferenceSystem gridCRS = formatter.getCRS();  // CRS fuer die Grad/Min/Sek-Anzeige
 //    try {
 //      final CoordinateReferenceSystem UTM   = CRS.decode("EPSG:32631"); // utm zone 31n
@@ -345,9 +346,19 @@
      if (formatter.getFont()  != null) {
     	 g2.setFont( formatter.getFont() );
      }
+     
+     
+     // TODO it would be great if we could print this right aligned     
+     // see: g2.getFontMetrics().stringWidth(coordStr);
+     
      String coordStr = formatter.formatCoordinate(this, grid_GCRS[idx]);
+     
+     
      x1 = isVertical() ?    5 : x1 + 5;
      y1 = isVertical() ? y1-2 : y1 + 12;
+     
+//     .string(coordStr, g2); 
+     
      g2.drawString( coordStr, x1, y1 );
    }
   }

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JEditorPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JEditorPane.java	2009-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JEditorPane.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -189,7 +189,7 @@
    */
   public JEditorPane(MapContext context) {
     super(context);
-    this.mapContext = getContext();
+    this.mapContext = getMapContext();
     // initalize the editor styles
     this.editorStyles = new HashMap<GeometryForm, Style>();
     for (GeometryForm geomForm : GeometryForm.values())

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/LayeredMapFrame.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/LayeredMapFrame.java	2009-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/LayeredMapFrame.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -135,7 +135,7 @@
     // Karte und Layer-Kontrolle
     layeredMapPane = lmp != null ? lmp : new LayeredMapPane();
     mapPane        = layeredMapPane.getMapPane();
-    mapContext     = mapPane.getContext();
+    mapContext     = mapPane.getMapContext();
     MapActionControlPane mapControl = new MapActionControlPane(mapPane,MapActionControlPane.VERTICAL);
     mapControl.setFloatable(false);
 
@@ -219,7 +219,7 @@
     // Alle Raster-Layer und Titel ermitteln
     Vector<MapLayer> rasterLayer     = new Vector<MapLayer>();
     Vector<String>   rasterLayerDesc = new Vector<String>();
-    for (MapLayer layer : mapPane.getContext().getLayers())
+    for (MapLayer layer : mapPane.getMapContext().getLayers())
       if ( mapPane.isGridCoverageLayer(layer) ) {
         rasterLayer.add(layer);
         rasterLayerDesc.add( layer.getTitle() );

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/LayeredMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/LayeredMapPane.java	2009-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/LayeredMapPane.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -119,7 +119,7 @@
     // rechter Bereich: Map, Grids und Scale
     this.geoMapPane = geoMapPane != null ? geoMapPane : new GeoMapPane();
     this.mapPane    = geoMapPane.getMapPane();
-    this.mapContext = mapPane.getContext();
+    this.mapContext = mapPane.getMapContext();
     this.mapContext.addMapLayerListListener( new MapLayerListListener() {
       public void layerAdded(MapLayerListEvent e) { }
       public void layerChanged(MapLayerListEvent e) { }

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/MapContextControlPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/MapContextControlPane.java	2009-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/MapContextControlPane.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -281,7 +281,7 @@
 		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
 		// Auf den MapContext lauschen und Steuerungskomponenten hinzufuegen,
 		// loeschen, verschieben
-		mapPane.getContext().addMapLayerListListener(
+		mapPane.getMapContext().addMapLayerListListener(
 				new MapLayerListListener() {
 					public void layerAdded(MapLayerListEvent e) {
 						addLayerControl(getComponentCount() - e.getToIndex(), e
@@ -513,7 +513,7 @@
 			if (e == null)
 				return;
 			Object source = e.getSource();
-			MapContext context = mapPane.getContext();
+			MapContext context = mapPane.getMapContext();
 			int currIdx = context.indexOf(layer);
 
 			// Checkbox (un)checked -> (in)visible layer

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/RasterPositionLabel.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/RasterPositionLabel.java	2009-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/RasterPositionLabel.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -147,7 +147,7 @@
 			return;
 		}
 
-		CoordinateReferenceSystem mapCrs = mapPane.getContext()
+		CoordinateReferenceSystem mapCrs = mapPane.getMapContext()
 				.getCoordinateReferenceSystem();
 		CoordinateReferenceSystem layerCrs = layer.getFeatureSource()
 				.getSchema().getGeometryDescriptor()
@@ -232,7 +232,7 @@
 				AbstractGridCoverage2DReader gcr = (AbstractGridCoverage2DReader) layerObj;
 				// Koordinaten in CRS des Rasters umrechnen
 				final MathTransform mapToGrid = CRS.findMathTransform(mapPane
-						.getContext().getCoordinateReferenceSystem(), gcr
+						.getMapContext().getCoordinateReferenceSystem(), gcr
 						.getCrs());
 				mapToGrid.transform(new GeneralDirectPosition(actPos_MapCRS),
 						actPos_GridCRS);
@@ -278,8 +278,8 @@
 			Point2D actPos_MapCRS) {
 
 		// find the first grid layer intersecting with the click position
-		for (int idx = mapPane.getContext().getLayerCount(); idx >= 1; idx--) {
-			MapLayer layer = mapPane.getContext().getLayer(idx - 1);
+		for (int idx = mapPane.getMapContext().getLayerCount(); idx >= 1; idx--) {
+			MapLayer layer = mapPane.getMapContext().getLayer(idx - 1);
 			if (!layer.isVisible())
 				continue;
 			if (!SelectableXMapPane.isGridCoverageLayer(layer))

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java	2009-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -417,7 +417,7 @@
 		try {
 
 			// BB umrechnen von Layer-CRS in Map-CRS
-			final CoordinateReferenceSystem targetCRS = getContext()
+			final CoordinateReferenceSystem targetCRS = getMapContext()
 					.getCoordinateReferenceSystem();
 			final CoordinateReferenceSystem sourceCRS = layer
 					.getFeatureSource().getSchema()
@@ -505,7 +505,7 @@
 	 *         Kr&uuml;ger</a>
 	 */
 	public void zoomToLayer(int index) {
-		final MapContext context = getContext();
+		final MapContext context = getMapContext();
 		if (context != null)
 			zoomToLayer(context.getLayer(index));
 	}
@@ -528,7 +528,7 @@
 	 *         Kr&uuml;ger</a>
 	 */
 	public void zoomToLayerIdxReverse(int index) {
-		zoomToLayer(getContext().getLayerCount() - 1 - index);
+		zoomToLayer(getMapContext().getLayerCount() - 1 - index);
 	}
 
 	/**
@@ -547,16 +547,16 @@
 	 * Liefert oberste Layer (sichtbar oder unsichtbar).
 	 */
 	public MapLayer getTopLayer() {
-		int count = getContext().getLayerCount();
-		return count > 0 ? getContext().getLayer(count - 1) : null;
+		int count = getMapContext().getLayerCount();
+		return count > 0 ? getMapContext().getLayer(count - 1) : null;
 	}
 
 	/**
 	 * Liefert oberste sichtbare Layer.
 	 */
 	public MapLayer getTopVisibleLayer() {
-		for (int i = getContext().getLayerCount() - 1; i >= 0; i--) {
-			MapLayer layer = getContext().getLayer(i);
+		for (int i = getMapContext().getLayerCount() - 1; i >= 0; i--) {
+			MapLayer layer = getMapContext().getLayer(i);
 			if (layer.isVisible())
 				return layer;
 		}
@@ -567,8 +567,8 @@
 	 * Liefert oberste sichtbare Raster-Layer.
 	 */
 	public MapLayer getTopVisibleGridCoverageLayer() {
-		for (int i = getContext().getLayerCount() - 1; i >= 0; i--) {
-			MapLayer layer = getContext().getLayer(i);
+		for (int i = getMapContext().getLayerCount() - 1; i >= 0; i--) {
+			MapLayer layer = getMapContext().getLayer(i);
 			if (layer.isVisible() && isGridCoverageLayer(layer))
 				return layer;
 		}
@@ -579,8 +579,8 @@
 	 * Liefert oberste sichtbare Nicht-Raster-Layer.
 	 */
 	public MapLayer getTopVisibleNonGridCoverageLayer() {
-		for (int i = getContext().getLayerCount() - 1; i >= 0; i--) {
-			MapLayer layer = getContext().getLayer(i);
+		for (int i = getMapContext().getLayerCount() - 1; i >= 0; i--) {
+			MapLayer layer = getMapContext().getLayer(i);
 			if (layer.isVisible() && !isGridCoverageLayer(layer))
 				return layer;
 		}
@@ -591,7 +591,7 @@
 	 * Liefert unterste Layer (sichtbar oder unsichtbar).
 	 */
 	public MapLayer getBottomLayer() {
-		return getContext().getLayerCount() > 0 ? getContext().getLayer(0)
+		return getMapContext().getLayerCount() > 0 ? getMapContext().getLayer(0)
 				: null;
 	}
 
@@ -703,7 +703,7 @@
 			FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = (FeatureSource<SimpleFeatureType, SimpleFeature>) layer
 					.getFeatureSource();
 			GeometryFilterImpl filter = new BoundingBoxFilterGenerator(env,
-					getContext().getCoordinateReferenceSystem())
+					getMapContext().getCoordinateReferenceSystem())
 					.adaptFilter(featureSource);
 			return !layer.getFeatureSource().getFeatures(filter).isEmpty();
 		} catch (Exception err) {
@@ -731,7 +731,7 @@
 			return result;
 
 		// Je nach Modus: Alle oder nur das oberste Layer
-		MapContext context = getContext();
+		MapContext context = getMapContext();
 		MapLayer[] layerList = context.getLayers();
 		for (int i = layerList.length - 1; i >= 0; i--) {
 			MapLayer layer = layerList[i];
@@ -821,7 +821,7 @@
 		if (point == null)
 			return result;
 
-		MapContext context = getContext();
+		MapContext context = getMapContext();
 		// Je nach Modus: Alle oder nur das oberste Layer
 		MapLayer[] layerList = context.getLayers();
 		for (int i = layerList.length - 1; i >= 0; i--) {
@@ -883,12 +883,12 @@
 
 			try {
 				// Grid an Geo-Position auswerten
-				if (!CRS.equalsIgnoreMetadata(getContext()
+				if (!CRS.equalsIgnoreMetadata(getMapContext()
 						.getCoordinateReferenceSystem(), sourceGrid
 						.getCoordinateReferenceSystem())) {
 					Coordinate pointInLayerCRS = JTSUtil.transformCoordinate(
 							new Coordinate(point.getX(), point.getY()),
-							getContext().getCoordinateReferenceSystem(),
+							getMapContext().getCoordinateReferenceSystem(),
 							sourceGrid.getCoordinateReferenceSystem());
 					sourceGrid.evaluate(new Point.Double(pointInLayerCRS.x,
 							pointInLayerCRS.y), values);
@@ -939,7 +939,7 @@
 	 */
 	public void performSelectionEvent(int ox, int oy, int px, int py) {
 
-		if (getContext().getLayerCount() == 0)
+		if (getMapContext().getLayerCount() == 0)
 			return;
 
 		// Fenster-Koordinaten in Map-Koordinaten umwandeln
@@ -961,7 +961,7 @@
 		case SELECT_ALL: // Features selektieren
 
 			boolean featuresFound = findFeaturesAndFireEvents(
-					new BoundingBoxFilterGenerator(env, getContext()
+					new BoundingBoxFilterGenerator(env, getMapContext()
 							.getCoordinateReferenceSystem()), selectState, env);
 			if (selectState == SELECT_ALL || !featuresFound)
 				findGridCoverageSubsetsAndFireEvents(env, selectState);
@@ -1021,7 +1021,7 @@
 		if (env == null)
 			return result;
 
-		MapContext context = getContext();
+		MapContext context = getMapContext();
 		// Je nach Modus: Alle oder nur das oberste Layer
 		MapLayer[] layerList = context.getLayers();
 		for (int i = layerList.length - 1; i >= 0; i--) {
@@ -1115,7 +1115,7 @@
 					"filterGenerator may not be null");
 
 		// Je nach Modus: Alle oder nur das oberste Layer
-		MapContext context = getContext();
+		MapContext context = getMapContext();
 		MapLayer[] layerList = context.getLayers();
 		for (int i = layerList.length - 1; i >= 0; i--) {
 			MapLayer layer = layerList[i];
@@ -1217,7 +1217,7 @@
 			Envelope bounds_MapCRS = JTSUtil.transformEnvelope(layer
 					.getFeatureSource().getBounds(), layer.getFeatureSource()
 					.getSchema().getGeometryDescriptor()
-					.getCoordinateReferenceSystem(), getContext()
+					.getCoordinateReferenceSystem(), getMapContext()
 					.getCoordinateReferenceSystem());
 
 			// TODO warum kann bounds_MapCRS == null sein ?? ?SK fragt martin???
@@ -1251,7 +1251,7 @@
 			CoordinateReferenceSystem layerCRS = layer.getFeatureSource()
 					.getSchema().getGeometryDescriptor()
 					.getCoordinateReferenceSystem();
-			CoordinateReferenceSystem mapCRS = getContext()
+			CoordinateReferenceSystem mapCRS = getMapContext()
 					.getCoordinateReferenceSystem();
 			if (!CRS.equalsIgnoreMetadata(layerCRS, mapCRS)) {
 

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-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -2415,7 +2415,7 @@
 		// Der "scaleDenominator" der aktuellen JMapPane
 		Double scaleDenominator = RendererUtilities.calculateOGCScale(
 				new ReferencedEnvelope(xMapPane.getMapArea(), xMapPane
-						.getContext().getCoordinateReferenceSystem()), xMapPane
+						.getMapContext().getCoordinateReferenceSystem()), xMapPane
 						.getBounds().width, null);
 
 		return filterSLDVisibleOnly(fc, style, scaleDenominator);

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/SelectXMapPaneMouseListener.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/SelectXMapPaneMouseListener.java	2009-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/SelectXMapPaneMouseListener.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -91,7 +91,7 @@
 
 		Hashtable<MapLayer, FeatureCollection<SimpleFeatureType, SimpleFeature>> result = xMapPane
 				.findVisibleFeatures(new PointFilterGenerator(geoCoord, radius,
-						xMapPane.getContext().getCoordinateReferenceSystem()),
+						xMapPane.getMapContext().getCoordinateReferenceSystem()),
 						state, new Envelope(geoCoord.getX(), geoCoord.getX(),
 								geoCoord.getY(), geoCoord.getY()));
 		

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java	2009-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -389,20 +389,20 @@
 		public void layerAdded(final MapLayerListEvent event) {
 			event.getLayer().addMapLayerListener(localMapLayerListener);
 
-			localRenderer.setContext(getContext());
+			localRenderer.setContext(getMapContext());
 			requestStartRendering();
 
 		}
 
 		@Override
 		public void layerChanged(final MapLayerListEvent event) {
-			localRenderer.setContext(getContext());
+			localRenderer.setContext(getMapContext());
 			requestStartRendering();
 		}
 
 		@Override
 		public void layerMoved(final MapLayerListEvent event) {
-			localRenderer.setContext(getContext());
+			localRenderer.setContext(getMapContext());
 			requestStartRendering();
 		}
 
@@ -410,7 +410,7 @@
 		public void layerRemoved(final MapLayerListEvent event) {
 			if (event.getLayer() != null)
 				event.getLayer().removeMapLayerListener(localMapLayerListener);
-			localRenderer.setContext(getContext());
+			localRenderer.setContext(getMapContext());
 			requestStartRendering();
 		}
 	};
@@ -423,7 +423,7 @@
 
 		@Override
 		public void layerChanged(final MapLayerEvent event) {
-			localRenderer.setContext(getContext()); // betters for SLD changes?!
+			localRenderer.setContext(getMapContext()); // betters for SLD changes?!
 			requestStartRendering();
 		}
 
@@ -762,6 +762,7 @@
 		}
 
 		final Envelope maxAllowedExtend = getMaxExtend();
+		
 		while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea)
 				&& newArea != null && !newArea.isNull()
 				&& !Double.isNaN(newArea.getMinX())
@@ -935,7 +936,7 @@
 		removeMouseListener(zoomMapPaneMouseListener);
 
 		if (localContext != null)
-			getContext().clearLayerList();
+			getMapContext().clearLayerList();
 		if (bgContext != null)
 			getBgContext().clearLayerList();
 
@@ -1046,7 +1047,7 @@
 		return bgImage;
 	}
 
-	public MapContext getContext() {
+	public MapContext getMapContext() {
 		if (localContext == null) {
 			setLocalContext(new DefaultMapContext());
 		}
@@ -1156,16 +1157,22 @@
 
 	public Envelope getMaxExtend() {
 		if (maxExtend == null) {
-			final ReferencedEnvelope layerBounds = GTUtil
-					.getVisibleLayoutBounds(localContext);
-			if (layerBounds == null) {
-				// TODO Last fallback could be the CRS valid area
-				return null;
-			}
-
-			// Kartenbereich um 10% vergroessern
-			return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil
-					.expandEnvelope(layerBounds, 0.1), true);
+			// Commented-out because it takes soo much time!
+//
+//			long start = System.currentTimeMillis(); 
+//			final ReferencedEnvelope layerBounds = GTUtil
+//					.getVisibleLayoutBounds(localContext);
+//			
+//			LOGGER.info( (System.currentTimeMillis()-start)+"m to get maxExtend");
+//			
+//			if (layerBounds == null) {
+//				// TODO Last fallback could be the CRS valid area
+//				return null;
+//			}
+//
+//			// Kartenbereich um 10% vergroessern
+//			return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil
+//					.expandEnvelope(layerBounds, 0.1), true);
 		}
 		return maxExtend;
 	}
@@ -1280,9 +1287,9 @@
 	 */
 	public boolean isWellDefined() {
 		try {
-			if (getContext() == null)
+			if (getMapContext() == null)
 				return false;
-			if (getContext().getLayerCount() <= 0)
+			if (getMapContext().getLayerCount() <= 0)
 				return false;
 			if (getVisibleRect().getWidth() == 0)
 				return false;
@@ -1618,7 +1625,7 @@
 	 */
 	private void resetTransforms() {
 		ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,
-				getContext().getCoordinateReferenceSystem());
+				getMapContext().getCoordinateReferenceSystem());
 
 		// System.out
 		// .println("paintArea in resetTeansofrms = " + getVisibleRect());
@@ -1702,7 +1709,7 @@
 	}
 
 	public boolean setMapArea(final Envelope newMapArea) {
-		return setMapArea(new ReferencedEnvelope(newMapArea, getContext()
+		return setMapArea(new ReferencedEnvelope(newMapArea, getMapContext()
 				.getCoordinateReferenceSystem()));
 	}
 
@@ -1965,7 +1972,7 @@
 			// (Graphics2D) getBgImage().getGraphics(), createGTRenderer);
 		}
 
-		if (getContext() != null) {
+		if (getMapContext() != null) {
 			// localExecuter = new RenderingExecutor(this, 150l);
 			// LOGGER.debug("starting local renderer:");
 
@@ -2226,13 +2233,19 @@
 	public void zoomTo(
 			final FeatureCollection<SimpleFeatureType, SimpleFeature> features) {
 
-		final CoordinateReferenceSystem mapCRS = getContext()
+		// if (!isWellDefined()) return;
+
+		final CoordinateReferenceSystem mapCRS = getMapContext()
 				.getCoordinateReferenceSystem();
 		final CoordinateReferenceSystem fCRS = features.getSchema()
 				.getGeometryDescriptor().getCoordinateReferenceSystem();
 
-		double width = mapArea.getWidth();
-		double height = mapArea.getHeight();
+		ReferencedEnvelope _mapArea;
+		if (mapArea == null)
+			_mapArea = features.getBounds();
+		else _mapArea = getMapArea();
+		double width = _mapArea.getWidth();
+		double height = _mapArea.getHeight();
 		final double ratio = height / width;
 
 		if (features == null || features.size() == 0) {
@@ -2284,9 +2297,9 @@
 		} else {
 			final ReferencedEnvelope fBounds = features.getBounds();
 
-			Envelope bounds;
+			ReferencedEnvelope bounds;
 			if (!mapCRS.equals(fCRS)) {
-				bounds = JTSUtil.transformEnvelope(fBounds, fCRS, mapCRS);
+				bounds = JTSUtil.transformEnvelope(fBounds, mapCRS);
 			} else {
 				bounds = fBounds;
 			}

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/labelsearch/LabelSearch.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/labelsearch/LabelSearch.java	2009-11-23 13:37:51 UTC (rev 550)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/labelsearch/LabelSearch.java	2009-11-23 15:47:04 UTC (rev 551)
@@ -108,7 +108,7 @@
 
 		final ArrayList<SearchResult> hits = new ArrayList<SearchResult>();
 
-		for (final MapLayer ml : mapPane.getContext().getLayers()) {
+		for (final MapLayer ml : mapPane.getMapContext().getLayers()) {
 			try {
 
 				// System.out.println("layer = "+ml.getTitle());



More information about the Schmitzm-commits mailing list