KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > gui > graph > model > DisplayNotifier


1 /***
2  * FractalGUI: a graphical tool to edit Fractal component configurations.
3  * Copyright (C) 2003 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: fractal@objectweb.org
20  *
21  * Authors: Eric Bruneton, Patrice Fauvel
22  */

23
24 package org.objectweb.fractal.gui.graph.model;
25
26 import org.objectweb.fractal.api.control.BindingController;
27
28 import java.util.Map JavaDoc;
29 import java.util.HashMap JavaDoc;
30 import java.util.Iterator JavaDoc;
31
32 /**
33  * A {@link DisplayListener} that notifies other {@link DisplayListener}s.
34  */

35
36 public class DisplayNotifier implements DisplayListener, BindingController {
37
38   /**
39    * A collection client interface bound to the {@link DisplayListener
40    * listeners} of this component.
41    */

42
43   public final static String JavaDoc DISPLAY_LISTENERS_BINDING = "display-listeners";
44
45   /**
46    * The listeners client interface.
47    */

48
49   private Map JavaDoc displayListeners;
50
51   /**
52    * Constructs a new {@link DisplayNotifier} component.
53    */

54
55   public DisplayNotifier () {
56     displayListeners = new HashMap JavaDoc();
57   }
58
59   // -------------------------------------------------------------------------
60
// Implementation of the BindingController interface
61
// -------------------------------------------------------------------------
62

63   public String JavaDoc[] listFc () {
64     return (String JavaDoc[])displayListeners.keySet().toArray(
65       new String JavaDoc[displayListeners.size()]);
66   }
67
68   public Object JavaDoc lookupFc (final String JavaDoc clientItfName) {
69     if (clientItfName.startsWith(DISPLAY_LISTENERS_BINDING)) {
70       return displayListeners.get(clientItfName);
71     }
72     return null;
73   }
74
75   public void bindFc (
76     final String JavaDoc clientItfName,
77     final Object JavaDoc serverItf)
78   {
79     if (clientItfName.startsWith(DISPLAY_LISTENERS_BINDING)) {
80       displayListeners.put(clientItfName, serverItf);
81     }
82   }
83
84   public void unbindFc (final String JavaDoc clientItfName) {
85     if (clientItfName.startsWith(DISPLAY_LISTENERS_BINDING)) {
86       displayListeners.remove(clientItfName);
87     }
88   }
89
90   // -------------------------------------------------------------------------
91
// Implementation of the DisplayListener interface
92
// -------------------------------------------------------------------------
93

94   public void displayedAreaChanged (final Rect oldValue) {
95     Iterator JavaDoc i = displayListeners.values().iterator();
96     while (i.hasNext()) {
97       ((DisplayListener)i.next()).displayedAreaChanged(oldValue);
98     }
99   }
100
101   public void antialiasingChanged () {
102     Iterator JavaDoc i = displayListeners.values().iterator();
103     while (i.hasNext()) {
104       ((DisplayListener)i.next()).antialiasingChanged();
105     }
106   }
107
108   public void maxDepthChanged () {
109     Iterator JavaDoc i = displayListeners.values().iterator();
110     while (i.hasNext()) {
111       ((DisplayListener)i.next()).maxDepthChanged();
112     }
113   }
114
115   public void itfNameDisplayModeChanged () {
116     Iterator JavaDoc i = displayListeners.values().iterator();
117     while (i.hasNext()) {
118       ((DisplayListener)i.next()).itfNameDisplayModeChanged();
119     }
120   }
121 }
122
123
Popular Tags