Revision 11297 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SymbolLayerManager.java
SymbolLayerManager.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2007-03-09 11:25:00 jaume |
|
46 |
* Revision 1.4 2007-04-20 07:54:38 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.3 2007/03/09 11:25:00 jaume |
|
47 | 50 |
* Advanced symbology (start committing) |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.4 2007/02/21 07:35:14 jaume |
... | ... | |
102 | 105 |
import javax.swing.BorderFactory; |
103 | 106 |
import javax.swing.DefaultListCellRenderer; |
104 | 107 |
import javax.swing.ImageIcon; |
108 |
import javax.swing.JCheckBox; |
|
105 | 109 |
import javax.swing.JList; |
106 | 110 |
import javax.swing.JPanel; |
107 | 111 |
import javax.swing.JScrollPane; |
... | ... | |
146 | 150 |
|
147 | 151 |
private void initialize() { |
148 | 152 |
this.setLayout(new BorderLayout()); |
149 |
this.setSize(new java.awt.Dimension(155,106)); |
|
150 | 153 |
this.add(getJScrollPane(), java.awt.BorderLayout.CENTER); |
151 | 154 |
this.add(getPnlButtons(), java.awt.BorderLayout.SOUTH); |
152 | 155 |
} |
... | ... | |
154 | 157 |
private JScrollPane getJScrollPane() { |
155 | 158 |
if (scroll == null) { |
156 | 159 |
scroll = new JScrollPane(); |
157 |
scroll.setPreferredSize(new Dimension(120, 160));
|
|
160 |
scroll.setPreferredSize(new Dimension(150, 160));
|
|
158 | 161 |
scroll.setViewportView(getJListLayers()); |
159 | 162 |
} |
160 | 163 |
return scroll; |
... | ... | |
174 | 177 |
}); |
175 | 178 |
jListLayers.setModel(new SymbolLayerListModel()); |
176 | 179 |
jListLayers.setCellRenderer(new DefaultListCellRenderer() { |
177 |
|
|
178 | 180 |
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
179 |
ISymbol sym = (ISymbol) value; |
|
180 |
|
|
181 |
JPanel pnl = new JPanel(); |
|
182 |
LayoutManager layout = new FlowLayout(FlowLayout.LEFT, 3, 3); |
|
183 |
pnl.setLayout(layout); |
|
184 |
Color bgColor = (isSelected) ? cellSelectedBGColor |
|
185 |
: Color.WHITE; |
|
186 |
pnl.setBackground(bgColor); |
|
187 |
SymbolPreviewer sp = new SymbolPreviewer(); |
|
188 |
sp.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
|
189 |
sp.setAlignmentX(Component.LEFT_ALIGNMENT); |
|
190 |
sp.setPreferredSize(new Dimension(80, 30)); |
|
191 |
sp.setSize(new Dimension(80, 30)); |
|
192 |
sp.setSymbol(sym); |
|
193 |
sp.setBackground(Color.WHITE); |
|
194 |
pnl.add(sp); |
|
195 |
XMLEntity xml = sym.getXMLEntity(); |
|
196 |
String source; |
|
197 |
if (xml.contains("locked")) |
|
198 |
source = xml.getBooleanProperty("locked") ? |
|
199 |
"images/locked.png" : |
|
200 |
"images/unlocked.png"; |
|
201 |
else |
|
202 |
source = "images/unlocked.png"; |
|
203 |
|
|
204 |
ImageIcon icon = new ImageIcon(getClass(). |
|
205 |
getClassLoader().getResource(source)); |
|
206 |
JButton btnLock = new JButton(icon); |
|
207 |
btnLock.setSize(btnDimension); |
|
208 |
btnLock.setPreferredSize(btnDimension); |
|
209 |
btnLock.setActionCommand("LOCK"); |
|
210 |
btnLock.setBackground(bgColor); |
|
211 |
btnLock.setAlignmentX(Component.CENTER_ALIGNMENT); |
|
212 |
pnl.add(btnLock); |
|
213 |
pnl.setPreferredSize(LIST_CELL_SIZE); |
|
214 |
return pnl; |
|
181 |
return new SymbolLayerComponent((ISymbol) value, index, isSelected); |
|
215 | 182 |
} |
216 |
|
|
217 | 183 |
}); |
218 |
|
|
219 | 184 |
jListLayers.addMouseListener(new MouseAdapter() { |
220 | 185 |
public void mouseClicked(MouseEvent e) { |
221 | 186 |
if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { |
... | ... | |
377 | 342 |
getJScrollPane().setViewportView(getJListLayers()); |
378 | 343 |
super.validate(); |
379 | 344 |
} |
345 |
|
|
346 |
private class SymbolLayerComponent extends JPanel { |
|
347 |
public SymbolLayerComponent(ISymbol sym, int index, boolean isSelected) { |
|
348 |
LayoutManager layout = new FlowLayout(FlowLayout.LEFT, 3, 3); |
|
349 |
setLayout(layout); |
|
350 |
Color bgColor = (isSelected) ? cellSelectedBGColor |
|
351 |
: Color.WHITE; |
|
352 |
setBackground(bgColor); |
|
353 |
JCheckBox chkVisible = new JCheckBox("", symbol.getLayer(index).isShapeVisible()); |
|
354 |
chkVisible.setBackground(bgColor); |
|
355 |
add(chkVisible); |
|
356 |
SymbolPreviewer sp = new SymbolPreviewer(); |
|
357 |
sp.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
|
358 |
sp.setAlignmentX(Component.LEFT_ALIGNMENT); |
|
359 |
sp.setPreferredSize(new Dimension(80, 30)); |
|
360 |
sp.setSize(new Dimension(80, 30)); |
|
361 |
sp.setSymbol(sym); |
|
362 |
sp.setBackground(Color.WHITE); |
|
363 |
add(sp); |
|
364 |
XMLEntity xml = sym.getXMLEntity(); |
|
365 |
String source; |
|
366 |
if (xml.contains("locked")) |
|
367 |
source = xml.getBooleanProperty("locked") ? |
|
368 |
"images/locked.png" : |
|
369 |
"images/unlocked.png"; |
|
370 |
else |
|
371 |
source = "images/unlocked.png"; |
|
372 |
|
|
373 |
ImageIcon icon = new ImageIcon(getClass(). |
|
374 |
getClassLoader().getResource(source)); |
|
375 |
JButton btnLock = new JButton(icon); |
|
376 |
btnLock.setSize(btnDimension); |
|
377 |
btnLock.setPreferredSize(btnDimension); |
|
378 |
btnLock.setActionCommand("LOCK"); |
|
379 |
btnLock.setBackground(bgColor); |
|
380 |
btnLock.setAlignmentX(Component.CENTER_ALIGNMENT); |
|
381 |
add(btnLock); |
|
382 |
setPreferredSize(LIST_CELL_SIZE); |
|
383 |
|
|
384 |
} |
|
385 |
} |
|
380 | 386 |
} |
381 | 387 |
|
382 | 388 |
|
Also available in: Unified diff