[Schmitzm-commits] r381 - in branches/1.0-gt2-2.6/src/schmitzm/geotools/gui: . resource/locales
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Sep 4 16:42:14 CEST 2009
Author: mojays
Date: 2009-09-04 16:42:13 +0200 (Fri, 04 Sep 2009)
New Revision: 381
Added:
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/ColorMapPanel.java
Modified:
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/MapContextControlPane.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties
Log:
new ColorMapPanel integrated in (MapContextControlPanel-internal) color map customization dialog
Added: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/ColorMapPanel.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/ColorMapPanel.java 2009-09-04 14:01:50 UTC (rev 380)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/ColorMapPanel.java 2009-09-04 14:42:13 UTC (rev 381)
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ *
+ * This file is part of the SCHMITZM library - a collection of utility
+ * classes based on Java 1.6, focusing (not only) on Java Swing
+ * and the Geotools library.
+ *
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ *
+ * Contributors:
+ * Martin O. J. Schmitz - initial API and implementation
+ * Stefan A. Krüger - additional utility classes
+ ******************************************************************************/
+
+package schmitzm.geotools.gui;
+
+import java.awt.BorderLayout;
+
+import javax.swing.JScrollPane;
+
+import org.geotools.styling.ColorMap;
+
+import schmitzm.swing.InputOption;
+import schmitzm.swing.JPanel;
+import schmitzm.swing.SelectionInputOption;
+import schmitzm.swing.event.InputOptionAdapter;
+
+/**
+ * Besides a {@linkplain ColorMapTable table} for the color map entries
+ * this panel contains components to controll other {@link ColorMap}
+ * properties.
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ *
+ */
+public class ColorMapPanel extends JPanel {
+ /** Holds the color map table. */
+ protected ColorMapTable colMapTable = null;
+ protected SelectionInputOption<Integer> colMapType = null;
+
+ /**
+ * Creates a new panel with no color map.
+ */
+ public ColorMapPanel() {
+ this(null);
+ }
+
+ /**
+ * Creates a new panel.
+ * @param colorMap color map to display
+ */
+ public ColorMapPanel(ColorMap colorMap) {
+ this(colorMap,true);
+ }
+
+ /**
+ * Creates a new panel.
+ * @param colorMap color map to display
+ * @param initGUI indicates whether {@link #initGUI()} is calles at the
+ * end of the constructor
+ */
+ protected ColorMapPanel(ColorMap colorMap, boolean initGUI) {
+ super();
+ if ( initGUI )
+ initGUI();
+ setColorMap(colorMap);
+ }
+
+ /**
+ * Initializes the GUI.
+ */
+ protected void initGUI() {
+ setLayout( new BorderLayout() );
+ this.colMapTable = new ColorMapTable();
+ this.colMapType = new SelectionInputOption.Combo<Integer>(
+ null,
+ true,
+ new Integer[] { ColorMap.TYPE_RAMP, ColorMap.TYPE_INTERVALS, ColorMap.TYPE_VALUES },
+ new String[] { GeotoolsGUIUtil.R("org.geotools.styling.ColorMap.TYPE_RAMP"),
+ GeotoolsGUIUtil.R("org.geotools.styling.ColorMap.TYPE_INTERVALS"),
+ GeotoolsGUIUtil.R("org.geotools.styling.ColorMap.TYPE_VALUES") }
+ );
+ this.colMapType.addInputOptionListener( new InputOptionAdapter() {
+ @Override
+ public void optionChanged(InputOption inputOption, Object oldValue, Object newValue) {
+ colMapTable.getColorMap().setType((Integer)newValue);
+ }
+ });
+
+ this.add( colMapType, BorderLayout.NORTH );
+ this.add( new JScrollPane(colMapTable), BorderLayout.CENTER );
+
+ }
+
+ /**
+ * Returns the displayed {@link ColorMap}.
+ */
+ public ColorMap getColorMap() {
+ return colMapTable.getColorMap();
+ }
+
+ /**
+ * Sets the {@link ColorMap} to display.
+ * @param colorMap a color map
+ */
+ public void setColorMap(ColorMap colorMap) {
+ colMapTable.setColorMap(colorMap);
+ if ( colorMap != null )
+ colMapType.setSelectedItem(colorMap.getType());
+ }
+
+
+}
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-09-04 14:01:50 UTC (rev 380)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/MapContextControlPane.java 2009-09-04 14:42:13 UTC (rev 381)
@@ -601,7 +601,8 @@
private JButton applyButton = null;
private JButton saveButton = null;
// Farbtabellen-Dialog
- private ColorMapTable customiseDialogTable = new ColorMapTable();
+// private ColorMapTable customiseDialogTable = new ColorMapTable();
+ private ColorMapPanel customiseDialogPanel = new ColorMapPanel();
private JDialog customiseDialog = null;
private String cmDialogTitle = GeotoolsGUIUtil.RESOURCE
.getString(CM_DIALOG_TITLE);
@@ -621,7 +622,7 @@
.cloneColorMap(colorMaps.get(colMapName)) : null;
if (colMap != null) {
layer.setStyle(GridUtil.createStyle(colMap, 1.0));
- customiseDialogTable.setColorMap(colMap);
+ customiseDialogPanel.setColorMap(colMap);
mapPane.setReset(true);
mapPane.repaint();
((JCheckBoxMenuItem) e.getSource()).setSelected(true);
@@ -638,7 +639,7 @@
customiseDialog.toFront();
return;
}
- customiseDialogTable.setColorMap(StylingUtil
+ customiseDialogPanel.setColorMap(StylingUtil
.cloneColorMap(StylingUtil.getColorMapFromStyle(layer
.getStyle())));
customiseDialog.setVisible(true);
@@ -785,8 +786,8 @@
applyButton = new JButton(SwingUtil.RESOURCE.getString("Apply"));
saveButton = new JButton(SwingUtil.RESOURCE.getString("Save"));
// Dialog aufbauen
- JOptionPane pane = new JOptionPane(new JScrollPane(
- customiseDialogTable), JOptionPane.QUESTION_MESSAGE,
+ JOptionPane pane = new JOptionPane(
+ customiseDialogPanel, JOptionPane.QUESTION_MESSAGE,
JOptionPane.DEFAULT_OPTION, null, new JButton[] { okButton,
cancelButton, applyButton, saveButton }, okButton);
final JDialog dialog = pane.createDialog(SwingUtil
@@ -810,7 +811,7 @@
// StylingUtil.getColorMapFromStyle(layer.getStyle()) )
// ) {
layer.setStyle(GridUtil.createStyle(StylingUtil
- .cloneColorMap(customiseDialogTable
+ .cloneColorMap(customiseDialogPanel
.getColorMap()), 1.0));
mapPane.setReset(true);
mapPane.repaint();
@@ -830,7 +831,7 @@
JOptionPane.QUESTION_MESSAGE);
if (name != null && !name.trim().equals("")) {
colorMaps.put(name, StylingUtil
- .cloneColorMap(customiseDialogTable
+ .cloneColorMap(customiseDialogPanel
.getColorMap()));
}
}
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties 2009-09-04 14:01:50 UTC (rev 380)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties 2009-09-04 14:42:13 UTC (rev 381)
@@ -43,6 +43,10 @@
org.geotools.styling.StyleBuilder.MARK_TRIANGLE=Triangle
org.geotools.styling.StyleBuilder.MARK_X=X
+org.geotools.styling.ColorMap.TYPE_RAMP=Color interpolation
+org.geotools.styling.ColorMap.TYPE_VALUES=Classifying values
+org.geotools.styling.ColorMap.TYPE_INTERVALS=Classifying intervals
+
schmitzm.geotools.feature.FeatureTableModel.AttrName=Attribut
schmitzm.geotools.feature.FeatureTableModel.AttrType=Type
schmitzm.geotools.feature.FeatureTableModel.AttrValue=Value
More information about the Schmitzm-commits
mailing list