KickJava   Java API By Example, From Geeks To Geeks.

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


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.Rect;
30 import org.objectweb.fractal.swing.AbstractAction;
31
32 import java.awt.event.ActionEvent JavaDoc;
33 import java.net.URL JavaDoc;
34
35 import javax.swing.ImageIcon JavaDoc;
36
37 /**
38  * An action that just calls the {@link Display#setDisplayedArea
39  * setDisplayedArea} method on a {@link Display}. This action reinitializes the
40  * displayed area so that the display shows the component graph entirely.
41  */

42
43 public class MaximizeAction extends AbstractAction
44   implements BindingController
45 {
46
47   /**
48    * A mandatory client interface bound to a {@link Display display} model. This
49    * is the display whose displayed area is modified by this controller
50    * component.
51    */

52
53   public final static String JavaDoc DISPLAY_BINDING = "display";
54
55   /**
56    * The display client interface.
57    */

58
59   private Display display;
60
61   /**
62    * Constructs a new {@link MaximizeAction} component.
63    */

64
65   public MaximizeAction () {
66     putValue(NAME, "Maximize");
67     URL JavaDoc url = getClass().getResource(
68       "/org/objectweb/fractal/gui/resources/maximize.gif");
69     putValue(SMALL_ICON, new ImageIcon JavaDoc(url));
70   }
71
72   // -------------------------------------------------------------------------
73
// Implementation of the BindingController interface
74
// -------------------------------------------------------------------------
75

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

106   public void actionPerformed (final ActionEvent JavaDoc e) {
107     display.setDisplayedArea(new Rect(0.01, 0.01, 0.99, 0.99));
108   }
109 }
110
111
Popular Tags