|
24 | 24 | import java.awt.Graphics; |
25 | 25 | import java.awt.Graphics2D; |
26 | 26 | import java.awt.Paint; |
27 | | -import java.awt.Window; |
28 | | -import java.awt.event.ActionEvent; |
29 | | -import java.awt.event.ActionListener; |
30 | 27 | import java.awt.event.WindowAdapter; |
31 | 28 | import java.awt.event.WindowEvent; |
32 | 29 | import java.io.File; |
33 | | -import java.lang.reflect.Method; |
34 | 30 |
|
35 | 31 | import javax.swing.JFrame; |
36 | 32 | import javax.swing.JOptionPane; |
|
49 | 45 | public class DeadCodeDetectorUI extends JPanel { |
50 | 46 | private static final long serialVersionUID = 1L; |
51 | 47 | private static final Color GRADIENT_COLOR = new Color(166, 202, 240); |
52 | | - private static final int APPEAR_STEP = 25; |
53 | | - private static final int APPEAR_DURATION = 750; |
54 | 48 | final ParametersPanel parametersPanel; |
55 | | - javax.swing.Timer appearTimer; |
56 | 49 |
|
57 | 50 | /** |
58 | 51 | * Constructeur du panel. |
@@ -122,55 +115,13 @@ public void windowClosing(WindowEvent e) { |
122 | 115 | final Dimension dimension = frame.getToolkit().getScreenSize(); |
123 | 116 | frame.setLocation(dimension.width / 2 - frame.getWidth() / 2, |
124 | 117 | dimension.height / 2 - frame.getHeight() / 2); |
125 | | - ui.disappear(); |
126 | 118 | frame.setVisible(true); |
127 | | - ui.appear(); |
128 | 119 | } catch (final Exception e) { |
129 | 120 | DcdUiHelper.printStackTrace(e); |
130 | 121 | JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); |
131 | 122 | } |
132 | 123 | } |
133 | 124 |
|
134 | | - private void appear() { |
135 | | - final JFrame frame = (JFrame) SwingUtilities.windowForComponent(this); |
136 | | - final long startTime = System.currentTimeMillis(); |
137 | | - appearTimer = new javax.swing.Timer(APPEAR_STEP, new ActionListener() { |
138 | | - /** {@inheritDoc} */ |
139 | | - @Override |
140 | | - public void actionPerformed(ActionEvent e) { |
141 | | - // calculate elapsed time |
142 | | - final long elapsed = System.currentTimeMillis() - startTime; |
143 | | - final float alpha = Math.min(1f, 1.0f * elapsed / APPEAR_DURATION); |
144 | | - setWindowOpacity(frame, alpha); |
145 | | - if (elapsed >= APPEAR_DURATION) { // should we stop timer? |
146 | | - appearTimer.stop(); |
147 | | - } |
148 | | - } |
149 | | - }); |
150 | | - |
151 | | - appearTimer.start(); |
152 | | - } |
153 | | - |
154 | | - private void disappear() { |
155 | | - final JFrame frame = (JFrame) SwingUtilities.windowForComponent(this); |
156 | | - setWindowOpacity(frame, 0f); |
157 | | - } |
158 | | - |
159 | | - static void setWindowOpacity(JFrame frame, float alpha) { |
160 | | - // cette méthode fonctionne à partir de Java 1.6.0_10 (update 10) |
161 | | - try { |
162 | | - //invoke AWTUtilities.setWindowOpacity(win, alpha); |
163 | | - final Class<?> awtutil = Class.forName("com.sun.awt.AWTUtilities"); |
164 | | - final Method setWindowOpaque = awtutil.getMethod("setWindowOpacity", Window.class, |
165 | | - float.class); |
166 | | - setWindowOpaque.invoke(null, frame, alpha); |
167 | | - } catch (final Throwable ex) { // NOPMD |
168 | | - // pour MAC OS X |
169 | | - frame.getRootPane().putClientProperty("Window.alpha", Float.valueOf(alpha)); |
170 | | - // sinon pas v1.6.0_u10 ou + : tant pis |
171 | | - } |
172 | | - } |
173 | | - |
174 | 125 | /** {@inheritDoc} */ |
175 | 126 | @Override |
176 | 127 | protected void paintComponent(Graphics graphics) { |
|
0 commit comments