KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > buchuki > ensmer > object > Frontend


1 /*
2  * Copyright 2004 Dusty Phillips
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.buchuki.ensmer.object;
17
18 import javax.media.j3d.BranchGroup;
19 import javax.swing.event.*;
20 import com.buchuki.annotations.*;
21
22 /**
23  * Interface to be implemented by object frontends. Frontends are usually
24  * groovy scripts loaded by the <code>Backhoe</code>. They all implement this
25  * interface. There is a 1:1 relationship between loaded frontends and
26  * backends. No data from a frontend should be serialized; they are reloaded
27  * afresh each time the application is run. Frontends can keep a reference to
28  * the BranchGraph they manipulate and make changes to it as they like.
29  * <strong>NOTE:</strong> This class could use a Tiger generic to represent the
30  * backend associated with the frontend, as each frontend type can be
31  * associated with only one backend class. However, I don't believe Groovy
32  * supports generics, and frontends are implemented in Groovy.
33  *
34  * @author Dusty Phillips [dusty@buchuki.com]
35  */

36 public interface Frontend extends ChangeListener {
37
38     /**
39      * Retrieve a reference to the BranchGroup for this frontend. This BranchGroup
40      * can be manipulated by the frontend at any time (ie: in response to a
41      * changeEvent on the backend) and if it is displayed the changes will be
42      * visible. However, the BranchGroup should be rebuilt every time the
43      * method is called, returning a brand new BranchGroup each time. This method
44      * is generally only called when the group is being added to a new or
45      * different area
46      *
47      * @return the BranchGroup for the backend being managed
48      */

49     public BranchGroup getBranchGroup();
50
51     /**
52      * Called when a ChangeEvent is issued to the Frontend. Frontends are
53      * automatically added as ChangeListeners for their backends. Usually the
54      * Branchgroup would need to be reconstructed in response to a ChangeEvent
55      *
56      * @param event the ChangeEvent issued. This method should check the
57      * event.getSource() == getBackend() to ensure it isn't processing on
58      * some other event.
59      */

60     public void stateChanged(ChangeEvent event);
61
62     /**
63      * Called once to set the backend for the object. This method should never be
64      * called more than once and should only be called by the backhoe on
65      * constructing the frontend.
66      *
67      * @param backend the Backend to be set for this Frontend
68      */

69      @CallOnce
70     public void setBackend(Backend backend);
71
72     /**
73      * Retrieve the backend the frontend is interfacing for.
74      *
75      * @return the backend associated with this frontend
76      */

77     public Backend getBackend();
78     
79     /**
80      * Called when the frontend is removed. Many objects will be able to implement
81      * this as a no-op. However, some need to remove various event listeners; this
82      * is the place to do it.
83      */

84     public void destroy();
85 }
86
87
Popular Tags