|
From: JP <j-...@us...> - 2007-04-02 00:36:25
|
Update of /cvsroot/swixat/swixat/src/main/java/org/swixat/framework In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv29447/src/main/java/org/swixat/framework Modified Files: Tag: B0_6_0 ActionMonitor.java Added Files: Tag: B0_6_0 MessageFadeTimer.java Log Message: Wanted to use MessageFadeTimer independent of ActionMonitor, so I broke it out into its own class file and made it public. Index: ActionMonitor.java =================================================================== RCS file: /cvsroot/swixat/swixat/src/main/java/org/swixat/framework/ActionMonitor.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** ActionMonitor.java 2 Oct 2006 21:48:35 -0000 1.2 --- ActionMonitor.java 2 Apr 2007 00:36:20 -0000 1.2.2.1 *************** *** 308,369 **** } - - class MessageFadeTimer extends Thread { - - /** - * Logger for this class - */ - private final Log log = LogFactory.getLog(MessageFadeTimer.class); - - long wait = 0; - boolean cancel = false; - JComponent msg; - Color currentForeground; - - public MessageFadeTimer(JComponent msg, long wait) { - this.wait = wait; - this.msg = msg; - currentForeground = getMessageForeground(); - } - public void cancel() { - cancel = true; - } - public boolean isCanceled() { - return cancel; - } - public void run() { - if (msg != null) { - try { - Thread.sleep(wait); - - int alpha = currentForeground.getAlpha(); - while (!cancel && alpha >= 0) { - alpha -= 25; - if (alpha < 0) { - alpha = 0; - } - final Color newColor = new Color(currentForeground.getRed(), - currentForeground.getGreen(), - currentForeground.getBlue(), - alpha); - final JComponent msg = this.msg; - SwingUtilities.invokeLater(new Runnable(){ - public void run() { - if (!isCanceled()) { - msg.setForeground(newColor); - } - }; - }); - Thread.sleep(200); - } - } catch (InterruptedException eee) { - if (log.isTraceEnabled()) { - log.trace("thread interrupted", eee); - } - } - } - } - } - class ProgressStartTimer extends Thread { long wait = 0; --- 308,311 ---- --- NEW FILE: MessageFadeTimer.java --- /* *##% * Copyright (C) 2006 * Paolo Marrone, Benjamin Poussin and the SwiXAT team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *##%*/ /* * * ActionMonitor.java * * Created: 28 mars 2006 15:19:01 * * @author poussin * @version $Revision: 1.1.2.1 $ * * Last update: $Date: 2007/04/02 00:36:20 $ * by : $Author: j--p $ */ package org.swixat.framework; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.swing.*; import java.awt.*; /** * Fadeout effect for component text labels. * * @author poussin */ public class MessageFadeTimer extends Thread { /** * Logger for this class */ private final Log log = LogFactory.getLog(MessageFadeTimer.class); long wait = 0; boolean cancel = false; JComponent msg; Color currentForeground; public MessageFadeTimer(JComponent msg, long wait) { this.wait = wait; this.msg = msg; currentForeground = msg.getForeground(); } public void cancel() { cancel = true; } public boolean isCanceled() { return cancel; } public void run() { if (msg != null) { try { Thread.sleep(wait); int alpha = currentForeground.getAlpha(); while (!cancel && alpha >= 0) { alpha -= 25; if (alpha < 0) { alpha = 0; } final Color newColor = new Color(currentForeground.getRed(), currentForeground.getGreen(), currentForeground.getBlue(), alpha); final JComponent msg = this.msg; SwingUtilities.invokeLater(new Runnable(){ public void run() { if (!isCanceled()) { msg.setForeground(newColor); } } }); Thread.sleep(200); } } catch (InterruptedException eee) { if (log.isTraceEnabled()) { log.trace("thread interrupted", eee); } } } } } |