Use AncestorAdapter.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@779 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
//
|
||||
// $Id: AnimationManager.java,v 1.17 2001/10/25 22:08:28 mdb Exp $
|
||||
// $Id: AnimationManager.java,v 1.18 2001/12/14 16:08:00 shaper Exp $
|
||||
|
||||
package com.threerings.media.sprite;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.event.AncestorEvent;
|
||||
|
||||
import com.samskivert.swing.event.AncestorAdapter;
|
||||
import com.samskivert.util.Interval;
|
||||
import com.samskivert.util.IntervalManager;
|
||||
|
||||
@@ -16,12 +17,12 @@ import com.threerings.media.util.PerformanceMonitor;
|
||||
import com.threerings.media.util.PerformanceObserver;
|
||||
|
||||
/**
|
||||
* The AnimationManager handles the regular refreshing of the scene
|
||||
* view to allow for animation. It also may someday manage special
|
||||
* scene-wide animations, such as rain, fog, or earthquakes.
|
||||
* The animation manager handles the regular refreshing of the scene view
|
||||
* to allow for animation. It also may someday manage special scene-wide
|
||||
* animations, such as rain, fog, or earthquakes.
|
||||
*/
|
||||
public class AnimationManager
|
||||
implements Interval, PerformanceObserver, AncestorListener
|
||||
implements Interval, PerformanceObserver
|
||||
{
|
||||
/**
|
||||
* Construct and initialize the animation manager with a sprite
|
||||
@@ -44,7 +45,19 @@ public class AnimationManager
|
||||
}
|
||||
|
||||
// listen to the view's ancestor events
|
||||
target.addAncestorListener(this);
|
||||
target.addAncestorListener(new AncestorAdapter() {
|
||||
public void ancestorAdded (AncestorEvent event) {
|
||||
if (_iid == -1) {
|
||||
// register the refresh interval since we're now visible
|
||||
registerInterval();
|
||||
}
|
||||
}
|
||||
public void ancestorRemoved (AncestorEvent event) {
|
||||
// un-register the refresh interval since we're now hidden
|
||||
IntervalManager.remove(_iid);
|
||||
_iid = -1;
|
||||
}
|
||||
});
|
||||
|
||||
// create a ticker for queueing up tick requests on the AWT thread
|
||||
_ticker = new Runnable() {
|
||||
@@ -143,34 +156,15 @@ public class AnimationManager
|
||||
Log.info(name + " [ticks=" + ticks + "].");
|
||||
}
|
||||
|
||||
/** AncestorListener interface methods. */
|
||||
|
||||
public void ancestorAdded (AncestorEvent event)
|
||||
{
|
||||
if (_iid == -1) {
|
||||
// register the refresh interval since we're now visible
|
||||
registerInterval();
|
||||
}
|
||||
}
|
||||
|
||||
public void ancestorRemoved (AncestorEvent event)
|
||||
{
|
||||
// un-register the refresh interval since we're now hidden
|
||||
IntervalManager.remove(_iid);
|
||||
_iid = -1;
|
||||
}
|
||||
|
||||
public void ancestorMoved (AncestorEvent event) { }
|
||||
|
||||
/** The ticker runnable that we put on the AWT thread periodically. */
|
||||
protected Runnable _ticker;
|
||||
|
||||
/** The desired number of refresh operations per second. */
|
||||
protected static final int FRAME_RATE = 70;
|
||||
|
||||
/** The milliseconds to sleep to obtain desired frame rate. */
|
||||
protected static final long REFRESH_INTERVAL = 1000 / FRAME_RATE;
|
||||
|
||||
/** The ticker runnable that we put on the AWT thread periodically. */
|
||||
protected Runnable _ticker;
|
||||
|
||||
/** The number of outstanding tick requests. */
|
||||
protected int _ticking = 0;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ChatPanel.java,v 1.8 2001/12/14 04:33:53 shaper Exp $
|
||||
// $Id: ChatPanel.java,v 1.9 2001/12/14 16:07:30 shaper Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
@@ -17,7 +17,6 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JTextPane;
|
||||
import javax.swing.event.AncestorEvent;
|
||||
import javax.swing.event.AncestorListener;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.Style;
|
||||
@@ -27,6 +26,7 @@ import javax.swing.text.StyleContext;
|
||||
import com.samskivert.swing.GroupLayout;
|
||||
import com.samskivert.swing.HGroupLayout;
|
||||
import com.samskivert.swing.VGroupLayout;
|
||||
import com.samskivert.swing.event.AncestorAdapter;
|
||||
|
||||
import com.threerings.crowd.chat.ChatCodes;
|
||||
import com.threerings.crowd.chat.ChatDirector;
|
||||
@@ -86,18 +86,12 @@ public class ChatPanel
|
||||
add(epanel, GroupLayout.FIXED);
|
||||
|
||||
// listen to ancestor events to request focus when added
|
||||
addAncestorListener(new AncestorListener() {
|
||||
addAncestorListener(new AncestorAdapter() {
|
||||
public void ancestorAdded (AncestorEvent e) {
|
||||
if (_focus) {
|
||||
_entry.requestFocus();
|
||||
}
|
||||
}
|
||||
public void ancestorMoved (AncestorEvent e) {
|
||||
// don't care
|
||||
}
|
||||
public void ancestorRemoved (AncestorEvent e) {
|
||||
// don't care
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: LobbySelector.java,v 1.3 2001/10/11 04:13:33 mdb Exp $
|
||||
// $Id: LobbySelector.java,v 1.4 2001/12/14 16:07:30 shaper Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
@@ -11,8 +11,8 @@ import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.AncestorEvent;
|
||||
import javax.swing.event.AncestorListener;
|
||||
|
||||
import com.samskivert.swing.event.AncestorAdapter;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
@@ -67,16 +67,12 @@ public class LobbySelector
|
||||
|
||||
// we'll need to know when we are made visible because we'll want
|
||||
// to issue a request for our categories when that happens
|
||||
addAncestorListener(new AncestorListener () {
|
||||
addAncestorListener(new AncestorAdapter () {
|
||||
public void ancestorAdded (AncestorEvent evt) {
|
||||
// issue a get categories request to get the category list
|
||||
LobbyService.getCategories(
|
||||
_ctx.getClient(), LobbySelector.this);
|
||||
}
|
||||
public void ancestorRemoved (AncestorEvent evt) {
|
||||
}
|
||||
public void ancestorMoved (AncestorEvent evt) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user