[Schmitzm-commits] r459 - in branches/1.0-gt2-2.6/src: schmitzm/geotools schmitzm/geotools/feature schmitzm/geotools/gui schmitzm/geotools/styling schmitzm/jfree/feature/style skrueger/swing
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Oct 12 00:45:45 CEST 2009
Author: alfonx
Date: 2009-10-12 00:45:44 +0200 (Mon, 12 Oct 2009)
New Revision: 459
Modified:
branches/1.0-gt2-2.6/src/schmitzm/geotools/GTUtil.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeoMapPane.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java
branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java
branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java
Log:
* Improving the AtlasStyler "label" panel. A nice preview panel is now available.
* Ongoing AtlasStyler migration to Miglayout
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/GTUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/GTUtil.java 2009-10-11 21:58:08 UTC (rev 458)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/GTUtil.java 2009-10-11 22:45:44 UTC (rev 459)
@@ -31,6 +31,7 @@
import java.awt.geom.Rectangle2D;
import java.text.DecimalFormat;
+import java.util.HashMap;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
@@ -70,6 +71,8 @@
/** Konstante fuer das CRS "WGS84" (erzeugt als "EPSG:4326")*/
public static CoordinateReferenceSystem WGS84 = null;
+private static HashMap<Object, Object> defaultRendererHints;
+
// Initialisierung der CRS-Konstanten
static {
try {
@@ -240,4 +243,29 @@
public static GTRendererType getGTRendererType() {
return rendererType;
}
+
+ /**
+ * @return
+ */
+ public static HashMap<Object, Object> getDefaultGTRendererHints() {
+ if (defaultRendererHints == null){
+ defaultRendererHints = new HashMap<Object, Object>();
+
+ /**
+ * This hint avoids "Bursa Wolf Parameters missing" exceptions while
+ * zooming which slow down the rendering process. The exceptions
+ * appeared for example in maps that consisted only of layers of DHDN2
+ * CRS.
+ */
+ defaultRendererHints.put(
+ StreamingRenderer.SCALE_COMPUTATION_METHOD_KEY,
+ StreamingRenderer.SCALE_OGC);
+
+
+
+ }
+ return (HashMap<Object, Object>) defaultRendererHints.clone();
+ }
+
+
}
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java 2009-10-11 21:58:08 UTC (rev 458)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java 2009-10-11 22:45:44 UTC (rev 459)
@@ -695,20 +695,30 @@
public static Vector<SimpleFeature> sortFeatures(
FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
String attrName) {
- return sortFeatures(fc.features(), attrName);
+ final FeatureCollection<SimpleFeatureType, SimpleFeature> source = fc;
+ FeatureIterator<SimpleFeature> iterator = source.features();
+ try {
+ return sortFeatures(iterator, attrName);
+ } finally {
+ source.close(iterator);
+ }
}
/**
* Orderes {@link SimpleFeature Features} according to an attribute
* (ascending).
*
+ * @warn When using this method, it's your responsibility t close the
+ * iterator afterwards!
+ * @see #sortFeatures(FeatureCollection, String)
+ *
* @param fi
* an iterator for the features
* @param attrName
* the attribute to order by
* @return a list of ordered features
*/
- public static Vector<SimpleFeature> sortFeatures(
+ protected static Vector<SimpleFeature> sortFeatures(
FeatureIterator<SimpleFeature> fi, String attrName) {
// First create a SortedMap with CollisionList
SortedMap<Comparable<?>, Vector<SimpleFeature>> sortedFeatureLists = new TreeMap<Comparable<?>, Vector<SimpleFeature>>();
@@ -775,18 +785,24 @@
FeatureIterator<SimpleFeature> fi = fc.features();
// Array fuer die Attribut-Werte eines Features
- List<Object> fValues = new ArrayList<Object>(resultType
- .getAttributeCount());
- for (; fi.hasNext();) {
- // Werte der alten Attribute in Array schreiben
- fValues = fi.next().getAttributes();
+ try {
- // Default-Werte der neuen Attribute in Array schreiben
- for (int i = fType.getAttributeCount(); i < fValues.size(); i++)
- fValues.set(i, resultType.getAttributeDescriptors().get(i)
- .getDefaultValue());
- // Erweitertes SimpleFeature erzeugen und FeatureCollection fuellen
- resultFc.add(createFeature(resultType, fValues));
+ List<Object> fValues = new ArrayList<Object>(resultType
+ .getAttributeCount());
+ for (; fi.hasNext();) {
+ // Werte der alten Attribute in Array schreiben
+ fValues = fi.next().getAttributes();
+
+ // Default-Werte der neuen Attribute in Array schreiben
+ for (int i = fType.getAttributeCount(); i < fValues.size(); i++)
+ fValues.set(i, resultType.getAttributeDescriptors().get(i)
+ .getDefaultValue());
+ // Erweitertes SimpleFeature erzeugen und FeatureCollection
+ // fuellen
+ resultFc.add(createFeature(resultType, fValues));
+ }
+ } finally {
+ fc.close(fi);
}
return resultFc;
@@ -891,56 +907,64 @@
DefaultFeatureCollection resultFc = (DefaultFeatureCollection) DefaultFeatureCollections
.newCollection();
FeatureIterator<SimpleFeature> fi = fc1.features();
- // Array fuer die Attribut-Werte eines Features
- Object[] fValues = new Object[resultType.getAttributeCount()];
+ try {
+ // Array fuer die Attribut-Werte eines Features
+ Object[] fValues = new Object[resultType.getAttributeCount()];
- // NestedLoopJoin: Alle Features der ersten Collection durchgehen
- // und die passenden in der zweiten Collection suchen
- AttributeFilter filter = compareOp.clone();
- for (SimpleFeature f1 = null; fi.hasNext();) {
- f1 = fi.next();
- // Werte der 1. Features in Array schreiben
- if (!projection)
- // Alle Attribut-Werte aus fc1
- getAttributeValues(f1, fValues, 0);
- else
- // Nur Werte der Projektions-Attribute aus fc1
- getAttributeValues(f1, fValues, 0, projAttr);
+ // NestedLoopJoin: Alle Features der ersten Collection durchgehen
+ // und die passenden in der zweiten Collection suchen
+ AttributeFilter filter = compareOp.clone();
+ for (SimpleFeature f1 = null; fi.hasNext();) {
+ f1 = fi.next();
+ // Werte der 1. Features in Array schreiben
+ if (!projection)
+ // Alle Attribut-Werte aus fc1
+ getAttributeValues(f1, fValues, 0);
+ else
+ // Nur Werte der Projektions-Attribute aus fc1
+ getAttributeValues(f1, fValues, 0, projAttr);
- // Passende Features in 2. Colletion suchen
- filter.setAttributeName(joinAttr2);
- filter.setCompareValue(f1.getAttribute(joinAttr1));
- FeatureIterator<SimpleFeature> joinedFeatures = fc2.subCollection(
- filter).features();
+ // Passende Features in 2. Colletion suchen
+ filter.setAttributeName(joinAttr2);
+ filter.setCompareValue(f1.getAttribute(joinAttr1));
+ FeatureIterator<SimpleFeature> joinedFeatures = fc2
+ .subCollection(filter).features();
- // Wenn LEFT-OUTER-JOIN und JOIN nicht erfolgreich, ein Dummy
- // SimpleFeature mit Default-Werten in die Collection einfuegen
- // Sonst: JOIN-Paare "normal" bilden
- if (!joinedFeatures.hasNext() && joinType == JoinType.LEFT_OUTER) {
- if (!projection)
- getDefaultAttributeValues(fType2, fValues, fType1
- .getAttributeCount());
- else
- getDefaultAttributeValues(fType2, fValues, 0, projAttr);
- // Erweitertes SimpleFeature erzeugen und FeatureCollection
- // fuellen
- resultFc.add(createFeature(resultType, fValues));
- } else {
- for (SimpleFeature f2 = null; joinedFeatures.hasNext();) {
- f2 = joinedFeatures.next();
- // Werte der 2. Features in Array schreiben
+ // Wenn LEFT-OUTER-JOIN und JOIN nicht erfolgreich, ein Dummy
+ // SimpleFeature mit Default-Werten in die Collection einfuegen
+ // Sonst: JOIN-Paare "normal" bilden
+ if (!joinedFeatures.hasNext()
+ && joinType == JoinType.LEFT_OUTER) {
if (!projection)
- getAttributeValues(f2, fValues, fType1
+ getDefaultAttributeValues(fType2, fValues, fType1
.getAttributeCount());
else
- getAttributeValues(f2, fValues, 0, projAttr);
+ getDefaultAttributeValues(fType2, fValues, 0, projAttr);
// Erweitertes SimpleFeature erzeugen und FeatureCollection
// fuellen
- SimpleFeature feature = createFeature(resultType, fValues);
- resultFc.add(feature);
+ resultFc.add(createFeature(resultType, fValues));
+ } else {
+ for (SimpleFeature f2 = null; joinedFeatures.hasNext();) {
+ f2 = joinedFeatures.next();
+ // Werte der 2. Features in Array schreiben
+ if (!projection)
+ getAttributeValues(f2, fValues, fType1
+ .getAttributeCount());
+ else
+ getAttributeValues(f2, fValues, 0, projAttr);
+ // Erweitertes SimpleFeature erzeugen und
+ // FeatureCollection
+ // fuellen
+ SimpleFeature feature = createFeature(resultType,
+ fValues);
+ resultFc.add(feature);
+ }
}
}
+ } finally {
+ fc1.close(fi);
}
+ ;
return resultFc;
}
@@ -1914,7 +1938,8 @@
.getSchema().getTypeName(), filter, SAMPLESIZE, null,
"random query for " + ratio);
- final GeometryForm geometryForm = FeatureUtil.getGeometryForm(styledFeatures.getSchema());
+ final GeometryForm geometryForm = FeatureUtil
+ .getGeometryForm(styledFeatures.getSchema());
Iterator<SimpleFeature> it;
it = styledFeatures.getFeatureSource().getFeatures(random100query)
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-10-11 21:58:08 UTC (rev 458)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeoMapPane.java 2009-10-11 22:45:44 UTC (rev 459)
@@ -118,7 +118,7 @@
private boolean disposed = false;
- private HashMap<Object, Object> defaultRendererHints;
+ private static HashMap<Object, Object> defaultRendererHints;
/**
* Erzeugt ein neues {@code GeoMapPane}.
@@ -159,7 +159,7 @@
"GridPanel for horizontal grid must be of type GridPanel.HORIZONTAL!!");
// Karte
- this.mapPane = (mapPane != null) ? mapPane : new JMapPane(null,null,renderer, null, getDefaultGTRendererHints());
+ this.mapPane = (mapPane != null) ? mapPane : new JMapPane(null,null,renderer, null, GTUtil.getDefaultGTRendererHints());
// Koordinaten-Leisten
this.setVertGrid((vGrid != null) ? vGrid : new GridPanel(
GridPanel.VERTICAL, this.mapPane));
@@ -322,29 +322,6 @@
}
}
- /**
- * @return
- */
- public HashMap<Object, Object> getDefaultGTRendererHints() {
- if (defaultRendererHints == null){
- defaultRendererHints = new HashMap<Object, Object>();
-
- /**
- * This hint avoids "Bursa Wolf Parameters missing" exceptions while
- * zooming which slow down the rendering process. The exceptions
- * appeared for example in maps that consisted only of layers of DHDN2
- * CRS.
- */
- defaultRendererHints.put(
- StreamingRenderer.SCALE_COMPUTATION_METHOD_KEY,
- StreamingRenderer.SCALE_OGC);
-
-
-
- }
- return defaultRendererHints;
- }
-
public void setVertGrid(GridPanel vertGrid) {
this.vertGrid = vertGrid;
}
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-10-11 21:58:08 UTC (rev 458)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java 2009-10-11 22:45:44 UTC (rev 459)
@@ -2156,8 +2156,9 @@
public static void copyAllValues(final TextSymbolizer from,
final TextSymbolizer to) {
to.setLabel(from.getLabel());
+ to.setPriority(from.getPriority());
- // TODO Does not copy all that has to be copoied!
+ // TODO Does not copy all that has to be copied!
final FilterFactory2 ff2 = FeatureUtil.FILTER_FACTORY2;
Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java 2009-10-11 21:58:08 UTC (rev 458)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java 2009-10-11 22:45:44 UTC (rev 459)
@@ -57,6 +57,16 @@
super(id);
dummyFeatureChartStyle = new Dummy(id,2);
}
+
+ @Override
+ /**
+ * Nicer debugging
+ */
+ public String toString() {
+
+ String titel = getTitleStyle() != null ? getTitleStyle().getLabel() : " - null title!!! - ";
+ return "ID="+getID()+" "+titel+"" + super.toString();
+ }
/**
* Creates a scatter chart style a regression line shown.
Modified: branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java 2009-10-11 21:58:08 UTC (rev 458)
+++ branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java 2009-10-11 22:45:44 UTC (rev 459)
@@ -19,10 +19,10 @@
public abstract DIALOG create();
/** May be overridden to add Listeners **/
- public void appendListeners(DIALOG newInstance){};
+ public void afterCreation(DIALOG newInstance){};
/** May be overridden to remove Listeners added earlier **/
- public void removeListeners(DIALOG newInstance){};
+ public void beforeDispose(DIALOG newInstance){};
}
@@ -109,23 +109,22 @@
} else {
dialog = factory.create();
-
dialogCache.put(key, dialog);
+ dialog.setVisible(true);
+ dialog.toFront();
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(final WindowEvent e) {
- factory.removeListeners(dialog);
+ factory.beforeDispose(dialog);
disposeInstanceFor(key);
}
});
- factory.appendListeners(dialog);
+ factory.afterCreation(dialog);
}
- dialog.setVisible(true);
- dialog.toFront();
-
+
return dialog;
}
More information about the Schmitzm-commits
mailing list