root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / gui / PlacementProperties.java @ 11170
History | View | Annotate | Download (19.2 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
|
42 |
/* CVS MESSAGES:
|
43 |
*
|
44 |
* $Id: PlacementProperties.java 11170 2007-04-12 16:01:32Z jaume $
|
45 |
* $Log$
|
46 |
* Revision 1.4 2007-04-12 16:01:32 jaume
|
47 |
* *** empty log message ***
|
48 |
*
|
49 |
* Revision 1.3 2007/03/28 15:38:56 jaume
|
50 |
* GUI for lines, points and polygons
|
51 |
*
|
52 |
* Revision 1.2 2007/03/09 11:25:00 jaume
|
53 |
* Advanced symbology (start committing)
|
54 |
*
|
55 |
* Revision 1.1.2.2 2007/02/09 11:00:03 jaume
|
56 |
* *** empty log message ***
|
57 |
*
|
58 |
* Revision 1.1.2.1 2007/02/01 12:12:41 jaume
|
59 |
* theme manager window and all its components are now dynamic
|
60 |
*
|
61 |
*
|
62 |
*/
|
63 |
package com.iver.cit.gvsig.project.documents.view.legend.gui; |
64 |
|
65 |
import java.awt.BorderLayout; |
66 |
import java.awt.Component; |
67 |
import java.awt.Dimension; |
68 |
import java.awt.FlowLayout; |
69 |
import java.awt.GridLayout; |
70 |
import java.awt.event.ActionEvent; |
71 |
import java.awt.event.ActionListener; |
72 |
|
73 |
import javax.swing.BorderFactory; |
74 |
import javax.swing.BoxLayout; |
75 |
import javax.swing.ButtonGroup; |
76 |
import javax.swing.ImageIcon; |
77 |
import javax.swing.JCheckBox; |
78 |
import javax.swing.JComponent; |
79 |
import javax.swing.JLabel; |
80 |
import javax.swing.JPanel; |
81 |
import javax.swing.JRadioButton; |
82 |
|
83 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
84 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
85 |
import org.gvsig.gui.beans.swing.JBlank; |
86 |
import org.gvsig.gui.beans.swing.JButton; |
87 |
|
88 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
89 |
import com.iver.andami.PluginServices; |
90 |
import com.iver.andami.ui.mdiManager.IWindow; |
91 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
92 |
import com.iver.cit.gvsig.fmap.core.FShape; |
93 |
import com.iver.cit.gvsig.fmap.core.styles.IStyle; |
94 |
import com.iver.cit.gvsig.fmap.core.styles.PointLabelPositioneer; |
95 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
96 |
import com.iver.cit.gvsig.fmap.rendering.styling.IPlacementConstraints; |
97 |
import com.iver.cit.gvsig.fmap.rendering.styling.LabelingFactory; |
98 |
import com.iver.cit.gvsig.gui.styling.StyleSelector; |
99 |
import com.iver.cit.gvsig.gui.styling.SelectorFilter; |
100 |
import com.iver.cit.gvsig.gui.styling.StylePreviewer; |
101 |
import com.iver.utiles.swing.JComboBox; |
102 |
import com.vividsolutions.jts.geom.Point; |
103 |
/**
|
104 |
*
|
105 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
106 |
*
|
107 |
*/
|
108 |
public class PlacementProperties extends JPanel implements IWindow, ActionListener { |
109 |
private PointLabelPositioneer pointStyle = new PointLabelPositioneer( |
110 |
new byte[] { 2, 2, 1, 3, 2, 3, 3, 2 }, |
111 |
PluginServices.getText(this, "prefer_top_right_all_allowed") |
112 |
); |
113 |
private int shapeType; |
114 |
private JPanel pnlContent = null; |
115 |
private JPanel pnlCenter = null; |
116 |
private GridBagLayoutPanel pnlSouth = null; |
117 |
private JRadioButton rdBtnRemoveDuplicates; |
118 |
private IPlacementConstraints constraints;
|
119 |
private JRadioButton rdBtnOnePerFeature; |
120 |
private JRadioButton rdBtnOnePerFeaturePart; |
121 |
private GridBagLayoutPanel orientationPanel;
|
122 |
private JRadioButton rdBtnHorizontal; |
123 |
private JRadioButton rdBtnParallel; |
124 |
private JRadioButton rdBtnFollowingLine; |
125 |
private JRadioButton rdBtnPerpendicular; |
126 |
private GridBagLayoutPanel positionPanel;
|
127 |
private JLabel polygonIcon; |
128 |
private JLabel lineIcon; |
129 |
private ActionListener action = new ActionListener() { |
130 |
public void actionPerformed(ActionEvent e) { |
131 |
if ("OK".equals(e.getActionCommand())) |
132 |
applyConstraints(); |
133 |
PluginServices.getMDIManager().closeWindow(PlacementProperties.this); |
134 |
} |
135 |
}; |
136 |
private GridBagLayoutPanel polygonSettingsPanel;
|
137 |
private JRadioButton rdBtnAlwaysHorizontal; |
138 |
private JRadioButton rdBtnAlwaysStraight; |
139 |
private GridBagLayoutPanel pointSettingsPanel;
|
140 |
private JRadioButton rdBtnOffsetLabelHorizontally; |
141 |
private JRadioButton rdBtnOffsetLabelOnTopPoint; |
142 |
private StylePreviewer stylePreview;
|
143 |
private JButton btnChangeLocation; |
144 |
private JPanel locationPanel; |
145 |
private JComboBox cmbLocationAlongLines; |
146 |
private JCheckBox chkBelow; |
147 |
private JCheckBox chkOnTheLine; |
148 |
private JCheckBox chkAbove; |
149 |
private JComboBox cmbOrientationSystem; |
150 |
private JLabel lblPointPosDesc = new JLabel(pointStyle.getDescription()); |
151 |
public PlacementProperties(FLyrVect layer, IPlacementConstraints constraints) throws ReadDriverException { |
152 |
this.shapeType = layer.getShapeType();
|
153 |
this.constraints = constraints != null ? |
154 |
constraints : |
155 |
LabelingFactory.createPlacementConstraints(layer); |
156 |
initialize(); |
157 |
} |
158 |
|
159 |
private void initialize() { |
160 |
this.setLayout(new BorderLayout()); |
161 |
this.setSize(new Dimension(410,380)); |
162 |
this.add(getPnlContent(), BorderLayout.CENTER); |
163 |
this.add(new AcceptCancelPanel(action, action), BorderLayout.SOUTH); |
164 |
} |
165 |
|
166 |
public WindowInfo getWindowInfo() {
|
167 |
WindowInfo viewInfo = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
|
168 |
viewInfo.setWidth(getWidth()); |
169 |
viewInfo.setHeight(getHeight()); |
170 |
viewInfo.setTitle(PluginServices.getText(this,"placement_properties")); |
171 |
return viewInfo;
|
172 |
} |
173 |
|
174 |
private JPanel getPnlContent() { |
175 |
if (pnlContent == null) { |
176 |
pnlContent = new JPanel(); |
177 |
pnlContent.setLayout(new BorderLayout()); |
178 |
pnlContent.add(getPnlCenter(), java.awt.BorderLayout.CENTER); |
179 |
pnlContent.add(getPnlSouth(), java.awt.BorderLayout.SOUTH); |
180 |
} |
181 |
return pnlContent;
|
182 |
} |
183 |
|
184 |
private JPanel getPnlCenter() { |
185 |
if (pnlCenter == null) { |
186 |
pnlCenter = new JPanel(); |
187 |
switch (shapeType) {
|
188 |
case FShape.POINT:
|
189 |
pnlCenter.setBorder(BorderFactory.
|
190 |
createTitledBorder(null,
|
191 |
PluginServices.getText(this, "point_settings"))); |
192 |
pnlCenter.add(getPointSettingsPanel()); |
193 |
break;
|
194 |
case FShape.LINE:
|
195 |
pnlCenter.setLayout(new BorderLayout()); |
196 |
pnlCenter.setBorder(BorderFactory.
|
197 |
createTitledBorder(null,
|
198 |
PluginServices.getText(this, "line_settings"))); |
199 |
JPanel aux = new JPanel( |
200 |
new GridLayout(1, 2)); |
201 |
aux.add(getOrientationPanel()); |
202 |
aux.add(getPositionPanel()); |
203 |
pnlCenter.add(aux, BorderLayout.CENTER);
|
204 |
pnlCenter.add(getLocationPanel(), BorderLayout.SOUTH);
|
205 |
|
206 |
break;
|
207 |
|
208 |
case FShape.POLYGON:
|
209 |
pnlCenter.setBorder(BorderFactory.
|
210 |
createTitledBorder(null,
|
211 |
PluginServices.getText(this, "polygon_settings"))); |
212 |
pnlCenter.add(getPolygonSettingsPanel()); |
213 |
break;
|
214 |
|
215 |
default:
|
216 |
break;
|
217 |
} |
218 |
} |
219 |
return pnlCenter;
|
220 |
} |
221 |
|
222 |
private JPanel getLocationPanel() { |
223 |
if (locationPanel == null) { |
224 |
locationPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); |
225 |
locationPanel.setBorder(BorderFactory.
|
226 |
createTitledBorder(null,
|
227 |
PluginServices.getText(this, "location"))); |
228 |
locationPanel.add(new JLabel(PluginServices.getText(this, "location_along_the_lines")+":")); |
229 |
locationPanel.add(getCmbLocationAlongLines()); |
230 |
} |
231 |
|
232 |
return locationPanel;
|
233 |
} |
234 |
|
235 |
private JComboBox getCmbLocationAlongLines() { |
236 |
if (cmbLocationAlongLines == null) { |
237 |
cmbLocationAlongLines = new JComboBox(new String[] { |
238 |
PluginServices.getText(this, "at_best"), |
239 |
PluginServices.getText(this, "at_begin"), |
240 |
PluginServices.getText(this, "at_end"), |
241 |
}); |
242 |
} |
243 |
|
244 |
return cmbLocationAlongLines;
|
245 |
} |
246 |
|
247 |
private GridBagLayoutPanel getPointSettingsPanel() {
|
248 |
if (pointSettingsPanel == null) { |
249 |
pointSettingsPanel = new GridBagLayoutPanel();
|
250 |
pointSettingsPanel.addComponent(getRdOffsetLabelHorizontally()); |
251 |
JPanel aux = new JPanel(); |
252 |
aux.add(getStylePreviewer()); |
253 |
|
254 |
JPanel aux2 = new JPanel(); |
255 |
aux2.setLayout(new BoxLayout(aux2, BoxLayout.Y_AXIS)); |
256 |
aux2.add(lblPointPosDesc); |
257 |
aux2.add(new JBlank(20, 20)); |
258 |
aux2.add(getBtnChangeLocation()); |
259 |
|
260 |
aux.add(aux2); |
261 |
pointSettingsPanel.addComponent("", aux);
|
262 |
pointSettingsPanel.addComponent("",
|
263 |
new JLabel(PluginServices.getText(this, "label-point-priority-help"))); |
264 |
pointSettingsPanel.addComponent(getRdOffsetLabelOnTopPoint()); |
265 |
ButtonGroup group = new ButtonGroup(); |
266 |
group.add(getRdOffsetLabelHorizontally()); |
267 |
group.add(getRdOffsetLabelOnTopPoint()); |
268 |
} |
269 |
|
270 |
return pointSettingsPanel;
|
271 |
} |
272 |
|
273 |
|
274 |
|
275 |
private JButton getBtnChangeLocation() { |
276 |
if (btnChangeLocation == null) { |
277 |
btnChangeLocation = new JButton(PluginServices.getText(this, "change_location")); |
278 |
btnChangeLocation.addActionListener(this);
|
279 |
} |
280 |
|
281 |
return btnChangeLocation;
|
282 |
} |
283 |
|
284 |
private StylePreviewer getStylePreviewer() {
|
285 |
if (stylePreview == null) { |
286 |
stylePreview = new StylePreviewer();
|
287 |
stylePreview.setStyle(pointStyle); |
288 |
stylePreview.setPreferredSize(new Dimension(80, 80)); |
289 |
} |
290 |
return stylePreview;
|
291 |
} |
292 |
|
293 |
private JRadioButton getRdOffsetLabelOnTopPoint() { |
294 |
if (rdBtnOffsetLabelOnTopPoint == null) { |
295 |
rdBtnOffsetLabelOnTopPoint = new JRadioButton( |
296 |
PluginServices.getText(this, "offset_labels_on_top_of_the_points")); |
297 |
|
298 |
} |
299 |
|
300 |
return rdBtnOffsetLabelOnTopPoint;
|
301 |
} |
302 |
|
303 |
private JRadioButton getRdOffsetLabelHorizontally() { |
304 |
if (rdBtnOffsetLabelHorizontally == null) { |
305 |
rdBtnOffsetLabelHorizontally = new JRadioButton( |
306 |
PluginServices.getText(this, "offset_labels_horizontally")); |
307 |
|
308 |
} |
309 |
|
310 |
return rdBtnOffsetLabelHorizontally;
|
311 |
} |
312 |
|
313 |
private GridBagLayoutPanel getPolygonSettingsPanel() {
|
314 |
if (polygonSettingsPanel == null) { |
315 |
polygonSettingsPanel = new GridBagLayoutPanel();
|
316 |
JPanel aux = new JPanel(); |
317 |
aux.setLayout(new BoxLayout(aux, BoxLayout.Y_AXIS)); |
318 |
aux.add(new JBlank(10,10)); |
319 |
aux.add(getRdBtnAlwaysHorizontal()); |
320 |
aux.add(new JBlank(10,10)); |
321 |
aux.add(getRdBtnAlwaysStraight()); |
322 |
polygonSettingsPanel.addComponent(getPolygonIcon(), aux); |
323 |
ButtonGroup group = new ButtonGroup(); |
324 |
group.add(getRdBtnAlwaysHorizontal()); |
325 |
group.add(getRdBtnAlwaysStraight()); |
326 |
getRdBtnAlwaysHorizontal().setSelected(true);
|
327 |
} |
328 |
|
329 |
return polygonSettingsPanel;
|
330 |
} |
331 |
|
332 |
private JRadioButton getRdBtnAlwaysStraight() { |
333 |
if (rdBtnAlwaysStraight == null) { |
334 |
rdBtnAlwaysStraight = new JRadioButton( |
335 |
PluginServices.getText(this, "always_straight")); |
336 |
rdBtnAlwaysStraight.addActionListener(this);
|
337 |
} |
338 |
|
339 |
return rdBtnAlwaysStraight;
|
340 |
} |
341 |
|
342 |
private JRadioButton getRdBtnAlwaysHorizontal() { |
343 |
if (rdBtnAlwaysHorizontal == null) { |
344 |
rdBtnAlwaysHorizontal = new JRadioButton( |
345 |
PluginServices.getText(this, "always_horizontal")); |
346 |
rdBtnAlwaysHorizontal.addActionListener(this);
|
347 |
} |
348 |
|
349 |
return rdBtnAlwaysHorizontal;
|
350 |
} |
351 |
|
352 |
private JLabel getPolygonIcon() { |
353 |
if (polygonIcon == null) { |
354 |
polygonIcon = new JLabel(new ImageIcon( |
355 |
getClass().getClassLoader(). |
356 |
getResource("images/label-polygon-always-horizontal.png")));
|
357 |
} |
358 |
return polygonIcon;
|
359 |
} |
360 |
|
361 |
private JLabel getLineIcon() { |
362 |
if (lineIcon == null) { |
363 |
lineIcon = new JLabel(new ImageIcon( |
364 |
getClass().getClassLoader(). |
365 |
getResource("images/label-line.png")));
|
366 |
} |
367 |
return lineIcon;
|
368 |
} |
369 |
|
370 |
private GridBagLayoutPanel getPositionPanel() {
|
371 |
if (positionPanel == null) { |
372 |
positionPanel = new GridBagLayoutPanel();
|
373 |
positionPanel.setBorder(BorderFactory.
|
374 |
createTitledBorder(null,
|
375 |
PluginServices.getText(this, "position"))); |
376 |
JPanel aux = new JPanel(new GridLayout(3, 1)); |
377 |
aux.add(getChkAbove()); |
378 |
aux.add(getChkOnTheLine()); |
379 |
aux.add(getChkBelow()); |
380 |
positionPanel.addComponent(aux, getLineIcon()); |
381 |
positionPanel.addComponent( |
382 |
PluginServices.getText(this, "orientation_system"), getCmbOrientationSystem()); |
383 |
|
384 |
} |
385 |
return positionPanel;
|
386 |
} |
387 |
|
388 |
private JComboBox getCmbOrientationSystem() { |
389 |
if (cmbOrientationSystem == null) { |
390 |
cmbOrientationSystem = new JComboBox(new String[] { |
391 |
PluginServices.getText(this, "line"), |
392 |
PluginServices.getText(this, "page") |
393 |
}); |
394 |
cmbOrientationSystem.setSelectedIndex(0);
|
395 |
} |
396 |
|
397 |
return cmbOrientationSystem;
|
398 |
} |
399 |
|
400 |
private JCheckBox getChkBelow() { |
401 |
if (chkBelow == null) { |
402 |
chkBelow = new JCheckBox(PluginServices.getText(this, "below")); |
403 |
} |
404 |
return chkBelow;
|
405 |
} |
406 |
|
407 |
private JCheckBox getChkOnTheLine() { |
408 |
if (chkOnTheLine == null) { |
409 |
chkOnTheLine = new JCheckBox(PluginServices.getText(this, "on_the_line")); |
410 |
} |
411 |
return chkOnTheLine;
|
412 |
} |
413 |
|
414 |
private JCheckBox getChkAbove() { |
415 |
if (chkAbove == null) { |
416 |
chkAbove = new JCheckBox(PluginServices.getText(this, "above")); |
417 |
chkAbove.setSelected(true);
|
418 |
} |
419 |
return chkAbove;
|
420 |
} |
421 |
|
422 |
private GridBagLayoutPanel getOrientationPanel() {
|
423 |
if (orientationPanel == null) { |
424 |
orientationPanel = new GridBagLayoutPanel();
|
425 |
orientationPanel.setBorder(BorderFactory.
|
426 |
createTitledBorder(null,
|
427 |
PluginServices.getText(this, "orientation"))); |
428 |
orientationPanel.addComponent(getRdBtnHorizontal()); |
429 |
orientationPanel.addComponent(getRdBtnParallel()); |
430 |
orientationPanel.addComponent(getRdBtnFollowingLine()); |
431 |
orientationPanel.addComponent(getRdBtnPerpendicular()); |
432 |
ButtonGroup group = new ButtonGroup(); |
433 |
group.add(getRdBtnHorizontal()); |
434 |
group.add(getRdBtnParallel()); |
435 |
group.add(getRdBtnFollowingLine()); |
436 |
group.add(getRdBtnPerpendicular()); |
437 |
getRdBtnParallel().setSelected(true);
|
438 |
|
439 |
} |
440 |
return orientationPanel;
|
441 |
} |
442 |
|
443 |
private JRadioButton getRdBtnParallel() { |
444 |
if (rdBtnParallel == null) { |
445 |
rdBtnParallel = new JRadioButton( |
446 |
PluginServices.getText(this, "parallel"), |
447 |
constraints.isParallel()); |
448 |
|
449 |
rdBtnParallel.addActionListener(this);
|
450 |
} |
451 |
return rdBtnParallel;
|
452 |
} |
453 |
|
454 |
private JRadioButton getRdBtnFollowingLine() { |
455 |
if (rdBtnFollowingLine == null) { |
456 |
rdBtnFollowingLine = new JRadioButton( |
457 |
PluginServices.getText(this, "following_line"), |
458 |
constraints.isFollowingLine()); |
459 |
rdBtnFollowingLine.addActionListener(this);
|
460 |
} |
461 |
return rdBtnFollowingLine;
|
462 |
} |
463 |
|
464 |
private JRadioButton getRdBtnPerpendicular() { |
465 |
if (rdBtnPerpendicular == null) { |
466 |
rdBtnPerpendicular = new JRadioButton( |
467 |
PluginServices.getText(this, "perpedicular"), |
468 |
constraints.isPerpendicular()); |
469 |
rdBtnPerpendicular.addActionListener(this);
|
470 |
} |
471 |
return rdBtnPerpendicular;
|
472 |
} |
473 |
|
474 |
private JRadioButton getRdBtnHorizontal() { |
475 |
if (rdBtnHorizontal == null) { |
476 |
rdBtnHorizontal = new JRadioButton( |
477 |
PluginServices.getText(this, "horizontal"), |
478 |
constraints.isHorizontal()); |
479 |
rdBtnHorizontal.addActionListener(this);
|
480 |
} |
481 |
return rdBtnHorizontal;
|
482 |
} |
483 |
|
484 |
private JPanel getPnlSouth() { |
485 |
if (pnlSouth == null) { |
486 |
pnlSouth = new GridBagLayoutPanel();
|
487 |
pnlSouth.setBorder(BorderFactory.
|
488 |
createTitledBorder(null,
|
489 |
PluginServices.getText(this, "duplicate_labels"))); |
490 |
pnlSouth.addComponent(getRdBtnRemoveDuplicates()); |
491 |
pnlSouth.addComponent(getRdBtnOnePerFeature()); |
492 |
pnlSouth.addComponent(getRdBtnOnePerFeaturePart()); |
493 |
|
494 |
ButtonGroup group = new ButtonGroup(); |
495 |
group.add(getRdBtnOnePerFeature()); |
496 |
group.add(getRdBtnOnePerFeaturePart()); |
497 |
group.add(getRdBtnRemoveDuplicates()); |
498 |
} |
499 |
return pnlSouth;
|
500 |
} |
501 |
|
502 |
private JRadioButton getRdBtnOnePerFeaturePart() { |
503 |
if (rdBtnOnePerFeaturePart == null) { |
504 |
rdBtnOnePerFeaturePart = new JRadioButton( |
505 |
PluginServices.getText(this, "place_one_label_per_feature_part"), |
506 |
constraints.getDuplicateLabelsMode() == IPlacementConstraints.ONE_LABEL_PER_FEATURE_PART); |
507 |
} |
508 |
return rdBtnOnePerFeaturePart;
|
509 |
} |
510 |
|
511 |
private JRadioButton getRdBtnOnePerFeature() { |
512 |
if (rdBtnOnePerFeature == null) { |
513 |
rdBtnOnePerFeature = new JRadioButton( |
514 |
PluginServices.getText(this, "place_one_label_per_feature"), |
515 |
constraints.getDuplicateLabelsMode() == IPlacementConstraints.ONE_LABEL_PER_FEATURE); |
516 |
} |
517 |
return rdBtnOnePerFeature;
|
518 |
} |
519 |
|
520 |
private JRadioButton getRdBtnRemoveDuplicates() { |
521 |
if (rdBtnRemoveDuplicates == null) { |
522 |
rdBtnRemoveDuplicates = new JRadioButton( |
523 |
PluginServices.getText(this, "remove_duplicate_labels"), |
524 |
constraints.getDuplicateLabelsMode() == IPlacementConstraints.REMOVE_DUPLICATE_LABELS); |
525 |
|
526 |
} |
527 |
return rdBtnRemoveDuplicates;
|
528 |
} |
529 |
|
530 |
private void applyConstraints() { |
531 |
switch (shapeType) {
|
532 |
case FShape.POINT:
|
533 |
break;
|
534 |
case FShape.LINE:
|
535 |
int mode;
|
536 |
if (getRdBtnFollowingLine().isSelected()) {
|
537 |
mode = IPlacementConstraints.FOLLOWING_LINE; |
538 |
} else if (getRdBtnParallel().isSelected()) { |
539 |
mode = IPlacementConstraints.PARALLEL; |
540 |
} else if (getRdBtnPerpendicular().isSelected()) { |
541 |
mode = IPlacementConstraints.PERPENDICULAR; |
542 |
} else {
|
543 |
mode = IPlacementConstraints.HORIZONTAL; |
544 |
} |
545 |
|
546 |
constraints.setPlacementMode(mode); |
547 |
constraints.setAboveTheLine(getChkAbove().isSelected()); |
548 |
constraints.setBellowTheLine(getChkBelow().isSelected()); |
549 |
// ON THE LINE??
|
550 |
|
551 |
constraints.setPageOriented(getCmbOrientationSystem().getSelectedIndex() ==1);
|
552 |
constraints.setLocationAlongTheLine() |
553 |
break;
|
554 |
case FShape.POLYGON:
|
555 |
break;
|
556 |
} |
557 |
} |
558 |
|
559 |
private void setComponentEnabled(Component c, boolean b) { |
560 |
if (c instanceof JComponent) { |
561 |
JComponent c1 = (JComponent) c; |
562 |
for (int i = 0; i < c1.getComponentCount(); i++) { |
563 |
setComponentEnabled(c1.getComponent(i), b); |
564 |
} |
565 |
} |
566 |
c.setEnabled(b); |
567 |
} |
568 |
|
569 |
|
570 |
public IPlacementConstraints getPlacementConstraints() {
|
571 |
return constraints;
|
572 |
} |
573 |
|
574 |
public void actionPerformed(ActionEvent e) { |
575 |
JComponent c = (JComponent) e.getSource(); |
576 |
if (c.equals(rdBtnAlwaysHorizontal) || c.equals(rdBtnAlwaysStraight) ) {
|
577 |
boolean horizontal = rdBtnAlwaysHorizontal.isSelected();
|
578 |
if (horizontal) {
|
579 |
getPolygonIcon().setIcon(new ImageIcon( |
580 |
getClass().getClassLoader(). |
581 |
getResource("images/label-polygon-always-horizontal.png")));
|
582 |
} else {
|
583 |
getPolygonIcon().setIcon(new ImageIcon( |
584 |
getClass().getClassLoader(). |
585 |
getResource("images/label-polygon-always-straight.png")));
|
586 |
} |
587 |
} else if (c.equals(rdBtnHorizontal)) { |
588 |
// lock position panel and location panel
|
589 |
setComponentEnabled(getPositionPanel(), false);
|
590 |
setComponentEnabled(getLocationPanel(), false);
|
591 |
} else if (c.equals(rdBtnParallel) || c.equals(rdBtnPerpendicular)) { |
592 |
// unlock position panel and location panel but keep orientation system locked
|
593 |
setComponentEnabled(getLocationPanel(), true);
|
594 |
setComponentEnabled(getPositionPanel(), true);
|
595 |
getCmbOrientationSystem().setEnabled(true);
|
596 |
} else if (c.equals(rdBtnFollowingLine)) { |
597 |
// lock location panel, unlock position panel, but keep orientation system locked
|
598 |
setComponentEnabled(getLocationPanel(), false);
|
599 |
setComponentEnabled(getPositionPanel(), true);
|
600 |
getCmbOrientationSystem().setEnabled(true);
|
601 |
// } else if (c.equals(rdBtnPerpendicular)) {
|
602 |
// // unlock location panel and position panel but keep orientation system locked
|
603 |
// setComponentEnabled(getLocationPanel(), true);
|
604 |
// setComponentEnabled(getPositionPanel(), true);
|
605 |
// getCmbOrientationSystem().setEnabled(true);
|
606 |
} else if (c.equals(btnChangeLocation)) { |
607 |
StyleSelector stySel = new StyleSelector(
|
608 |
pointStyle, |
609 |
FShape.POINT, new SelectorFilter() {
|
610 |
public boolean accepts(Object obj) { |
611 |
return obj instanceof PointLabelPositioneer; |
612 |
} |
613 |
}); |
614 |
PluginServices.getMDIManager().addWindow(stySel); |
615 |
IStyle sty = (IStyle) stySel.getSelectedObject(); |
616 |
if (sty != null) { |
617 |
stylePreview.setStyle(sty); |
618 |
lblPointPosDesc.setText(sty.getDescription()); |
619 |
} |
620 |
} |
621 |
} |
622 |
|
623 |
} // @jve:decl-index=0:visual-constraint="10,10"
|