root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / StyleEditor.java @ 11055
History | View | Annotate | Download (5.68 KB)
1 | 11055 | 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 | |||
42 | package com.iver.cit.gvsig.gui.styling; |
||
43 | |||
44 | import java.awt.BorderLayout; |
||
45 | import java.awt.Component; |
||
46 | import java.awt.Dimension; |
||
47 | import java.awt.FlowLayout; |
||
48 | |||
49 | import javax.swing.BorderFactory; |
||
50 | import javax.swing.BoxLayout; |
||
51 | import javax.swing.ButtonGroup; |
||
52 | import javax.swing.JLabel; |
||
53 | import javax.swing.JPanel; |
||
54 | import javax.swing.JSeparator; |
||
55 | import javax.swing.JTextField; |
||
56 | import javax.swing.JToggleButton; |
||
57 | |||
58 | import org.gvsig.gui.beans.AcceptCancelPanel; |
||
59 | import org.gvsig.gui.beans.swing.JButton; |
||
60 | |||
61 | import com.iver.andami.PluginServices; |
||
62 | import com.iver.andami.ui.mdiManager.IWindow; |
||
63 | import com.iver.andami.ui.mdiManager.WindowInfo; |
||
64 | import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
||
65 | import com.iver.cit.gvsig.fmap.core.styles.ILabelStyle; |
||
66 | import com.iver.cit.gvsig.fmap.core.styles.IStyle; |
||
67 | |||
68 | /**
|
||
69 | *
|
||
70 | * @author jaume dominguez faus - jaume.dominguez@iver.es
|
||
71 | *
|
||
72 | */
|
||
73 | /**
|
||
74 | *
|
||
75 | * @author jaume dominguez faus - jaume.dominguez@iver.es
|
||
76 | *
|
||
77 | */
|
||
78 | public class StyleEditor extends JPanel implements IWindow { |
||
79 | |||
80 | private JPanel pnlNorth = null; |
||
81 | private JPanel jPanel = null; |
||
82 | private JPanel pnlCenter = null; |
||
83 | private AcceptCancelPanel pnlButtons = null; |
||
84 | private JLabel lblTitle; |
||
85 | private StylePreviewer preview;
|
||
86 | private JPanel pnlTools; |
||
87 | private JToggleButton btnPan; |
||
88 | private JToggleButton btnNewTextArea; |
||
89 | private JTextField txtDesc; |
||
90 | private JButton btnBackground; |
||
91 | |||
92 | |||
93 | public StyleEditor(IStyle style) {
|
||
94 | if (style!=null) { |
||
95 | IStyle sty = SymbologyFactory.createStyleFromXML(style.getXMLEntity(), style.getDescription()); |
||
96 | getStylePreviewer().setStyle(sty); |
||
97 | String desc = sty.getDescription();
|
||
98 | getTxtDesc().setText(desc); |
||
99 | } else {
|
||
100 | getTxtDesc().setText(PluginServices.getText(this, "new_style")); |
||
101 | } |
||
102 | initialize(); |
||
103 | } |
||
104 | |||
105 | /**
|
||
106 | * This method initializes this
|
||
107 | *
|
||
108 | */
|
||
109 | private void initialize() { |
||
110 | this.setLayout(new BorderLayout()); |
||
111 | this.setSize(417,284); |
||
112 | this.add(getPnlNorth(), java.awt.BorderLayout.NORTH);
|
||
113 | this.add(getPnlCenter(), java.awt.BorderLayout.CENTER);
|
||
114 | this.add(getPnlButtons(), java.awt.BorderLayout.SOUTH);
|
||
115 | } |
||
116 | |||
117 | |||
118 | |||
119 | /**
|
||
120 | * This method initializes pnlNorth
|
||
121 | *
|
||
122 | * @return javax.swing.JPanel
|
||
123 | */
|
||
124 | private JPanel getPnlNorth() { |
||
125 | if (pnlNorth == null) { |
||
126 | pnlNorth = new JPanel(new FlowLayout(FlowLayout.LEADING)); |
||
127 | lblTitle = new JLabel(PluginServices.getText(this, "editing")); |
||
128 | pnlNorth.add(lblTitle); |
||
129 | pnlNorth.add(getTxtDesc()); |
||
130 | } |
||
131 | return pnlNorth;
|
||
132 | } |
||
133 | |||
134 | private JTextField getTxtDesc() { |
||
135 | if (txtDesc == null) { |
||
136 | txtDesc = new JTextField(30); |
||
137 | |||
138 | } |
||
139 | |||
140 | return txtDesc;
|
||
141 | } |
||
142 | |||
143 | /**
|
||
144 | * This method initializes jPanel1
|
||
145 | *
|
||
146 | * @return javax.swing.JPanel
|
||
147 | */
|
||
148 | private JPanel getPnlCenter() { |
||
149 | if (pnlCenter == null) { |
||
150 | pnlCenter = new JPanel(new BorderLayout()); |
||
151 | JPanel aux = new JPanel(); |
||
152 | aux.add(getStylePreviewer()); |
||
153 | pnlCenter.add(getStylePreviewer(), BorderLayout.CENTER);
|
||
154 | pnlCenter.add(getPnlTools(), BorderLayout.EAST);
|
||
155 | } |
||
156 | return pnlCenter;
|
||
157 | } |
||
158 | |||
159 | private JPanel getPnlTools() { |
||
160 | if (pnlTools == null) { |
||
161 | pnlTools = new JPanel(); |
||
162 | pnlTools.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(this, "tools"))); |
||
163 | pnlTools.setLayout(new BoxLayout(pnlTools, BoxLayout.Y_AXIS)); |
||
164 | pnlTools.add(getBtnPan()); |
||
165 | pnlTools.add(getBtnNewTextArea()); |
||
166 | pnlTools.add(new JSeparator(JSeparator.HORIZONTAL)); |
||
167 | pnlTools.add(getBtnBackground()); |
||
168 | |||
169 | ButtonGroup group = new ButtonGroup(); |
||
170 | group.add(getBtnPan()); |
||
171 | group.add(getBtnNewTextArea()); |
||
172 | } |
||
173 | |||
174 | return pnlTools;
|
||
175 | } |
||
176 | |||
177 | private Component getBtnBackground() { |
||
178 | if (btnBackground == null) { |
||
179 | btnBackground = new JButton("background"); |
||
180 | |||
181 | } |
||
182 | |||
183 | return btnBackground;
|
||
184 | } |
||
185 | |||
186 | private JToggleButton getBtnNewTextArea() { |
||
187 | if (btnNewTextArea == null) { |
||
188 | btnNewTextArea = new JToggleButton("new_text"); |
||
189 | } |
||
190 | return btnNewTextArea;
|
||
191 | } |
||
192 | |||
193 | private JToggleButton getBtnPan() { |
||
194 | if (btnPan == null) { |
||
195 | btnPan = new JToggleButton("pan"); |
||
196 | |||
197 | } |
||
198 | |||
199 | return btnPan;
|
||
200 | } |
||
201 | |||
202 | private StylePreviewer getStylePreviewer() {
|
||
203 | if (preview == null) { |
||
204 | preview = new StylePreviewer();
|
||
205 | preview.setShowOutline(true);
|
||
206 | } |
||
207 | |||
208 | return preview;
|
||
209 | } |
||
210 | |||
211 | /**
|
||
212 | * This method initializes pnlButtons
|
||
213 | *
|
||
214 | * @return javax.swing.JPanel
|
||
215 | */
|
||
216 | private JPanel getPnlButtons() { |
||
217 | if (pnlButtons == null) { |
||
218 | pnlButtons = new AcceptCancelPanel();
|
||
219 | } |
||
220 | return pnlButtons;
|
||
221 | } |
||
222 | |||
223 | public WindowInfo getWindowInfo() {
|
||
224 | WindowInfo wi = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
|
||
225 | wi.setTitle(PluginServices.getText(this, "edit_style")); |
||
226 | wi.setWidth(getWidth()+10);
|
||
227 | wi.setHeight(getHeight()); |
||
228 | return wi;
|
||
229 | } |
||
230 | } // @jve:decl-index=0:visual-constraint="10,10" |