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 / DuplicateLayersMode.java @ 40911
History | View | Annotate | Download (3.93 KB)
1 | 40911 | jldominguez | /**
|
---|---|---|---|
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.awt.event.ActionEvent; |
||
27 | import java.awt.event.ActionListener; |
||
28 | |||
29 | import javax.swing.BorderFactory; |
||
30 | import javax.swing.ButtonGroup; |
||
31 | import javax.swing.JRadioButton; |
||
32 | |||
33 | import org.gvsig.fmap.mapcontext.rendering.legend.styling.IPlacementConstraints; |
||
34 | import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
||
35 | import org.gvsig.i18n.Messages; |
||
36 | |||
37 | public class DuplicateLayersMode extends GridBagLayoutPanel |
||
38 | implements ActionListener { |
||
39 | |||
40 | private static final long serialVersionUID = 1091963463412809652L; |
||
41 | private JRadioButton rdBtnRemoveDuplicates; |
||
42 | private JRadioButton rdBtnOnePerFeature; |
||
43 | private JRadioButton rdBtnOnePerFeaturePart; |
||
44 | |||
45 | private ActionListener actListeneter = null; |
||
46 | |||
47 | public DuplicateLayersMode(ActionListener act_lis) { |
||
48 | super();
|
||
49 | actListeneter = act_lis; |
||
50 | initialize(); |
||
51 | } |
||
52 | private void initialize() { |
||
53 | setBorder(BorderFactory.
|
||
54 | createTitledBorder(null,
|
||
55 | Messages.getText("duplicate_labels")));
|
||
56 | addComponent(getRdBtnRemoveDuplicates()); |
||
57 | addComponent(getRdBtnOnePerFeature()); |
||
58 | addComponent(getRdBtnOnePerFeaturePart()); |
||
59 | |||
60 | ButtonGroup group = new ButtonGroup(); |
||
61 | group.add(getRdBtnOnePerFeature()); |
||
62 | group.add(getRdBtnOnePerFeaturePart()); |
||
63 | group.add(getRdBtnRemoveDuplicates()); |
||
64 | } |
||
65 | |||
66 | |||
67 | private JRadioButton getRdBtnOnePerFeaturePart() { |
||
68 | if (rdBtnOnePerFeaturePart == null) { |
||
69 | rdBtnOnePerFeaturePart = new JRadioButton( |
||
70 | Messages.getText("place_one_label_per_feature_part"));
|
||
71 | rdBtnOnePerFeaturePart.addActionListener(this);
|
||
72 | |||
73 | } |
||
74 | return rdBtnOnePerFeaturePart;
|
||
75 | } |
||
76 | |||
77 | private JRadioButton getRdBtnOnePerFeature() { |
||
78 | if (rdBtnOnePerFeature == null) { |
||
79 | rdBtnOnePerFeature = new JRadioButton( |
||
80 | Messages.getText("place_one_label_per_feature"));
|
||
81 | rdBtnOnePerFeature.setSelected(true);
|
||
82 | rdBtnOnePerFeature.addActionListener(this);
|
||
83 | } |
||
84 | return rdBtnOnePerFeature;
|
||
85 | } |
||
86 | |||
87 | private JRadioButton getRdBtnRemoveDuplicates() { |
||
88 | if (rdBtnRemoveDuplicates == null) { |
||
89 | rdBtnRemoveDuplicates = new JRadioButton( |
||
90 | Messages.getText("remove_duplicate_labels"));
|
||
91 | rdBtnRemoveDuplicates.addActionListener(this);
|
||
92 | |||
93 | } |
||
94 | return rdBtnRemoveDuplicates;
|
||
95 | } |
||
96 | |||
97 | public void setMode(int dupMode) { |
||
98 | |||
99 | rdBtnRemoveDuplicates.setSelected(dupMode == IPlacementConstraints.REMOVE_DUPLICATE_LABELS); |
||
100 | rdBtnOnePerFeature.setSelected(dupMode == IPlacementConstraints.ONE_LABEL_PER_FEATURE); |
||
101 | rdBtnOnePerFeaturePart.setSelected(dupMode == IPlacementConstraints.ONE_LABEL_PER_FEATURE_PART); |
||
102 | } |
||
103 | |||
104 | public int getMode() { |
||
105 | if (rdBtnRemoveDuplicates.isSelected()) {
|
||
106 | return IPlacementConstraints.REMOVE_DUPLICATE_LABELS;
|
||
107 | } |
||
108 | if (rdBtnOnePerFeature.isSelected()) {
|
||
109 | return IPlacementConstraints.ONE_LABEL_PER_FEATURE;
|
||
110 | } |
||
111 | if (rdBtnOnePerFeaturePart.isSelected()) {
|
||
112 | return IPlacementConstraints.ONE_LABEL_PER_FEATURE_PART;
|
||
113 | } |
||
114 | |||
115 | throw new Error("Unsupported layer duplicates mode"); |
||
116 | } |
||
117 | public void actionPerformed(ActionEvent e) { |
||
118 | |||
119 | if (actListeneter != null) { |
||
120 | ActionEvent aev = new ActionEvent(this, 0, ""); |
||
121 | actListeneter.actionPerformed(aev); |
||
122 | } |
||
123 | |||
124 | } |
||
125 | } |