01: package prefuse.util;
02:
03: import java.awt.event.ComponentEvent;
04: import java.awt.event.ComponentListener;
05:
06: import prefuse.data.Tuple;
07: import prefuse.data.event.ExpressionListener;
08: import prefuse.data.event.TupleSetListener;
09: import prefuse.data.expression.Expression;
10: import prefuse.data.tuple.TupleSet;
11:
12: /**
13: * Convenience listener class that implements ExpressionListener,
14: * TupleSetListener, and ComponentListener and routes all the
15: * callbacks into a generic {@link #update(Object)} method. For the
16: * case of ComponentListener, only the resize event is funneled into
17: * the update method.
18: *
19: * @author <a href="http://jheer.org">jeffrey heer</a>
20: */
21: public abstract class UpdateListener implements ExpressionListener,
22: TupleSetListener, ComponentListener {
23: /**
24: * Generic update routine triggerred by any of the other callbacks.
25: * @param source a source object, either the Expression, TupleSet,
26: * or Component that triggered this update event.
27: */
28: public abstract void update(Object source);
29:
30: /**
31: * @see prefuse.data.event.ExpressionListener#expressionChanged(prefuse.data.expression.Expression)
32: */
33: public void expressionChanged(Expression expr) {
34: update(expr);
35: }
36:
37: /**
38: * @see prefuse.data.event.TupleSetListener#tupleSetChanged(prefuse.data.tuple.TupleSet, prefuse.data.Tuple[], prefuse.data.Tuple[])
39: */
40: public void tupleSetChanged(TupleSet tset, Tuple[] added,
41: Tuple[] removed) {
42: update(tset);
43: }
44:
45: /**
46: * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
47: */
48: public void componentResized(ComponentEvent e) {
49: update(e.getSource());
50: }
51:
52: /**
53: * Does nothing.
54: * @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
55: */
56: public void componentHidden(ComponentEvent e) {
57: // do nothing
58: }
59:
60: /**
61: * Does nothing.
62: * @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
63: */
64: public void componentMoved(ComponentEvent e) {
65: // do nothing
66: }
67:
68: /**
69: * Does nothing.
70: * @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
71: */
72: public void componentShown(ComponentEvent e) {
73: // do nothing
74: }
75:
76: } // end of abstract class UpdateListener
|