KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > gui > graph > control > ChangeItfDisplayAction


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.control;
25
26 import org.objectweb.fractal.api.control.BindingController;
27
28 import org.objectweb.fractal.gui.graph.model.Display;
29 import org.objectweb.fractal.gui.graph.model.DisplayListener;
30 import org.objectweb.fractal.gui.graph.model.Rect;
31 import org.objectweb.fractal.swing.AbstractAction;
32
33 import java.awt.event.ActionEvent JavaDoc;
34 import java.net.URL JavaDoc;
35
36 import javax.swing.ImageIcon JavaDoc;
37 import javax.swing.KeyStroke JavaDoc;
38
39 /**
40  * An action that just calls the {@link Display#setIsAntialiasing
41  * setIsAntiAliasing} method on a {@link Display}. This action listens to the
42  * display model in order to change its name when the anti aliasing option
43  * changes.
44  */

45
46 public class ChangeItfDisplayAction extends AbstractAction implements
47   DisplayListener,
48   BindingController
49 {
50
51   /**
52    * A mandatory client interface bound to a {@link Display display} model. This
53    * is the display whose anti aliasing option is modified by this controller
54    * component.
55    */

56
57   public final static String JavaDoc DISPLAY_BINDING = "display";
58
59   /**
60    * The display client interface.
61    */

62
63   private Display display;
64
65   /**
66    * Constructs a new {@link AntiAliasAction} component.
67    */

68
69   public ChangeItfDisplayAction () {
70     putValue(NAME, "Change Display Itf Name");
71     putValue(SHORT_DESCRIPTION, "Change Display Itf Name");
72     URL JavaDoc url = getClass().getResource(
73       "/org/objectweb/fractal/gui/resources/empty.gif");
74     putValue(SMALL_ICON, new ImageIcon JavaDoc(url));
75     putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("alt R"));
76   }
77
78   // -------------------------------------------------------------------------
79
// Implementation of the BindingController interface
80
// -------------------------------------------------------------------------
81

82   public String JavaDoc[] listFc () {
83     return new String JavaDoc[] { DISPLAY_BINDING };
84   }
85
86   public Object JavaDoc lookupFc (final String JavaDoc clientItfName) {
87     if (DISPLAY_BINDING.equals(clientItfName)) {
88       return display;
89     }
90     return null;
91   }
92
93   public void bindFc (
94     final String JavaDoc clientItfName,
95     final Object JavaDoc serverItf)
96   {
97     if (DISPLAY_BINDING.equals(clientItfName)) {
98       display = (Display)serverItf;
99     }
100   }
101
102   public void unbindFc (final String JavaDoc clientItfName) {
103     if (DISPLAY_BINDING.equals(clientItfName)) {
104       display = null;
105     }
106   }
107
108   // -------------------------------------------------------------------------
109
// Implementation of the DisplayListener interface
110
// -------------------------------------------------------------------------
111

112   public void displayedAreaChanged (final Rect oldValue) {
113     // does nothing
114
}
115
116   public void antialiasingChanged () {
117     // does nothing
118
}
119
120   public void maxDepthChanged () {
121     // does nothing
122
}
123
124   public void itfNameDisplayModeChanged() {
125   }
126
127   // -------------------------------------------------------------------------
128
// Overriden JCheckBoxMenuItem methods
129
// -------------------------------------------------------------------------
130

131   public void actionPerformed (final ActionEvent JavaDoc e) {
132     display.setItfNameDisplayMode();
133   }
134 }
135
Popular Tags