svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / Panels / AdjustTransparencyPanel.java @ 621
History | View | Annotate | Download (4.02 KB)
1 |
/*
|
---|---|
2 |
* Created on 18-sep-2004
|
3 |
*/
|
4 |
package com.iver.cit.gvsig.gui.Panels; |
5 |
|
6 |
import javax.swing.JButton; |
7 |
import javax.swing.JDialog; |
8 |
import javax.swing.JLabel; |
9 |
import javax.swing.JPanel; |
10 |
import javax.swing.JSlider; |
11 |
import javax.swing.JTextField; |
12 |
|
13 |
import com.iver.andami.PluginServices; |
14 |
import com.iver.andami.Utilities; |
15 |
import com.iver.andami.ui.mdiManager.View; |
16 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
17 |
import com.iver.cit.gvsig.fmap.layers.FLyrDefault; |
18 |
import com.iver.cit.gvsig.gui.GUIUtil; |
19 |
import com.iver.cit.gvsig.gui.ValidatingTextField; |
20 |
/**
|
21 |
* Panel de Ajuste de Transparencia.
|
22 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
23 |
*/
|
24 |
public class AdjustTransparencyPanel extends JPanel implements View { |
25 |
JDialog dlg = null; |
26 |
private JLabel jLabel = null; |
27 |
private JSlider jSlider = null; |
28 |
private ValidatingTextField jTxtTransparency = null; |
29 |
private JButton jOkButton = null; |
30 |
private FLyrDefault fLayer = null; |
31 |
|
32 |
private ViewInfo m_ViewInfo = null; |
33 |
|
34 |
public AdjustTransparencyPanel(FLyrDefault layer) {
|
35 |
super();
|
36 |
initialize(layer); |
37 |
} |
38 |
private void initialize(FLyrDefault layer) { |
39 |
jLabel = new JLabel(); |
40 |
setSize(255, 127); |
41 |
setMinimumSize(new java.awt.Dimension(220,80)); |
42 |
setLayout(null);
|
43 |
|
44 |
setFLayer(layer); |
45 |
jLabel.setBounds(15, 17, 195, 21); |
46 |
jLabel.setText("Nivel de transparencia:");
|
47 |
this.add(jLabel, null); |
48 |
this.add(getJSlider(), null); |
49 |
this.add(getJTxtTransparency(), null); |
50 |
this.add(getJOkButton(), null); |
51 |
jLabel.setText(PluginServices.getText(this, "Nivel_de_transparencia")+":"); |
52 |
jOkButton.setText(PluginServices.getText(this, "Aceptar")); |
53 |
} |
54 |
|
55 |
public void setFLayer(FLyrDefault f) { |
56 |
fLayer = f; |
57 |
setAlpha(255 - fLayer.getTransparency());
|
58 |
} |
59 |
public void setAlpha(int alpha) { |
60 |
getJSlider().setValue(alpha); |
61 |
} |
62 |
|
63 |
public int getAlpha() { |
64 |
return getJSlider().getValue();
|
65 |
} |
66 |
|
67 |
/**
|
68 |
* This method initializes jSlider
|
69 |
*
|
70 |
* @return javax.swing.JSlider
|
71 |
*/
|
72 |
private JSlider getJSlider() { |
73 |
if (jSlider == null) { |
74 |
jSlider = new JSlider(); |
75 |
jSlider.setBounds(20, 59, 163, 21); |
76 |
jSlider.setMaximum(255);
|
77 |
jSlider.setMajorTickSpacing(10);
|
78 |
} |
79 |
return jSlider;
|
80 |
} |
81 |
/**
|
82 |
* This method initializes jTextField
|
83 |
*
|
84 |
* @return javax.swing.JTextField
|
85 |
*/
|
86 |
private JTextField getJTxtTransparency() { |
87 |
if (jTxtTransparency == null) { |
88 |
jTxtTransparency = GUIUtil.createSyncdTextField(jSlider, 3);
|
89 |
jTxtTransparency.setBounds(192, 55, 41, 25); |
90 |
//jTxtTransparency.setText("" + getAlpha());
|
91 |
} |
92 |
return jTxtTransparency;
|
93 |
} |
94 |
/**
|
95 |
* This method initializes jButton
|
96 |
*
|
97 |
* @return javax.swing.JButton
|
98 |
*/
|
99 |
private JButton getJOkButton() { |
100 |
if (jOkButton == null) { |
101 |
jOkButton = new JButton(); |
102 |
jOkButton.setBounds(88, 98, 94, 19); |
103 |
jOkButton.setText("Aceptar");
|
104 |
jOkButton.addActionListener(new java.awt.event.ActionListener() {
|
105 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
106 |
AdjustTransparencyPanel.this.closeJDialog(); |
107 |
} |
108 |
}); |
109 |
|
110 |
} |
111 |
return jOkButton;
|
112 |
} |
113 |
/* (non-Javadoc)
|
114 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
115 |
*/
|
116 |
public ViewInfo getViewInfo() {
|
117 |
if (m_ViewInfo==null){ |
118 |
m_ViewInfo=new ViewInfo(ViewInfo.MODELESSDIALOG | ViewInfo.RESIZABLE);
|
119 |
m_ViewInfo.setTitle(PluginServices.getText(this,"Ajustar_transparencia")); |
120 |
} |
121 |
return m_ViewInfo;
|
122 |
} |
123 |
/* (non-Javadoc)
|
124 |
* @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
125 |
*/
|
126 |
public void viewActivated() { |
127 |
// TODO Auto-generated method stub
|
128 |
|
129 |
} |
130 |
public void openJDialog() { |
131 |
if (PluginServices.getMainFrame() == null) { |
132 |
dlg = new JDialog(); |
133 |
|
134 |
setPreferredSize(getSize()); |
135 |
dlg.getContentPane().add(this);
|
136 |
dlg.setModal(false);
|
137 |
dlg.pack(); |
138 |
dlg.show(); |
139 |
|
140 |
} else
|
141 |
PluginServices.getMDIManager().addView(this);
|
142 |
} |
143 |
public void closeJDialog() { |
144 |
fLayer.setTransparency(255 - getAlpha());
|
145 |
if (PluginServices.getMainFrame() == null) { |
146 |
dlg.hide(); |
147 |
dlg.dispose(); |
148 |
dlg = null;
|
149 |
} else
|
150 |
PluginServices.getMDIManager().closeView(this);
|
151 |
|
152 |
|
153 |
} |
154 |
|
155 |
} // @jve:visual-info decl-index=0 visual-constraint="10,10"
|