1 /*****************************************************************************
2 * Virtual Mockup for Machine Vision
3 * Copyright (C) 2001-2003 Fabio R. de Miranda, João E. Kogler Jr.,
4 * Carlos S. Santos.
5 * Virtual Mockup for Machine Vision Project funded by SENAC-SP
6 *
7 * Permission is granted to redistribute and/or modify this
8 * software under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License (http://www.gnu.org/copyleft/lesser.html)
16 * for more details.
17 *
18 *****************************************************************************/
19
20 package camera3d;
21
22
23 import javax.vecmath.*;
24 import javax.media.j3d.*;
25 import javax.swing.ImageIcon;
26 import javax.swing.Icon;
27
28 /***
29 * Abstract superclass to all lights that can be added to the scene graph. This class
30 * encapsulates a javax.media.j3d.Light and provides some functionality for editing it.
31 * @author Fábio Roberto de Miranda
32 * @version 1.0
33 */
34 public abstract class VcLight extends VcObject {
35
36 private static int instanceCounter = 0;
37 private Icon lightIcon = new ImageIcon(this.getClass().getResource("icons/light_item.gif"));
38 Color3f color = new Color3f();
39
40 /***
41 * Creates new light.
42 */
43 public VcLight(){
44 this.setLabel("Light"+VcLight.instanceCounter++);
45 }
46
47
48 /***
49 * Returns the number of objects instatiated so far.
50 */
51 public static int getInstanceCounter(){
52 return instanceCounter;
53 }
54
55 /***
56 * Sets color of this light.
57 * @param red red component of color.
58 * @param green green component of color.
59 * @param blue blue component of color.
60 */
61 public abstract void setColor(float red, float green, float blue);
62
63 /***
64 * Sets state (on/off) of this light.
65 * @param b If true, turns light on. If false, turns light off.
66 */
67 public abstract void setEnable(boolean b);
68
69 /***
70 * Returns current color of this light.
71 */
72 public Color3f getColor(){
73 return this.color;
74 }
75
76 /***
77 * Returns red component of this light's color.
78 */
79 public float getRed(){
80 getJ3DLight().getColor(color);
81 return color.x;
82 }
83
84 /***
85 * Returns green component of this light's color.
86 */
87 public float getGreen(){
88 getJ3DLight().getColor(color);
89 return color.y;
90 }
91
92 /***
93 * Returns blue component of this light's color.
94 */
95 public float getBlue(){
96 getJ3DLight().getColor(color);
97 return color.z;
98 }
99
100 /***
101 * Returns a flag indicating current light's state (on/off).
102 * @return true if light is on, false if light is off.
103 */
104 public boolean isEnabled(){
105 return this.getJ3DLight().getEnable();
106 }
107
108 /***
109 * Returns the Icon associated with lights.
110 */
111 public Icon getIcon(){
112 return this.lightIcon;
113 }
114
115 /***
116 * Sets the Icon associated with lights.
117 */
118 public void setIcon(Icon lightIcon){
119 this.lightIcon=lightIcon;
120 }
121
122 /*** Returns the Java 3D light encapsulated by this VcLight. */
123 public abstract Light getJ3DLight();
124
125 /*** Sets the Java 3D light encapsulated by this VcLight. */
126 public abstract void setJ3DLight(javax.media.j3d.Light light);
127 }
This page was automatically generated by Maven