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;
|
package com.threerings.media.sprite;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.SwingUtilities;
|
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.Interval;
|
||||||
import com.samskivert.util.IntervalManager;
|
import com.samskivert.util.IntervalManager;
|
||||||
|
|
||||||
@@ -16,12 +17,12 @@ import com.threerings.media.util.PerformanceMonitor;
|
|||||||
import com.threerings.media.util.PerformanceObserver;
|
import com.threerings.media.util.PerformanceObserver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The AnimationManager handles the regular refreshing of the scene
|
* The animation manager handles the regular refreshing of the scene view
|
||||||
* view to allow for animation. It also may someday manage special
|
* to allow for animation. It also may someday manage special scene-wide
|
||||||
* scene-wide animations, such as rain, fog, or earthquakes.
|
* animations, such as rain, fog, or earthquakes.
|
||||||
*/
|
*/
|
||||||
public class AnimationManager
|
public class AnimationManager
|
||||||
implements Interval, PerformanceObserver, AncestorListener
|
implements Interval, PerformanceObserver
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Construct and initialize the animation manager with a sprite
|
* Construct and initialize the animation manager with a sprite
|
||||||
@@ -44,7 +45,19 @@ public class AnimationManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// listen to the view's ancestor events
|
// 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
|
// create a ticker for queueing up tick requests on the AWT thread
|
||||||
_ticker = new Runnable() {
|
_ticker = new Runnable() {
|
||||||
@@ -143,34 +156,15 @@ public class AnimationManager
|
|||||||
Log.info(name + " [ticks=" + ticks + "].");
|
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. */
|
/** The desired number of refresh operations per second. */
|
||||||
protected static final int FRAME_RATE = 70;
|
protected static final int FRAME_RATE = 70;
|
||||||
|
|
||||||
/** The milliseconds to sleep to obtain desired frame rate. */
|
/** The milliseconds to sleep to obtain desired frame rate. */
|
||||||
protected static final long REFRESH_INTERVAL = 1000 / 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. */
|
/** The number of outstanding tick requests. */
|
||||||
protected int _ticking = 0;
|
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;
|
package com.threerings.micasa.client;
|
||||||
|
|
||||||
@@ -17,7 +17,6 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.JTextPane;
|
import javax.swing.JTextPane;
|
||||||
import javax.swing.event.AncestorEvent;
|
import javax.swing.event.AncestorEvent;
|
||||||
import javax.swing.event.AncestorListener;
|
|
||||||
import javax.swing.text.BadLocationException;
|
import javax.swing.text.BadLocationException;
|
||||||
import javax.swing.text.Document;
|
import javax.swing.text.Document;
|
||||||
import javax.swing.text.Style;
|
import javax.swing.text.Style;
|
||||||
@@ -27,6 +26,7 @@ import javax.swing.text.StyleContext;
|
|||||||
import com.samskivert.swing.GroupLayout;
|
import com.samskivert.swing.GroupLayout;
|
||||||
import com.samskivert.swing.HGroupLayout;
|
import com.samskivert.swing.HGroupLayout;
|
||||||
import com.samskivert.swing.VGroupLayout;
|
import com.samskivert.swing.VGroupLayout;
|
||||||
|
import com.samskivert.swing.event.AncestorAdapter;
|
||||||
|
|
||||||
import com.threerings.crowd.chat.ChatCodes;
|
import com.threerings.crowd.chat.ChatCodes;
|
||||||
import com.threerings.crowd.chat.ChatDirector;
|
import com.threerings.crowd.chat.ChatDirector;
|
||||||
@@ -86,18 +86,12 @@ public class ChatPanel
|
|||||||
add(epanel, GroupLayout.FIXED);
|
add(epanel, GroupLayout.FIXED);
|
||||||
|
|
||||||
// listen to ancestor events to request focus when added
|
// listen to ancestor events to request focus when added
|
||||||
addAncestorListener(new AncestorListener() {
|
addAncestorListener(new AncestorAdapter() {
|
||||||
public void ancestorAdded (AncestorEvent e) {
|
public void ancestorAdded (AncestorEvent e) {
|
||||||
if (_focus) {
|
if (_focus) {
|
||||||
_entry.requestFocus();
|
_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;
|
package com.threerings.micasa.lobby;
|
||||||
|
|
||||||
@@ -11,8 +11,8 @@ import java.util.*;
|
|||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.AncestorEvent;
|
import javax.swing.event.AncestorEvent;
|
||||||
import javax.swing.event.AncestorListener;
|
|
||||||
|
|
||||||
|
import com.samskivert.swing.event.AncestorAdapter;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
import com.threerings.crowd.data.PlaceObject;
|
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
|
// we'll need to know when we are made visible because we'll want
|
||||||
// to issue a request for our categories when that happens
|
// to issue a request for our categories when that happens
|
||||||
addAncestorListener(new AncestorListener () {
|
addAncestorListener(new AncestorAdapter () {
|
||||||
public void ancestorAdded (AncestorEvent evt) {
|
public void ancestorAdded (AncestorEvent evt) {
|
||||||
// issue a get categories request to get the category list
|
// issue a get categories request to get the category list
|
||||||
LobbyService.getCategories(
|
LobbyService.getCategories(
|
||||||
_ctx.getClient(), LobbySelector.this);
|
_ctx.getClient(), LobbySelector.this);
|
||||||
}
|
}
|
||||||
public void ancestorRemoved (AncestorEvent evt) {
|
|
||||||
}
|
|
||||||
public void ancestorMoved (AncestorEvent evt) {
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user