1 |
|
/******************************************************************************* |
2 |
|
* Copyright (c) 2009 Martin O. J. Schmitz. |
3 |
|
* |
4 |
|
* This file is part of the SCHMITZM library - a collection of utility |
5 |
|
* classes based on Java 1.6, focussing (not only) on Java Swing |
6 |
|
* and the Geotools library. |
7 |
|
* |
8 |
|
* The SCHMITZM project is hosted at: |
9 |
|
* http://wald.intevation.org/projects/schmitzm/ |
10 |
|
* |
11 |
|
* This program is free software; you can redistribute it and/or |
12 |
|
* modify it under the terms of the GNU Lesser General Public License |
13 |
|
* as published by the Free Software Foundation; either version 3 |
14 |
|
* of the License, or (at your option) any later version. |
15 |
|
* |
16 |
|
* This program is distributed in the hope that it will be useful, |
17 |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 |
|
* GNU General Public License for more details. |
20 |
|
* |
21 |
|
* You should have received a copy of the GNU Lesser General Public License (license.txt) |
22 |
|
* along with this program; if not, write to the Free Software |
23 |
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
|
* or try this link: http://www.gnu.org/licenses/lgpl.html |
25 |
|
* |
26 |
|
* Contributors: |
27 |
|
* Martin O. J. Schmitz - initial API and implementation |
28 |
|
* Stefan A. Krüger - additional utility classes |
29 |
|
******************************************************************************/ |
30 |
/** |
/** |
31 |
Copyright 2008 Stefan Alfons Krüger |
Copyright 2008 Stefan Alfons Krüger |
32 |
|
|
68 |
import schmitzm.geotools.styling.StylingUtil; |
import schmitzm.geotools.styling.StylingUtil; |
69 |
import schmitzm.lang.LangUtil; |
import schmitzm.lang.LangUtil; |
70 |
import skrueger.geotools.MapPaneToolBar; |
import skrueger.geotools.MapPaneToolBar; |
71 |
import skrueger.geotools.StyledMapInterface; |
import skrueger.geotools.StyledLayerInterface; |
72 |
|
|
73 |
/** |
/** |
74 |
* This class keeps the selection of a (feature) {@link JTable} synchronized |
* This class keeps the selection of a (feature) {@link JTable} synchronized |
97 |
* model. |
* model. |
98 |
*/ |
*/ |
99 |
protected final MapLayer mapLayer; |
protected final MapLayer mapLayer; |
100 |
protected final StyledMapInterface<?> styledMapLayer; |
protected final StyledLayerInterface<?> styledLayer; |
101 |
protected final JMapPane mapPane; |
protected final JMapPane mapPane; |
102 |
private final MapPaneToolBar toolBar; |
private final MapPaneToolBar toolBar; |
103 |
|
|
113 |
*/ |
*/ |
114 |
public FeatureMapLayerSelectionSynchronizer( |
public FeatureMapLayerSelectionSynchronizer( |
115 |
StyledFeatureLayerSelectionModel layerSelModel, |
StyledFeatureLayerSelectionModel layerSelModel, |
116 |
StyledMapInterface<?> styledMapLayer, MapLayer mapLayer, |
StyledLayerInterface<?> styledLayer, MapLayer mapLayer, |
117 |
JMapPane mapPane, MapPaneToolBar toolBar) { |
JMapPane mapPane, MapPaneToolBar toolBar) { |
118 |
|
|
119 |
super(layerSelModel); |
super(layerSelModel); |
120 |
this.styledMapLayer = styledMapLayer; |
this.styledLayer = styledLayer; |
121 |
|
|
122 |
this.mapLayer = mapLayer; |
this.mapLayer = mapLayer; |
123 |
this.mapPane = mapPane; |
this.mapPane = mapPane; |
174 |
try { |
try { |
175 |
if (newSelection.isEmpty()) { |
if (newSelection.isEmpty()) { |
176 |
|
|
177 |
selectionMapStyle = styledMapLayer.getStyle(); |
selectionMapStyle = styledLayer.getStyle(); |
178 |
// LOGGER.debug("NO SELECTION .. set to original style directly"); |
// LOGGER.debug("NO SELECTION .. set to original style directly"); |
179 |
|
|
180 |
} else { |
} else { |
181 |
LOGGER.debug("SELECTION .. change style"); |
LOGGER.debug("SELECTION .. change style"); |
182 |
|
|
183 |
// We take Style from the MapLayer that is displayed at the |
// We take Style from the MapLayer that is displayed at the |
184 |
// moment. We do not use the styledMapLayer.getStyle, because in |
// moment. We do not use the styledLayer.getStyle, because in |
185 |
// the atlas, this always return the default style, but |
// the atlas, this always return the default style, but |
186 |
// additionaly styles might be selected. |
// additional styles might be selected. |
187 |
// Taking the style from the mapLayer indicated, that we have to |
// Taking the style from the mapLayer indicated, that we have to |
188 |
// remove any selection rules first. |
// remove any selection rules first. |
189 |
Style originalStyle = mapLayer.getStyle(); |
Style originalStyle = mapLayer.getStyle(); |
191 |
// TODO The default style is not good here. We need |
// TODO The default style is not good here. We need |
192 |
// .createSelectionStyle(normalStyle, geoObj); |
// .createSelectionStyle(normalStyle, geoObj); |
193 |
selectionMapStyle = StylingUtil |
selectionMapStyle = StylingUtil |
194 |
.createSelectionStyle(styledMapLayer.getGeoObject()); |
.createSelectionStyle(styledLayer.getGeoObject()); |
195 |
// selectionMapStyle = StylingUtil |
// selectionMapStyle = StylingUtil |
196 |
// .createDefaultStyle(styledMapLayer.getGeoObject()); |
// .createDefaultStyle(styledLayer.getGeoObject()); |
197 |
|
|
198 |
selectionMapStyle.getFeatureTypeStyles()[0] |
selectionMapStyle.getFeatureTypeStyles()[0] |
199 |
.setName(SELECTION_STYLING); |
.setName(SELECTION_STYLING); |