Revision 42981
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/legend/gui/LabelingManager.java | ||
---|---|---|
68 | 68 |
}; |
69 | 69 |
private TreeMap<Class<?>, ILabelingStrategyPanel> strategyPanels = |
70 | 70 |
new TreeMap<Class<?>, ILabelingStrategyPanel>(comparator); |
71 |
|
|
71 |
|
|
72 | 72 |
private JCheckBox chkApplyLabels; |
73 | 73 |
private ILabelable layer; |
74 | 74 |
private JPanel content; |
... | ... | |
102 | 102 |
} |
103 | 103 |
|
104 | 104 |
} |
105 |
|
|
105 |
|
|
106 | 106 |
@Override |
107 | 107 |
public int getPriority() { |
108 | 108 |
return 600; |
... | ... | |
111 | 111 |
private void initialize() { |
112 | 112 |
setLayout(new BorderLayout()); |
113 | 113 |
SymbologySwingManager symbologySwingManager = SymbologySwingLocator.getSwingManager(); |
114 |
|
|
114 |
|
|
115 | 115 |
Iterator<ILabelingStrategyPanel> it = symbologySwingManager.getLabelingEditors().iterator(); |
116 | 116 |
while( it.hasNext() ) { |
117 | 117 |
ILabelingStrategyPanel pnl = it.next(); |
... | ... | |
188 | 188 |
} |
189 | 189 |
|
190 | 190 |
/** |
191 |
*
|
|
191 |
* |
|
192 | 192 |
* @deprecated use {#SymbolSwingManger. |
193 | 193 |
*/ |
194 | 194 |
public static void addLabelingStrategy(Class<? extends ILabelingStrategyPanel> iLabelingStrategyPanelClass) { |
... | ... | |
273 | 273 |
} |
274 | 274 |
|
275 | 275 |
public void acceptAction() { |
276 |
|
|
276 |
applyAction(); |
|
277 | 277 |
} |
278 | 278 |
|
279 | 279 |
public void cancelAction() { |
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 | ||
---|---|---|
34 | 34 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingMethod; |
35 | 35 |
|
36 | 36 |
|
37 |
/** |
|
38 |
* @author gvSIG Team |
|
39 |
* |
|
40 |
*/ |
|
37 | 41 |
public abstract class AbstractLabelingMethodPanel extends JPanel implements PropertyChangeListener { |
38 |
|
|
39 |
public static final String PLACEMENT_CONSTRAINTS = "PLACEMENT_CONSTRAINTS"; |
|
42 |
|
|
43 |
/** |
|
44 |
* |
|
45 |
*/ |
|
46 |
private static final long serialVersionUID = 3042343486793818865L; |
|
47 |
/** |
|
48 |
* |
|
49 |
*/ |
|
50 |
public static final String PLACEMENT_CONSTRAINTS = "PLACEMENT_CONSTRAINTS"; |
|
51 |
/** |
|
52 |
* |
|
53 |
*/ |
|
40 | 54 |
public static final String ALLOW_OVERLAP = "ALLOW_OVERLAP"; |
55 |
/** |
|
56 |
* |
|
57 |
*/ |
|
41 | 58 |
public static final String ZOOM_CONSTRAINTS= "ZOOM_CONSTRAINTS"; |
42 |
|
|
59 |
|
|
43 | 60 |
protected FLyrVect layer; |
44 | 61 |
protected ILabelingMethod method; |
45 |
|
|
62 |
|
|
46 | 63 |
public abstract String getName(); |
64 |
|
|
65 |
/** |
|
66 |
* @return the labeling method class. |
|
67 |
*/ |
|
47 | 68 |
public abstract Class<? extends ILabelingMethod> getLabelingMethodClass(); |
69 |
|
|
70 |
/** |
|
71 |
* @param method |
|
72 |
* @param srcLayer |
|
73 |
* @throws ReadException |
|
74 |
*/ |
|
48 | 75 |
public void setModel(ILabelingMethod method, FLyrVect srcLayer) |
49 | 76 |
throws ReadException { |
50 |
|
|
77 |
|
|
51 | 78 |
if (srcLayer == null) { |
52 | 79 |
throw new ReadException("FLyrVect is null", |
53 | 80 |
new Exception("FLyrVect is null")); |
... | ... | |
55 | 82 |
this.layer = srcLayer; |
56 | 83 |
|
57 | 84 |
try { |
58 |
if (method!= null && method.getClass().equals(getLabelingMethodClass())) { |
|
85 |
Class<? extends ILabelingMethod> labelingMethodClass = getLabelingMethodClass(); |
|
86 |
if (method!= null && method.getClass().equals(labelingMethodClass)) { |
|
59 | 87 |
this.method = method; |
60 | 88 |
} else { |
61 |
this.method = getLabelingMethodClass().newInstance();
|
|
89 |
this.method = labelingMethodClass.newInstance();
|
|
62 | 90 |
} |
63 |
initializePanel(); |
|
64 |
|
|
91 |
|
|
65 | 92 |
} catch (Exception e) { |
66 |
|
|
93 |
|
|
67 | 94 |
throw new ReadException( |
68 |
srcLayer.getFeatureStore().getName(),
|
|
69 |
new Exception("Unable to load labeling method. Is it in your classpath?", e));
|
|
95 |
srcLayer.getFeatureStore().getName(), |
|
96 |
new Exception("Unable to load labeling method. Is it in your classpath?", e)); |
|
70 | 97 |
} |
71 |
|
|
98 |
initializePanel(); |
|
99 |
|
|
72 | 100 |
try { |
73 |
fillPanel(this.method, srcLayer.getFeatureStore().getDefaultFeatureType());
|
|
101 |
fillPanel(srcLayer.getFeatureStore().getDefaultFeatureType()); |
|
74 | 102 |
} catch (DataException de) { |
75 | 103 |
throw new ReadException(srcLayer.getFeatureStore().getName(), de); |
76 | 104 |
} |
77 |
|
|
105 |
|
|
78 | 106 |
} |
79 |
|
|
107 |
|
|
80 | 108 |
protected abstract void initializePanel() ; |
109 |
/** |
|
110 |
* @param ftype |
|
111 |
* @throws ReadException |
|
112 |
*/ |
|
81 | 113 |
public abstract void fillPanel( |
82 |
ILabelingMethod method, |
|
83 | 114 |
FeatureType ftype) throws ReadException; |
84 |
|
|
115 |
|
|
85 | 116 |
public String toString() { |
86 | 117 |
return getName(); |
87 | 118 |
} |
88 |
|
|
119 |
|
|
120 |
/** |
|
121 |
* @return the labeling method |
|
122 |
*/ |
|
89 | 123 |
public ILabelingMethod getMethod() { |
90 |
return method;
|
|
124 |
return method; |
|
91 | 125 |
} |
92 |
|
|
126 |
|
|
93 | 127 |
public boolean equals(Object obj) { |
94 | 128 |
if (obj == null) return false; |
95 | 129 |
return getClass().equals(obj.getClass()); |
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/DefaultLabeling.java | ||
---|---|---|
40 | 40 |
import javax.swing.JPanel; |
41 | 41 |
import javax.swing.JSplitPane; |
42 | 42 |
|
43 |
import org.slf4j.Logger; |
|
44 |
import org.slf4j.LoggerFactory; |
|
45 |
|
|
43 | 46 |
import org.gvsig.andami.messages.NotificationManager; |
44 | 47 |
import org.gvsig.app.ApplicationLocator; |
45 |
import org.gvsig.fmap.dal.exception.DataException; |
|
46 | 48 |
import org.gvsig.fmap.dal.exception.ReadException; |
47 |
import org.gvsig.fmap.dal.feature.Feature; |
|
48 | 49 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
49 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
50 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
51 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
52 | 50 |
import org.gvsig.fmap.dal.feature.FeatureType; |
53 | 51 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelClass; |
54 | 52 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingMethod; |
... | ... | |
63 | 61 |
import org.gvsig.labeling.lang.LabelClassUtils; |
64 | 62 |
import org.gvsig.symbology.SymbologyLocator; |
65 | 63 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.DefaultLabelingMethod; |
66 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
67 |
import org.slf4j.Logger; |
|
68 |
import org.slf4j.LoggerFactory; |
|
69 | 64 |
|
70 | 65 |
public class DefaultLabeling extends AbstractLabelingMethodPanel implements |
71 | 66 |
ActionListener { |
... | ... | |
87 | 82 |
private IZoomConstraints zoomConstraints; |
88 | 83 |
private LabelClassProperties lcProp; |
89 | 84 |
|
85 |
private JSplitPane scrl; |
|
86 |
private JPanel aux; |
|
87 |
private JPanel aux2; |
|
88 |
|
|
89 |
|
|
90 | 90 |
public Class<? extends ILabelingMethod> getLabelingMethodClass() { |
91 | 91 |
return DefaultLabelingMethod.class; |
92 | 92 |
} |
... | ... | |
96 | 96 |
} |
97 | 97 |
|
98 | 98 |
@Override |
99 |
public void fillPanel(ILabelingMethod method, FeatureType fty) {
|
|
99 |
public void fillPanel(FeatureType fty) { |
|
100 | 100 |
try { |
101 |
if (enableLayerPrev.isSelected()) {
|
|
101 |
if (getEnableLayerPreview().isSelected()) {
|
|
102 | 102 |
layerPrev.setLayer(layer); |
103 | 103 |
} else { |
104 | 104 |
layerPrev.setLayer(null); |
... | ... | |
175 | 175 |
} |
176 | 176 |
|
177 | 177 |
@Override |
178 |
protected void initializePanel() { |
|
179 |
setLayout(new BorderLayout()); |
|
180 |
JSplitPane scrl = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
|
181 |
scrl.add(getLayerPreview(), JSplitPane.LEFT); |
|
178 |
protected void initializePanel() { |
|
179 |
setLayout(new BorderLayout()); |
|
180 |
add(getScrl(), BorderLayout.CENTER); |
|
181 |
scrl.setDividerLocation(500); |
|
182 |
getEnableLayerPreview().setSelected(false); |
|
183 |
add(getEnableLayerPreview(), BorderLayout.SOUTH); |
|
184 |
} |
|
182 | 185 |
|
183 |
labelPrev = getLabelPrev(); // new LabelClassPreview(); |
|
184 |
JPanel aux = new JPanel(new BorderLayout()); |
|
185 |
aux.add(new JBlank(10, 10), BorderLayout.NORTH); |
|
186 |
aux.add(new JBlank(10, 10), BorderLayout.WEST); |
|
187 |
aux.add(labelPrev, BorderLayout.CENTER); |
|
188 |
aux.add(new JBlank(10, 10), BorderLayout.EAST); |
|
189 |
JPanel aux2 = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10)); |
|
190 |
btnProperties = getBtnProperties(); |
|
191 |
aux2.add(btnProperties); |
|
192 |
aux.add(aux2, BorderLayout.SOUTH); |
|
193 |
scrl.add(aux, JSplitPane.RIGHT); |
|
194 |
add(scrl, BorderLayout.CENTER); |
|
195 |
scrl.setDividerLocation(500); |
|
186 |
private JSplitPane getScrl() { |
|
187 |
if (scrl == null) { |
|
188 |
scrl = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
|
189 |
} |
|
190 |
scrl.add(getLayerPreview(), JSplitPane.LEFT); |
|
191 |
scrl.add(getAuxPanel(), JSplitPane.RIGHT); |
|
192 |
add(scrl, BorderLayout.CENTER); |
|
193 |
return scrl; |
|
194 |
} |
|
196 | 195 |
|
197 |
getEnableLayerPreview().setSelected(false); |
|
198 |
add(enableLayerPrev, BorderLayout.SOUTH); |
|
196 |
JPanel getAuxPanel(){ |
|
197 |
if(aux == null){ |
|
198 |
aux = new JPanel(new BorderLayout()); |
|
199 |
aux.add(new JBlank(10, 10), BorderLayout.NORTH); |
|
200 |
aux.add(new JBlank(10, 10), BorderLayout.WEST); |
|
201 |
aux.add(getLabelPrev(), BorderLayout.CENTER); |
|
202 |
aux.add(new JBlank(10, 10), BorderLayout.EAST); |
|
203 |
aux.add(getAux2Panel(), BorderLayout.SOUTH); |
|
204 |
} |
|
205 |
return aux; |
|
199 | 206 |
} |
200 | 207 |
|
208 |
JPanel getAux2Panel(){ |
|
209 |
if(aux2 == null){ |
|
210 |
aux2 = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10)); |
|
211 |
aux2.add(getBtnProperties()); |
|
212 |
} |
|
213 |
return aux2; |
|
214 |
} |
|
215 |
|
|
201 | 216 |
private LabelClassProperties getLcProp() { |
202 | 217 |
if (lcProp == null) { |
203 | 218 |
|
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/FeatureDependent.java | ||
---|---|---|
75 | 75 |
|
76 | 76 |
public class FeatureDependent extends AbstractLabelingMethodPanel implements ActionListener{ |
77 | 77 |
private static final Logger logger = LoggerFactory.getLogger(FeatureDependent.class); |
78 |
|
|
78 |
|
|
79 | 79 |
private static final long serialVersionUID = 5493451803343695650L; |
80 | 80 |
private static int NAME_FIELD_INDEX = 0; |
81 | 81 |
private static int PREVIEW_FIELD_INDEX = 1; |
... | ... | |
91 | 91 |
private boolean openEditor = false; |
92 | 92 |
private JButton btnMoveDownClass; |
93 | 93 |
private JButton btnDelClass; |
94 |
|
|
94 |
|
|
95 |
private JPanel panel; |
|
96 |
|
|
97 |
|
|
95 | 98 |
/* |
96 | 99 |
private String[] fieldNames; |
97 | 100 |
private int[] fieldTypes; |
... | ... | |
101 | 104 |
|
102 | 105 |
@Override |
103 | 106 |
public String getName() { |
104 |
|
|
107 |
|
|
105 | 108 |
return Messages.getText( |
106 | 109 |
"define_classes_of_features_and_label_each_differently")+"."; |
107 | 110 |
} |
... | ... | |
341 | 344 |
|
342 | 345 |
|
343 | 346 |
private class LabelClassTableModel extends DefaultTableModel { |
344 |
|
|
347 |
|
|
345 | 348 |
private static final long serialVersionUID = -9152998982339430209L; |
346 | 349 |
Object[][] values; |
347 | 350 |
|
... | ... | |
412 | 415 |
|
413 | 416 |
@Override |
414 | 417 |
protected void initializePanel() { |
415 |
|
|
416 | 418 |
setLayout(new BorderLayout()); |
417 |
JPanel panel = new JPanel(new BorderLayout()); |
|
418 |
|
|
419 |
GridLayout gl = new GridLayout(4,1); |
|
420 |
buttonPanel = new JPanel(gl); |
|
421 |
buttonPanel.add(getBtnAddClass()); |
|
422 |
buttonPanel.add(getBtnDelClass()); |
|
423 |
// buttonPanel.addComponent(new JBlank(10, 10)); |
|
424 |
buttonPanel.add(getBtnMoveUpClass()); |
|
425 |
buttonPanel.add(getBtnMoveDownClass()); |
|
426 |
|
|
427 |
JPanel auxp = new JPanel(); |
|
428 |
auxp.add(buttonPanel); |
|
429 |
|
|
430 |
panel.add(auxp, BorderLayout.EAST); |
|
431 |
panel.add(getChkDefinePriorities(), BorderLayout.NORTH); |
|
432 |
|
|
433 |
JPanel centro = new JPanel(new BorderLayout()); |
|
434 |
centro.add(getLabelClassSelector(), BorderLayout.NORTH); |
|
435 |
centro.add(getCenterScrl(), BorderLayout.CENTER); |
|
436 |
panel.add(centro, BorderLayout.CENTER); |
|
437 |
|
|
438 |
add(panel,BorderLayout.CENTER); |
|
419 |
add(getPanel(),BorderLayout.CENTER); |
|
439 | 420 |
} |
440 | 421 |
|
422 |
private JPanel getPanel() { |
|
423 |
if (this.panel == null) { |
|
424 |
this.panel = new JPanel(new BorderLayout()); |
|
441 | 425 |
|
426 |
GridLayout gl = new GridLayout(4, 1); |
|
427 |
buttonPanel = new JPanel(gl); |
|
428 |
buttonPanel.add(getBtnAddClass()); |
|
429 |
buttonPanel.add(getBtnDelClass()); |
|
430 |
// buttonPanel.addComponent(new JBlank(10, 10)); |
|
431 |
buttonPanel.add(getBtnMoveUpClass()); |
|
432 |
buttonPanel.add(getBtnMoveDownClass()); |
|
433 |
|
|
434 |
JPanel auxp = new JPanel(); |
|
435 |
auxp.add(buttonPanel); |
|
436 |
|
|
437 |
this.panel.add(auxp, BorderLayout.EAST); |
|
438 |
this.panel.add(getChkDefinePriorities(), BorderLayout.NORTH); |
|
439 |
|
|
440 |
JPanel centro = new JPanel(new BorderLayout()); |
|
441 |
centro.add(getLabelClassSelector(), BorderLayout.NORTH); |
|
442 |
centro.add(getCenterScrl(), BorderLayout.CENTER); |
|
443 |
panel.add(centro, BorderLayout.CENTER); |
|
444 |
|
|
445 |
} |
|
446 |
return this.panel; |
|
447 |
|
|
448 |
} |
|
449 |
|
|
450 |
|
|
442 | 451 |
private JPanel getLabelClassSelector() { |
443 | 452 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
444 | 453 |
SymbologyManager symbologyMamanger = SymbologyLocator.getSymbologyManager(); |
445 |
|
|
454 |
|
|
446 | 455 |
JPanel panel = new JPanel(new BorderLayout()); |
447 | 456 |
panel.add(new JLabel(i18nManager.getTranslation("_Label_type_to_use_XcolonX")), BorderLayout.WEST); |
448 |
|
|
457 |
|
|
449 | 458 |
DefaultComboBoxModel model = new DefaultComboBoxModel(); |
450 | 459 |
Collection<ILabelClassFactory> factories = symbologyMamanger.getLabelClassFactories(); |
451 | 460 |
for( ILabelClassFactory factory : factories ) { |
... | ... | |
458 | 467 |
} |
459 | 468 |
return panel; |
460 | 469 |
} |
461 |
|
|
462 |
public void fillPanel(ILabelingMethod method, FeatureType fty)
|
|
470 |
|
|
471 |
public void fillPanel(FeatureType fty) |
|
463 | 472 |
throws ReadException { |
464 |
|
|
465 |
if (method == null) { |
|
466 |
this.method = new FeatureDependentLabeled(); |
|
467 |
} |
|
473 |
|
|
468 | 474 |
chkDefinePriorities.setSelected(this.method.definesPriorities()); |
469 | 475 |
repaint(); |
470 | 476 |
} |
... | ... | |
563 | 569 |
} |
564 | 570 |
repaint(); |
565 | 571 |
} |
566 |
|
|
572 |
|
|
567 | 573 |
public void propertyChange(PropertyChangeEvent evt) { |
568 | 574 |
// TODO Auto-generated method stub |
569 | 575 |
|
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/OnSelection.java | ||
---|---|---|
44 | 44 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingMethod; |
45 | 45 |
import org.gvsig.i18n.Messages; |
46 | 46 |
import org.gvsig.labeling.label.OnSelectionLabeled; |
47 |
import org.gvsig.symbology.SymbologyLocator; |
|
48 | 47 |
|
48 |
/** |
|
49 |
* @author gvSIG Team |
|
50 |
* |
|
51 |
*/ |
|
49 | 52 |
public class OnSelection extends DefaultLabeling{ |
50 | 53 |
|
51 | 54 |
private static final long serialVersionUID = -3619706540747109386L; |
... | ... | |
60 | 63 |
return OnSelectionLabeled.class; |
61 | 64 |
} |
62 | 65 |
|
63 |
@Override |
|
64 |
public ILabelingMethod getMethod() { |
|
65 |
|
|
66 |
OnSelectionLabeled resp = null; |
|
67 |
if (super.getMethod() instanceof OnSelectionLabeled) { |
|
68 |
resp = (OnSelectionLabeled) super.getMethod(); |
|
69 |
} else { |
|
70 |
resp = new OnSelectionLabeled(); |
|
71 |
} |
|
72 |
|
|
73 |
if (resp.getLabelClasses() == null || resp.getLabelClasses().length == 0) { |
|
74 |
ILabelClass lc = null; |
|
75 |
lc = SymbologyLocator.getSymbologyManager().createDefaultLabel(); |
|
76 |
resp.addLabelClass(lc); |
|
77 |
} |
|
78 |
return resp; |
|
79 |
} |
|
80 |
|
|
81 | 66 |
protected ILabelingMethod newMethodForThePreview(ILabelClass defaultLabel) { |
82 | 67 |
OnSelectionLabeled method = new OnSelectionLabeled(); |
83 | 68 |
method.addLabelClass(defaultLabel); |
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/GeneralLabeling.java | ||
---|---|---|
45 | 45 |
import javax.swing.JLabel; |
46 | 46 |
import javax.swing.JPanel; |
47 | 47 |
|
48 |
import org.slf4j.Logger; |
|
49 |
import org.slf4j.LoggerFactory; |
|
50 |
|
|
48 | 51 |
import org.gvsig.andami.messages.NotificationManager; |
49 | 52 |
import org.gvsig.app.ApplicationLocator; |
50 | 53 |
import org.gvsig.app.project.documents.view.legend.gui.ILabelingStrategyPanel; |
51 | 54 |
import org.gvsig.fmap.dal.exception.ReadException; |
52 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
53 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
54 | 55 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
55 | 56 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
56 | 57 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
... | ... | |
64 | 65 |
import org.gvsig.labeling.lang.LabelClassUtils; |
65 | 66 |
import org.gvsig.symbology.SymbologyLocator; |
66 | 67 |
|
68 |
/** |
|
69 |
* @author gvSIG Team |
|
70 |
* |
|
71 |
*/ |
|
67 | 72 |
public class GeneralLabeling extends JPanel implements |
68 | 73 |
ILabelingStrategyPanel, ActionListener { |
69 |
|
|
74 |
|
|
70 | 75 |
private static final long serialVersionUID = 8864709758980903351L; |
71 |
private static Comparator comparator = |
|
76 |
private static final Logger logger = LoggerFactory |
|
77 |
.getLogger(GeneralLabeling.class); |
|
78 |
private static Comparator<Class<? extends ILabelingMethod>> comparator = |
|
72 | 79 |
new Comparator<Class<? extends ILabelingMethod>>(){ |
73 | 80 |
public int compare(Class<? extends ILabelingMethod> o1, |
74 | 81 |
Class<? extends ILabelingMethod> o2) { |
75 | 82 |
return o1.getName().compareTo(o2.getName()); |
76 | 83 |
}}; |
77 |
|
|
84 |
|
|
78 | 85 |
private static TreeMap< |
79 | 86 |
Class<? extends ILabelingMethod>, |
80 | 87 |
Class<? extends AbstractLabelingMethodPanel> |
... | ... | |
83 | 90 |
Class<? extends ILabelingMethod>, |
84 | 91 |
Class<? extends AbstractLabelingMethodPanel> |
85 | 92 |
>(comparator); |
86 |
|
|
93 |
|
|
87 | 94 |
private JButton btnVisualization; |
88 | 95 |
private JButton btnPlacement; |
89 |
private JComboBox cmbMethod; |
|
96 |
private JComboBox<?> cmbMethod;
|
|
90 | 97 |
private JPanel methodPanel; |
91 | 98 |
private IPlacementConstraints placementConstraints; |
92 | 99 |
private IZoomConstraints zoomConstraints; |
... | ... | |
95 | 102 |
private JCheckBox chkAllowLabelOverlapping; |
96 | 103 |
private FLyrVect auxLayer; |
97 | 104 |
private GeneralLabelingStrategy gStr; |
98 |
private AbstractLabelingMethodPanel previousMethodPanel = null; |
|
105 |
/** |
|
106 |
* |
|
107 |
*/ |
|
99 | 108 |
public GeneralLabeling() { |
100 | 109 |
initialize(); |
101 | 110 |
} |
102 | 111 |
|
103 | 112 |
private void initialize() { |
104 |
|
|
113 |
|
|
105 | 114 |
setLayout(new BorderLayout()); |
106 | 115 |
JPanel center = new JPanel(new BorderLayout(10, 10)); |
107 | 116 |
center.setBorder(BorderFactory.createTitledBorder( |
... | ... | |
171 | 180 |
return btnPlacement; |
172 | 181 |
} |
173 | 182 |
|
174 |
private JComboBox getCmbMethod() { |
|
183 |
@SuppressWarnings({ "rawtypes", "unchecked" }) |
|
184 |
private JComboBox getCmbMethod() { |
|
175 | 185 |
if (cmbMethod == null) { |
176 | 186 |
Iterator<Class<? extends AbstractLabelingMethodPanel>> it = methods.values().iterator(); |
177 | 187 |
ArrayList<AbstractLabelingMethodPanel> panels = new ArrayList<AbstractLabelingMethodPanel>(); |
... | ... | |
201 | 211 |
return resp; |
202 | 212 |
} |
203 | 213 |
|
204 |
|
|
214 |
|
|
205 | 215 |
public void setModel(FLayer layer, ILabelingStrategy str) { |
206 | 216 |
if (layer instanceof FLyrVect) { |
207 | 217 |
try { |
208 | 218 |
targetLayer = (FLyrVect) layer;//.cloneLayer(); |
209 |
|
|
219 |
|
|
210 | 220 |
auxLayer = (FLyrVect) targetLayer.cloneLayer(); |
211 | 221 |
auxLayer.setParentLayer(layer.getParentLayer()); |
212 | 222 |
auxLayer.setLegend((IVectorLegend)targetLayer.getLegend()); |
213 | 223 |
auxLayer.setProjection(targetLayer.getProjection()); |
214 |
|
|
224 |
|
|
215 | 225 |
if (str instanceof GeneralLabelingStrategy) { |
216 |
GeneralLabelingStrategy gls = (GeneralLabelingStrategy) str;
|
|
226 |
GeneralLabelingStrategy gls = (GeneralLabelingStrategy) str; |
|
217 | 227 |
gStr = (GeneralLabelingStrategy) gls.clone(); |
218 | 228 |
auxLayer.setLabelingStrategy(gStr); |
219 | 229 |
gStr.setLayer(auxLayer); |
... | ... | |
237 | 247 |
} |
238 | 248 |
|
239 | 249 |
|
250 |
/** |
|
251 |
* @param iLabelingMethodClass |
|
252 |
*/ |
|
240 | 253 |
public static void addLabelingMethod(Class<? extends AbstractLabelingMethodPanel> iLabelingMethodClass) { |
241 | 254 |
try { |
242 | 255 |
methods.put( |
... | ... | |
276 | 289 |
if (zoomConstraints == null) { |
277 | 290 |
zoomConstraints = |
278 | 291 |
SymbologyLocator.getSymbologyManager().createDefaultZoomConstraints(); |
279 |
|
|
292 |
|
|
280 | 293 |
} |
281 | 294 |
return zoomConstraints; |
282 | 295 |
} |
... | ... | |
297 | 310 |
IPlacementProperties pp = PlacementProperties.createPlacementProperties( |
298 | 311 |
getPlacementConstraints(), |
299 | 312 |
((FLyrVect) auxLayer).getShapeType()); |
300 |
|
|
313 |
|
|
301 | 314 |
ApplicationLocator.getManager().getUIManager().addWindow(pp); |
302 |
|
|
315 |
|
|
303 | 316 |
placementConstraints = pp.getPlacementConstraints(); |
304 | 317 |
|
305 | 318 |
((AbstractLabelingMethodPanel) cmbMethod.getSelectedItem()). |
... | ... | |
348 | 361 |
!newValue, |
349 | 362 |
newValue)); |
350 | 363 |
|
351 |
} else if (c.equals(cmbMethod)) { |
|
352 |
AbstractLabelingMethodPanel p = (AbstractLabelingMethodPanel) cmbMethod.getSelectedItem(); |
|
353 |
if(previousMethodPanel == null || previousMethodPanel != p ){ |
|
354 |
Container cont = methodPanel.getParent(); |
|
355 |
cont.remove(methodPanel); |
|
356 |
emptyContainer(methodPanel); |
|
364 |
} else if (c.equals(getCmbMethod())) { |
|
365 |
AbstractLabelingMethodPanel p = (AbstractLabelingMethodPanel) cmbMethod.getSelectedItem(); |
|
366 |
Container cont = methodPanel.getParent(); |
|
367 |
cont.remove(methodPanel); |
|
368 |
emptyContainer(methodPanel); |
|
357 | 369 |
|
358 |
try { |
|
359 |
if(gStr != null){ |
|
360 |
if(gStr.getLabelingMethod() != null){ |
|
361 |
p.setModel(gStr.getLabelingMethod(), auxLayer); |
|
362 |
} |
|
363 |
} else { |
|
364 |
p.setModel(getMethod(),auxLayer); |
|
365 |
} |
|
366 |
methodPanel.add( |
|
367 |
p, |
|
368 |
BorderLayout.CENTER); |
|
370 |
try { |
|
371 |
if (gStr != null) { |
|
372 |
if (gStr.getLabelingMethod() != null) { |
|
373 |
p.setModel(gStr.getLabelingMethod(), auxLayer); |
|
374 |
} |
|
375 |
} else { |
|
376 |
p.setModel(getMethod(), auxLayer); |
|
377 |
} |
|
378 |
methodPanel.add(p, BorderLayout.CENTER); |
|
369 | 379 |
|
370 |
methodPanel.repaint(); |
|
371 |
setVisible(false); |
|
372 |
setVisible(true); |
|
373 |
} catch (Exception e1) { |
|
374 |
NotificationManager.addError(new Date(System.currentTimeMillis()).toString(), e1); |
|
375 |
} |
|
376 |
cont.add(methodPanel, BorderLayout.CENTER); |
|
377 |
} |
|
378 |
previousMethodPanel = p; |
|
379 |
} |
|
380 |
|
|
381 |
} |
|
380 |
methodPanel.repaint(); |
|
381 |
setVisible(false); |
|
382 |
setVisible(true); |
|
383 |
} catch (Exception e1) { |
|
384 |
NotificationManager.addError(new Date(System.currentTimeMillis()).toString(), e1); |
|
385 |
} |
|
386 |
cont.add(methodPanel, BorderLayout.CENTER); |
|
387 |
} |
|
382 | 388 |
|
383 |
private void emptyContainer(Container c) { |
|
384 |
for (int i = 0; i < c.getComponentCount(); i++) { |
|
385 |
if (c.getComponent(i) instanceof Container) { |
|
386 |
emptyContainer((Container) c.getComponent(i)); |
|
387 |
} |
|
388 |
c.remove(i); |
|
389 |
} |
|
390 | 389 |
} |
391 | 390 |
|
391 |
private void emptyContainer(Container c) { |
|
392 |
for (int i = 0; i < c.getComponentCount(); i++) { |
|
393 |
c.remove(i); |
|
394 |
} |
|
395 |
} |
|
396 |
|
|
392 | 397 |
public String getLabelingStrategyName() { |
393 | 398 |
return Messages.getText("user_defined_labels"); |
394 | 399 |
} |
Also available in: Unified diff