svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.labeling.app / org.gvsig.labeling.app.mainplugin / src / main / java / org / gvsig / labeling / gui / layerproperties / AbstractLabelingMethodPanel.java @ 40911
History | View | Annotate | Download (3.01 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.labeling.gui.layerproperties; |
25 |
|
26 |
import java.beans.PropertyChangeListener; |
27 |
|
28 |
import javax.swing.JPanel; |
29 |
|
30 |
import org.gvsig.fmap.dal.exception.DataException; |
31 |
import org.gvsig.fmap.dal.exception.ReadException; |
32 |
import org.gvsig.fmap.dal.feature.FeatureType; |
33 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
34 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingMethod; |
35 |
|
36 |
|
37 |
public abstract class AbstractLabelingMethodPanel extends JPanel implements PropertyChangeListener { |
38 |
|
39 |
public static final String PLACEMENT_CONSTRAINTS = "PLACEMENT_CONSTRAINTS"; |
40 |
public static final String ALLOW_OVERLAP = "ALLOW_OVERLAP"; |
41 |
public static final String ZOOM_CONSTRAINTS= "ZOOM_CONSTRAINTS"; |
42 |
|
43 |
protected FLyrVect layer;
|
44 |
protected ILabelingMethod method;
|
45 |
|
46 |
public abstract String getName(); |
47 |
public abstract Class<? extends ILabelingMethod> getLabelingMethodClass(); |
48 |
public void setModel(ILabelingMethod method, FLyrVect srcLayer) |
49 |
throws ReadException {
|
50 |
|
51 |
if (srcLayer == null) { |
52 |
throw new ReadException("FLyrVect is null", |
53 |
new Exception("FLyrVect is null")); |
54 |
} |
55 |
this.layer = srcLayer;
|
56 |
|
57 |
try {
|
58 |
if (method!= null && method.getClass().equals(getLabelingMethodClass())) { |
59 |
this.method = method;
|
60 |
} else {
|
61 |
this.method = getLabelingMethodClass().newInstance();
|
62 |
} |
63 |
initializePanel(); |
64 |
|
65 |
} catch (Exception e) { |
66 |
|
67 |
throw new ReadException( |
68 |
srcLayer.getFeatureStore().getName(), |
69 |
new Exception("Unable to load labeling method. Is it in your classpath?", e)); |
70 |
} |
71 |
|
72 |
try {
|
73 |
fillPanel(this.method, srcLayer.getFeatureStore().getDefaultFeatureType());
|
74 |
} catch (DataException de) {
|
75 |
throw new ReadException(srcLayer.getFeatureStore().getName(), de); |
76 |
} |
77 |
|
78 |
} |
79 |
|
80 |
protected abstract void initializePanel() ; |
81 |
public abstract void fillPanel( |
82 |
ILabelingMethod method, |
83 |
FeatureType ftype) throws ReadException;
|
84 |
|
85 |
public String toString() { |
86 |
return getName();
|
87 |
} |
88 |
|
89 |
public ILabelingMethod getMethod() {
|
90 |
return method;
|
91 |
} |
92 |
|
93 |
public boolean equals(Object obj) { |
94 |
if (obj == null) return false; |
95 |
return getClass().equals(obj.getClass());
|
96 |
} |
97 |
} |