root / trunk / extensions / extSymbology / src / org / gvsig / symbology / gui / styling / MarkerFillProperties.java @ 20768
History | View | Annotate | Download (6.42 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 |
package org.gvsig.symbology.gui.styling; |
42 |
|
43 |
import java.awt.FlowLayout; |
44 |
import java.awt.GridLayout; |
45 |
import java.awt.event.ActionEvent; |
46 |
import java.awt.event.ActionListener; |
47 |
import java.util.ArrayList; |
48 |
|
49 |
import javax.swing.BorderFactory; |
50 |
import javax.swing.JLabel; |
51 |
import javax.swing.JPanel; |
52 |
|
53 |
import org.gvsig.gui.beans.swing.JIncrementalNumberField; |
54 |
import org.gvsig.symbology.fmap.styles.SimpleMarkerFillPropertiesStyle; |
55 |
|
56 |
import com.iver.andami.PluginServices; |
57 |
import com.iver.cit.gvsig.fmap.core.styles.IMarkerFillPropertiesStyle; |
58 |
|
59 |
/**
|
60 |
* Implements a tab to modify attributes to fill the padding of a polygon
|
61 |
* such offset and separation (between pictures or markers).<p>
|
62 |
* <p>
|
63 |
* This tab is used several times in different places in our applicattion becuase the
|
64 |
* behaviour is the same if the user is filling the padding of a polygon using pictures
|
65 |
* or makers .For this reason, in order to avoid the repetition of code, this class has been
|
66 |
* created (instead of treat it like a simple tab). With this solution, the user
|
67 |
* only has to refer it to use it (and do not need to create a tab and fill it again
|
68 |
* and so on).
|
69 |
*
|
70 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
71 |
*/
|
72 |
public class MarkerFillProperties extends JPanel { |
73 |
private static final double DEFAULT_SEPARATION = 20; |
74 |
private static final double DEFAULT_OFFSET = 10; |
75 |
private JIncrementalNumberField txtOffsetX;
|
76 |
private JIncrementalNumberField txtOffsetY;
|
77 |
private JIncrementalNumberField txtSeparationX;
|
78 |
private JIncrementalNumberField txtSeparationY;
|
79 |
private ArrayList listeners = new ArrayList(); |
80 |
private ActionListener action = new ActionListener() { |
81 |
public void actionPerformed(ActionEvent e) { |
82 |
for (int i = 0; i < listeners.size(); i++) { |
83 |
((ActionListener) listeners.get(i)).actionPerformed(e);
|
84 |
} |
85 |
} |
86 |
}; |
87 |
/**
|
88 |
* Constructor method
|
89 |
*
|
90 |
*/
|
91 |
public MarkerFillProperties() {
|
92 |
super();
|
93 |
initialize(); |
94 |
} |
95 |
|
96 |
/**
|
97 |
* Initializes the parameters to create a tab to modify attributes to fill the
|
98 |
* padding of a polygon such offset and separation (between pictures or markers)
|
99 |
*
|
100 |
*/
|
101 |
private void initialize() { |
102 |
GridLayout layout = new GridLayout(); |
103 |
layout.setColumns(1);
|
104 |
layout.setVgap(5);
|
105 |
setName(PluginServices.getText(this, "fill_properties")); |
106 |
JPanel offsetPnl = new JPanel(); |
107 |
offsetPnl.setBorder(BorderFactory.
|
108 |
createTitledBorder(null,
|
109 |
PluginServices.getText(this, "offset"))); |
110 |
|
111 |
// add components to the offset panel here
|
112 |
{ |
113 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
114 |
aux.add(new JLabel("X:")); |
115 |
aux.add(txtOffsetX = new JIncrementalNumberField("0", 10, 0, 150,1)); |
116 |
offsetPnl.add(aux); |
117 |
|
118 |
aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
119 |
aux.add(new JLabel("Y:")); |
120 |
aux.add(txtOffsetY = new JIncrementalNumberField("0", 10, 0, 150,1)); |
121 |
offsetPnl.add(aux); |
122 |
|
123 |
|
124 |
|
125 |
} |
126 |
layout.setRows(offsetPnl.getComponentCount()); |
127 |
offsetPnl.setLayout(layout); |
128 |
|
129 |
add(offsetPnl); |
130 |
|
131 |
JPanel separationPnl = new JPanel(); |
132 |
layout = new GridLayout(); |
133 |
layout.setColumns(1);
|
134 |
layout.setVgap(5);
|
135 |
separationPnl.setBorder(BorderFactory.
|
136 |
createTitledBorder(null,
|
137 |
PluginServices.getText(this, "separation"))); |
138 |
|
139 |
// add components to the separation panel here
|
140 |
{ |
141 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
142 |
aux.add(new JLabel("X:")); |
143 |
aux.add(txtSeparationX = new JIncrementalNumberField("0", 10,0, 150,1)); |
144 |
separationPnl.add(aux); |
145 |
|
146 |
aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
147 |
aux.add(new JLabel("Y:")); |
148 |
aux.add(txtSeparationY = new JIncrementalNumberField("0", 10, 0, 150,1)); |
149 |
separationPnl.add(aux); |
150 |
} |
151 |
layout.setRows(separationPnl.getComponentCount()); |
152 |
separationPnl.setLayout(layout); |
153 |
add(separationPnl); |
154 |
layout = new GridLayout(); |
155 |
layout.setColumns(1);
|
156 |
layout.setVgap(5);
|
157 |
layout.setRows(getComponentCount()); |
158 |
txtOffsetX.setDouble(DEFAULT_OFFSET); |
159 |
txtOffsetY.setDouble(DEFAULT_OFFSET); |
160 |
txtSeparationX.setDouble(DEFAULT_SEPARATION); |
161 |
txtSeparationY.setDouble(DEFAULT_SEPARATION); |
162 |
|
163 |
txtOffsetX.addActionListener(action); |
164 |
txtOffsetY.addActionListener(action); |
165 |
txtSeparationX.addActionListener(action); |
166 |
txtSeparationY.addActionListener(action); |
167 |
|
168 |
setLayout(layout); |
169 |
} |
170 |
/**
|
171 |
* Sets the graphical component that shows the properties of the model.
|
172 |
* @param fillProps,IMarkerFillPropertiesStyle
|
173 |
*/
|
174 |
public void setModel(IMarkerFillPropertiesStyle fillProps) { |
175 |
if (fillProps != null) { |
176 |
txtOffsetX.setDouble(fillProps.getXOffset()); |
177 |
txtOffsetY.setDouble(fillProps.getYOffset()); |
178 |
txtSeparationX.setDouble(fillProps.getXSeparation()); |
179 |
txtSeparationY.setDouble(fillProps.getYSeparation()); |
180 |
} |
181 |
} |
182 |
|
183 |
/**
|
184 |
* Obtains the MarkerFillProperties
|
185 |
*
|
186 |
* @return mfProps,IMarkerFillPropertiesStyle
|
187 |
*/
|
188 |
public IMarkerFillPropertiesStyle getMarkerFillProperties() {
|
189 |
SimpleMarkerFillPropertiesStyle mfProps = new SimpleMarkerFillPropertiesStyle();
|
190 |
mfProps.setXOffset(txtOffsetX.getDouble()); |
191 |
mfProps.setYOffset(txtOffsetY.getDouble()); |
192 |
mfProps.setXSeparation(txtSeparationX.getDouble()); |
193 |
mfProps.setYSeparation(txtSeparationY.getDouble()); |
194 |
return mfProps;
|
195 |
} |
196 |
/**
|
197 |
* Permits the good operation of the JIncrementalNumberFields that are included
|
198 |
* in the panel
|
199 |
* @param l,ActionListener
|
200 |
*/
|
201 |
|
202 |
public void addActionListener(ActionListener l) { |
203 |
listeners.add(l); |
204 |
} |
205 |
} |