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