root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / LineFill.java @ 13008
History | View | Annotate | Download (6.55 KB)
1 | 12820 | jaume | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 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.Dimension; |
||
44 | import java.awt.FlowLayout; |
||
45 | import java.awt.event.ActionEvent; |
||
46 | import java.awt.event.ActionListener; |
||
47 | import java.util.ArrayList; |
||
48 | |||
49 | import javax.swing.JPanel; |
||
50 | |||
51 | import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
||
52 | import org.gvsig.gui.beans.swing.JIncrementalNumberField; |
||
53 | |||
54 | import com.iver.andami.PluginServices; |
||
55 | import com.iver.cit.gvsig.fmap.core.FShape; |
||
56 | import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
||
57 | import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
||
58 | import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
||
59 | import com.iver.cit.gvsig.fmap.core.symbols.LineFillSymbol; |
||
60 | 12826 | jaume | import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
61 | 12820 | jaume | import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
62 | import com.iver.cit.gvsig.project.documents.view.legend.gui.JSymbolPreviewButton; |
||
63 | |||
64 | /**
|
||
65 | 12970 | jvidal | * <b>LineFill</b> allows the user to store and modify the properties that fills a
|
66 | * polygon with a padding composed of lines<p>
|
||
67 | * <p>
|
||
68 | * This functionality is carried out thanks to a tab (line fill)which is included
|
||
69 | * in the panel to edit the properities of a symbol (SymbolEditor)how is explained
|
||
70 | * in AbstractTypeSymbolEditor.<p>
|
||
71 | * <p>
|
||
72 | * This tab permits the user to change the line that composes the padding
|
||
73 | * (<b>btnLineSymbol</b>),the outline of the polygon (<b>btnOutlineSymbol</b>),
|
||
74 | * the color between the lines (<b>jcc</b>),the angle of the line(<b>incrAngle</b>),
|
||
75 | * the offset between paralel lines(<b>incrOffset</b>) and the separation
|
||
76 | * (<b>incrSeparation</b>).
|
||
77 | *
|
||
78 | *
|
||
79 | *@see AbstractTypeSymbolEditor
|
||
80 | *@author jaume dominguez faus - jaume.dominguez@iver.es
|
||
81 | */
|
||
82 | 12911 | jaume | public class LineFill extends AbstractTypeSymbolEditor implements ActionListener { |
83 | 12820 | jaume | private ArrayList tabs = new ArrayList(); |
84 | private ColorChooserPanel jcc;
|
||
85 | private JIncrementalNumberField incrAngle;
|
||
86 | private JIncrementalNumberField incrOffset;
|
||
87 | private JIncrementalNumberField incrSeparation;
|
||
88 | private JSymbolPreviewButton btnOutlineSymbol;
|
||
89 | private JSymbolPreviewButton btnLineSymbol;
|
||
90 | private ILineSymbol outline;
|
||
91 | private ILineSymbol line = SymbologyFactory.createDefaultLineSymbol();
|
||
92 | public LineFill(SymbolEditor owner) {
|
||
93 | super(owner);
|
||
94 | initialize(); |
||
95 | } |
||
96 | |||
97 | 12970 | jvidal | /**
|
98 | * Initializes the parameters that allows the user to fill the padding of
|
||
99 | * a polygon with a simpleline style.To do it, a tab (line fill) is created inside the
|
||
100 | * SymbolEditor panel with default values for the different attributes.
|
||
101 | */
|
||
102 | |||
103 | 12820 | jaume | private void initialize() { |
104 | 12970 | jvidal | |
105 | 12820 | jaume | GridBagLayoutPanel content = new GridBagLayoutPanel();
|
106 | content.setName(PluginServices.getText(this, "line_fill")); |
||
107 | JPanel aux;
|
||
108 | aux = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); |
||
109 | aux.add(jcc = new ColorChooserPanel());
|
||
110 | jcc.setAlpha(255);
|
||
111 | content.addComponent(PluginServices.getText(this, "color")+":", |
||
112 | aux); |
||
113 | 12970 | jvidal | |
114 | 12820 | jaume | aux = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); |
115 | aux.add(incrAngle = new JIncrementalNumberField("0", 5)); |
||
116 | content.addComponent(PluginServices.getText(this, "angle")+":", |
||
117 | aux); |
||
118 | 12970 | jvidal | |
119 | 12820 | jaume | aux = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); |
120 | aux.add(incrOffset = new JIncrementalNumberField("0", 5)); |
||
121 | content.addComponent(PluginServices.getText(this, "offset")+":", |
||
122 | aux); |
||
123 | 12970 | jvidal | |
124 | 12820 | jaume | aux = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); |
125 | aux.add(incrSeparation = new JIncrementalNumberField(
|
||
126 | "5",
|
||
127 | 5,
|
||
128 | 1,
|
||
129 | Double.POSITIVE_INFINITY,
|
||
130 | 1));
|
||
131 | incrSeparation.setDouble(5);
|
||
132 | content.addComponent(PluginServices.getText(this, "separation")+":", |
||
133 | aux); |
||
134 | 12970 | jvidal | |
135 | 12820 | jaume | aux = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); |
136 | aux.add(btnLineSymbol = new JSymbolPreviewButton(FShape.LINE));
|
||
137 | btnLineSymbol.setPreferredSize(new Dimension(100, 35)); |
||
138 | content.addComponent(PluginServices.getText(this, "line"), aux); |
||
139 | |||
140 | aux = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); |
||
141 | aux.add(btnOutlineSymbol = new JSymbolPreviewButton(FShape.LINE));
|
||
142 | btnOutlineSymbol.setPreferredSize(new Dimension(100, 35)); |
||
143 | content.addComponent(PluginServices.getText(this, "outline"), aux); |
||
144 | 12970 | jvidal | |
145 | 12820 | jaume | jcc.addActionListener(this);
|
146 | incrAngle.addActionListener(this);
|
||
147 | incrOffset.addActionListener(this);
|
||
148 | incrSeparation.addActionListener(this);
|
||
149 | btnOutlineSymbol.addActionListener(this);
|
||
150 | btnLineSymbol.addActionListener(this);
|
||
151 | 12970 | jvidal | |
152 | 12820 | jaume | tabs.add(content); |
153 | 12970 | jvidal | |
154 | 12820 | jaume | } |
155 | |||
156 | 12981 | jaume | public EditorTool[] getEditorTools() { |
157 | 12820 | jaume | return null; |
158 | } |
||
159 | |||
160 | public ISymbol getLayer() {
|
||
161 | LineFillSymbol sym = new LineFillSymbol();
|
||
162 | 12826 | jaume | sym.setAngle(incrAngle.getDouble()*FConstant.DEGREE_TO_RADIANS); |
163 | 12820 | jaume | sym.setOffset(incrOffset.getDouble()); |
164 | sym.setSeparation(incrSeparation.getDouble()); |
||
165 | sym.setFillColor(jcc.getColor()); |
||
166 | sym.setOutline(outline); |
||
167 | 12970 | jvidal | sym.setLineSymbol(line); |
168 | 12820 | jaume | return sym;
|
169 | } |
||
170 | |||
171 | public String getName() { |
||
172 | return PluginServices.getText(this, "line_fill_symbol"); |
||
173 | } |
||
174 | |||
175 | public Class getSymbolClass() { |
||
176 | return LineFillSymbol.class;
|
||
177 | } |
||
178 | |||
179 | public JPanel[] getTabs() { |
||
180 | return (JPanel[]) tabs.toArray(new JPanel[tabs.size()]); |
||
181 | } |
||
182 | 12970 | jvidal | |
183 | 12820 | jaume | public void refreshControls(ISymbol layer) { |
184 | LineFillSymbol lfs = (LineFillSymbol) layer; |
||
185 | 12826 | jaume | incrAngle.setDouble(lfs.getAngle()/FConstant.DEGREE_TO_RADIANS); |
186 | 12820 | jaume | incrOffset.setDouble(lfs.getOffset()); |
187 | incrSeparation.setDouble(lfs.getSeparation()); |
||
188 | jcc.setColor(lfs.getFillColor()); |
||
189 | outline = lfs.getOutline(); |
||
190 | line = lfs.getLineSymbol(); |
||
191 | 12826 | jaume | btnLineSymbol.setSymbol(line); |
192 | btnOutlineSymbol.setSymbol(outline); |
||
193 | 12820 | jaume | } |
194 | |||
195 | public void actionPerformed(ActionEvent e) { |
||
196 | line = (ILineSymbol) btnLineSymbol.getSymbol(); |
||
197 | outline = (ILineSymbol) btnOutlineSymbol.getSymbol(); |
||
198 | fireSymbolChangedEvent(); |
||
199 | } |
||
200 | |||
201 | 12981 | jaume | } |