KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > buchuki > ensmer > builtin > Background


1 /*
2  * Copyright 2005 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
17 package com.buchuki.ensmer.builtin;
18
19 import com.buchuki.ensmer.EnsmerManager;
20 import com.buchuki.ensmer.input.InputManager;
21 import com.buchuki.ensmer.input.command.*;
22 import com.buchuki.ensmer.input.event.*;
23 import com.buchuki.ensmer.object.Backend;
24 import com.buchuki.ensmer.text.TextInput;
25 import com.sun.j3d.utils.geometry.Text2D;
26 import java.awt.Font JavaDoc;
27 import java.awt.event.KeyEvent JavaDoc;
28 import java.io.Serializable JavaDoc;
29 import javax.media.j3d.*;
30 import javax.vecmath.Color3f;
31
32 /**
33  * Class to represent an object that displays an image on the background of
34  * the scene. This is the intended purpose, but it actually only stores a
35  * filename and it is up to the frontend to display the background object.
36  *
37  * @author Dusty Phillips [dusty@buchuki.com]
38  */

39 public class Background extends Backend {
40     
41     /**
42      * Creates a new instance of a default (empty) Background
43      */

44     public Background() {
45     }
46     
47     /**
48      * Create a background object based on previously serialized data
49      * representing the note's filename
50      */

51     public Background(Serializable JavaDoc data) {
52         this();
53     }
54     
55     /**
56      * When we get an ID, set up the Configurator default properties
57      */

58     public void setId(Long JavaDoc id) {
59         super.setId(id);
60         if (getConfigProperty("filename") == null) {
61             setConfigProperty("filename", "");
62         }
63     }
64     
65     /**
66      * Get the Serializable for the Background object
67      *
68      * @return the TextInput storing the filename
69      */

70     public Serializable JavaDoc getSerializable() {
71         return null;
72     }
73     
74     /**
75      * Get the filename for the Background object
76      */

77     public String JavaDoc getFilename() {
78         String JavaDoc filename = getConfigProperty("filename");
79         return filename == null ? "" : filename;
80     }
81     
82     /**
83      * Return a Branchgroup representing the <b>type</b> of this object so that
84      * Background objects can be manually added to the scene. Probably an interesting
85      * objicon could be created, but for now it simply creates a text2D containing
86      * the word 'Background'.
87      *
88      * @return a branchgroup representing the class of Static objects
89      */

90     @Override JavaDoc
91     public static BranchGroup getRepresentation() {
92         Text2D text = new Text2D("Background", new Color3f(.7f, .1f, .6f), "Times",
93                 16, Font.BOLD);
94         Appearance app = text.getAppearance();
95         PolygonAttributes poly = new PolygonAttributes();
96         poly.setCullFace(poly.CULL_NONE);
97         app.setPolygonAttributes(poly);
98         BranchGroup ret = new BranchGroup();
99         ret.addChild(text);
100         return ret;
101     }
102 }
103
Popular Tags