svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / ArrowDecorator.java @ 12805
History | View | Annotate | Download (6.91 KB)
1 | 12729 | jaume | /* 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 | package com.iver.cit.gvsig.gui.styling; |
||
42 | |||
43 | import java.awt.BorderLayout; |
||
44 | import java.awt.FlowLayout; |
||
45 | 12805 | jaume | import java.awt.event.ActionEvent; |
46 | import java.awt.event.ActionListener; |
||
47 | 12729 | jaume | |
48 | import javax.swing.BorderFactory; |
||
49 | import javax.swing.ButtonGroup; |
||
50 | import javax.swing.JCheckBox; |
||
51 | import javax.swing.JLabel; |
||
52 | import javax.swing.JPanel; |
||
53 | import javax.swing.JRadioButton; |
||
54 | |||
55 | 12805 | jaume | import org.gvsig.gui.beans.DefaultBean; |
56 | 12729 | jaume | import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
57 | import org.gvsig.gui.beans.swing.JButton; |
||
58 | import org.gvsig.gui.beans.swing.JIncrementalNumberField; |
||
59 | import org.gvsig.gui.beans.swing.ValidatingTextField; |
||
60 | 12805 | jaume | import org.opengis.go.display.style.ArrowStyle; |
61 | 12729 | jaume | |
62 | import com.iver.andami.PluginServices; |
||
63 | import com.iver.cit.gvsig.fmap.core.styles.ArrowDecoratorStyle; |
||
64 | 12805 | jaume | import com.iver.cit.gvsig.fmap.core.symbols.ArrowMarkerSymbol; |
65 | import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol; |
||
66 | 12729 | jaume | |
67 | /**
|
||
68 | * @autor jaume dominguez faus - jaume.dominguez@iver.es
|
||
69 | */
|
||
70 | 12805 | jaume | public class ArrowDecorator extends DefaultBean implements ActionListener { |
71 | 12729 | jaume | |
72 | private JCheckBox chkFlipAll; |
||
73 | private JCheckBox chkFlipFirst; |
||
74 | private JRadioButton rdBtnFollowLine; |
||
75 | private JRadioButton rdBtnFixedAngle; |
||
76 | private JIncrementalNumberField incrPositionCount;
|
||
77 | 12805 | jaume | private JIncrementalNumberField incrSharpeness;
|
78 | 12729 | jaume | private JCheckBox chkUseDecorator; |
79 | 12805 | jaume | private IMarkerSymbol marker;
|
80 | private JIncrementalNumberField incrSize;
|
||
81 | 12729 | jaume | |
82 | public ArrowDecorator() {
|
||
83 | super();
|
||
84 | initialize(); |
||
85 | } |
||
86 | |||
87 | private void initialize() { |
||
88 | setName(PluginServices.getText(this, "arrow_decorator")); |
||
89 | setLayout(new BorderLayout(10, 10)); |
||
90 | |||
91 | chkUseDecorator = new JCheckBox(PluginServices.getText(this, "use_decorator")); |
||
92 | 12805 | jaume | |
93 | 12729 | jaume | JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
94 | 12805 | jaume | GridBagLayoutPanel pnlTopOptions = new GridBagLayoutPanel();
|
95 | pnlTopOptions.addComponent(chkUseDecorator); |
||
96 | pnlTopOptions.addComponent(PluginServices.getText(this, "size"), |
||
97 | incrSize = new JIncrementalNumberField(
|
||
98 | "0",
|
||
99 | 5,
|
||
100 | ValidatingTextField.DOUBLE_VALIDATOR, |
||
101 | ValidatingTextField.NUMBER_CLEANER, |
||
102 | 0,
|
||
103 | Integer.MAX_VALUE,
|
||
104 | 1)
|
||
105 | ); |
||
106 | pnlTopOptions.addComponent(PluginServices.getText(this, "arrow_sharpeness"), |
||
107 | incrSharpeness = new JIncrementalNumberField(
|
||
108 | "0",
|
||
109 | 5,
|
||
110 | ValidatingTextField.DOUBLE_VALIDATOR, |
||
111 | ValidatingTextField.NUMBER_CLEANER, |
||
112 | 0,
|
||
113 | Integer.MAX_VALUE,
|
||
114 | 1)
|
||
115 | ); |
||
116 | JPanel aux2 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||
117 | aux2.add( incrPositionCount = new JIncrementalNumberField(
|
||
118 | 12729 | jaume | "0",
|
119 | 5,
|
||
120 | ValidatingTextField.INTEGER_VALIDATOR, |
||
121 | ValidatingTextField.NUMBER_CLEANER, |
||
122 | 0,
|
||
123 | Integer.MAX_VALUE,
|
||
124 | 12805 | jaume | 1)
|
125 | ); |
||
126 | 12729 | jaume | JButton btnChooseSymbol = new JButton(PluginServices.getText(this, "symbol")); |
127 | 12805 | jaume | JPanel aux3 = new JPanel(new FlowLayout(FlowLayout.LEFT,5, 0)); |
128 | aux3.add(btnChooseSymbol); |
||
129 | aux2.add(aux3); |
||
130 | pnlTopOptions.addComponent(PluginServices.getText(this, "number_of_positions")+":", aux2); |
||
131 | aux.add(pnlTopOptions); |
||
132 | add(aux, BorderLayout.NORTH);
|
||
133 | 12729 | jaume | |
134 | 12805 | jaume | aux = new JPanel(new BorderLayout(5,5)); |
135 | 12729 | jaume | aux2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
136 | GridBagLayoutPanel pnlFlip = new GridBagLayoutPanel();
|
||
137 | pnlFlip.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(this, "flip")+":")); |
||
138 | pnlFlip.addComponent(chkFlipAll = new JCheckBox(PluginServices.getText(this, "flip_all"))); |
||
139 | pnlFlip.addComponent(chkFlipFirst = new JCheckBox(PluginServices.getText(this, "flip_first"))); |
||
140 | |||
141 | 12805 | jaume | |
142 | 12729 | jaume | aux2.add(pnlFlip); |
143 | |||
144 | GridBagLayoutPanel pnlRotation = new GridBagLayoutPanel();
|
||
145 | pnlRotation.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(this, "rotation")+":")); |
||
146 | pnlRotation.addComponent(rdBtnFollowLine = new JRadioButton(PluginServices.getText(this, "rotate_symbol_to_follow_line_angle"))); |
||
147 | pnlRotation.addComponent(rdBtnFixedAngle = new JRadioButton(PluginServices.getText(this, "keep_symbol_at_fixed_angle_to_page"))); |
||
148 | ButtonGroup group = new ButtonGroup(); |
||
149 | group.add(rdBtnFixedAngle); |
||
150 | group.add(rdBtnFollowLine); |
||
151 | aux2.add(pnlRotation); |
||
152 | |||
153 | 12805 | jaume | chkUseDecorator.addActionListener(this);
|
154 | incrPositionCount.addActionListener(this);
|
||
155 | incrSharpeness.addActionListener(this);
|
||
156 | incrSize.addActionListener(this);
|
||
157 | chkFlipFirst.addActionListener(this);
|
||
158 | chkFlipAll.addActionListener(this);
|
||
159 | rdBtnFixedAngle.addActionListener(this);
|
||
160 | rdBtnFollowLine.addActionListener(this);
|
||
161 | |||
162 | 12729 | jaume | aux.add(aux2, BorderLayout.CENTER);
|
163 | add(aux, BorderLayout.CENTER);
|
||
164 | } |
||
165 | |||
166 | public void setArrowDecoratorStyle(ArrowDecoratorStyle ads) { |
||
167 | chkUseDecorator.setSelected(ads!=null);
|
||
168 | |||
169 | if (ads == null) { |
||
170 | ads = new ArrowDecoratorStyle();
|
||
171 | } |
||
172 | |||
173 | 12805 | jaume | marker = ads.getMarker(); |
174 | if (marker instanceof ArrowMarkerSymbol) { |
||
175 | ArrowMarkerSymbol arrow = (ArrowMarkerSymbol) marker; |
||
176 | incrSharpeness.setDouble(arrow.getSharpeness()); |
||
177 | } |
||
178 | incrSize.setDouble(marker.getSize()); |
||
179 | 12729 | jaume | incrPositionCount.setInteger(ads.getArrowMarkerCount()); |
180 | chkFlipAll.setSelected(ads.isFlipAll()); |
||
181 | chkFlipFirst.setSelected(ads.isFlipFirst()); |
||
182 | rdBtnFollowLine.setSelected(ads.isFollowLineAngle()); |
||
183 | |||
184 | } |
||
185 | |||
186 | public ArrowDecoratorStyle getArrowDecoratorStyle() {
|
||
187 | if (!chkUseDecorator.isSelected()) return null; |
||
188 | |||
189 | ArrowDecoratorStyle ads = new ArrowDecoratorStyle();
|
||
190 | 12805 | jaume | |
191 | if (marker instanceof ArrowMarkerSymbol) { |
||
192 | ArrowMarkerSymbol arrow = (ArrowMarkerSymbol) marker; |
||
193 | arrow.setSharpeness(incrSharpeness.getDouble()); |
||
194 | } |
||
195 | marker.setSize(incrSize.getDouble()); |
||
196 | ads.setMarker(marker); |
||
197 | 12729 | jaume | ads.setArrowMarkerCount(incrPositionCount.getInteger()); |
198 | ads.setFlipAll(chkFlipAll.isSelected()); |
||
199 | ads.setFlipFirst(chkFlipFirst.isSelected()); |
||
200 | ads.setFollowLineAngle(rdBtnFollowLine.isSelected()); |
||
201 | return ads;
|
||
202 | } |
||
203 | 12805 | jaume | |
204 | public void actionPerformed(ActionEvent e) { |
||
205 | boolean isArrow = marker instanceof ArrowMarkerSymbol; |
||
206 | incrSharpeness.setEnabled(isArrow); |
||
207 | |||
208 | callValueChanged(getArrowDecoratorStyle()); |
||
209 | } |
||
210 | 12729 | jaume | } |