root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / FillProperties.java @ 12867
History | View | Annotate | Download (5.22 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 com.iver.cit.gvsig.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 |
|
55 |
import com.iver.andami.PluginServices; |
56 |
import com.iver.cit.gvsig.fmap.core.styles.IMarkerFillProperties; |
57 |
import com.iver.cit.gvsig.fmap.core.styles.MarkerFillProperties; |
58 |
|
59 |
/**
|
60 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
61 |
*/
|
62 |
public class FillProperties extends JPanel { |
63 |
private static final double DEFAULT_SEPARATION = 20; |
64 |
private static final double DEFAULT_OFFSET = 10; |
65 |
private JIncrementalNumberField txtOffsetX;
|
66 |
private JIncrementalNumberField txtOffsetY;
|
67 |
private JIncrementalNumberField txtSeparationX;
|
68 |
private JIncrementalNumberField txtSeparationY;
|
69 |
private ArrayList listeners = new ArrayList(); |
70 |
private ActionListener action = new ActionListener() { |
71 |
public void actionPerformed(ActionEvent e) { |
72 |
for (int i = 0; i < listeners.size(); i++) { |
73 |
((ActionListener) listeners.get(i)).actionPerformed(e);
|
74 |
} |
75 |
} |
76 |
}; |
77 |
|
78 |
public FillProperties() {
|
79 |
super();
|
80 |
initialize(); |
81 |
} |
82 |
|
83 |
private void initialize() { |
84 |
GridLayout layout = new GridLayout(); |
85 |
layout.setColumns(1);
|
86 |
layout.setVgap(5);
|
87 |
setName(PluginServices.getText(this, "fill_properties")); |
88 |
JPanel offsetPnl = new JPanel(); |
89 |
offsetPnl.setBorder(BorderFactory.
|
90 |
createTitledBorder(null,
|
91 |
PluginServices.getText(this, "offset"))); |
92 |
|
93 |
// add components to the offset panel here
|
94 |
{ |
95 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
96 |
aux.add(new JLabel("X:")); |
97 |
aux.add(txtOffsetX = new JIncrementalNumberField("0", 10, 0, 150,1)); |
98 |
offsetPnl.add(aux); |
99 |
|
100 |
aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
101 |
aux.add(new JLabel("Y:")); |
102 |
aux.add(txtOffsetY = new JIncrementalNumberField("0", 10, 0, 150,1)); |
103 |
offsetPnl.add(aux); |
104 |
|
105 |
|
106 |
|
107 |
} |
108 |
layout.setRows(offsetPnl.getComponentCount()); |
109 |
offsetPnl.setLayout(layout); |
110 |
|
111 |
add(offsetPnl); |
112 |
|
113 |
JPanel separationPnl = new JPanel(); |
114 |
layout = new GridLayout(); |
115 |
layout.setColumns(1);
|
116 |
layout.setVgap(5);
|
117 |
separationPnl.setBorder(BorderFactory.
|
118 |
createTitledBorder(null,
|
119 |
PluginServices.getText(this, "separation"))); |
120 |
|
121 |
// add components to the separation panel here
|
122 |
{ |
123 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
124 |
aux.add(new JLabel("X:")); |
125 |
aux.add(txtSeparationX = new JIncrementalNumberField("0", 10,0, 150,1)); |
126 |
separationPnl.add(aux); |
127 |
|
128 |
aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
129 |
aux.add(new JLabel("Y:")); |
130 |
aux.add(txtSeparationY = new JIncrementalNumberField("0", 10, 0, 150,1)); |
131 |
separationPnl.add(aux); |
132 |
} |
133 |
layout.setRows(separationPnl.getComponentCount()); |
134 |
separationPnl.setLayout(layout); |
135 |
add(separationPnl); |
136 |
layout = new GridLayout(); |
137 |
layout.setColumns(1);
|
138 |
layout.setVgap(5);
|
139 |
layout.setRows(getComponentCount()); |
140 |
txtOffsetX.setDouble(DEFAULT_OFFSET); |
141 |
txtOffsetY.setDouble(DEFAULT_OFFSET); |
142 |
txtSeparationX.setDouble(DEFAULT_SEPARATION); |
143 |
txtSeparationY.setDouble(DEFAULT_SEPARATION); |
144 |
|
145 |
txtOffsetX.addActionListener(action); |
146 |
txtOffsetY.addActionListener(action); |
147 |
txtSeparationX.addActionListener(action); |
148 |
txtSeparationY.addActionListener(action); |
149 |
|
150 |
setLayout(layout); |
151 |
} |
152 |
|
153 |
public void setModel(IMarkerFillProperties fillProps) { |
154 |
if (fillProps != null) { |
155 |
txtOffsetX.setDouble(fillProps.getXOffset()); |
156 |
txtOffsetY.setDouble(fillProps.getYOffset()); |
157 |
txtSeparationX.setDouble(fillProps.getXSeparation()); |
158 |
txtSeparationY.setDouble(fillProps.getYSeparation()); |
159 |
} |
160 |
} |
161 |
|
162 |
public IMarkerFillProperties getMarkerFillProperties() {
|
163 |
MarkerFillProperties mfProps = new MarkerFillProperties();
|
164 |
mfProps.setXOffset(txtOffsetX.getDouble()); |
165 |
mfProps.setYOffset(txtOffsetY.getDouble()); |
166 |
mfProps.setXSeparation(txtSeparationX.getDouble()); |
167 |
mfProps.setYSeparation(txtSeparationY.getDouble()); |
168 |
return mfProps;
|
169 |
} |
170 |
|
171 |
public void addActionListener(ActionListener l) { |
172 |
listeners.add(l); |
173 |
} |
174 |
} |