org.wilmascope.light
Class LightManager

java.lang.Object
  extended by org.wilmascope.light.LightManager

public class LightManager
extends java.lang.Object

LightManager is the main class to control the light sources.

It maintain 4 vectors:
1 ambLightVector--contains all the ambient lights created.
2 dirLightVector--contains all the directioanl lights created.
3 pointLightVector--contains all the point lights created.
4 spotLightVector--contains all the spot lights created.

Here is an example to create an object of it:

lightManager=new LightManager(bg,bounds,"WILMA_CONSTANTS.properties");
 

parameter 1:the branch group the lights will be attached to
parameter 2:the scheduling bounds of the lights
parameter 3:the light properties file name.

Before showing the lightFrame,first disable all mouse picking and behavior capabilities. And then add a window Listener to the lightFrame, so that when the frame is closed, the mouse picking and behavior capabilites are reenabled:
GraphCanvas graphCanvas=graphControl.getGraphCanvas();
graphControl.getGraphCanvas().setPickingEnabled(false);
graphControl.getGraphCanvas().getMouseRotate().setEnable(false);
graphControl.getGraphCanvas().getMouseTranslate().setEnable(false);
graphControl.getGraphCanvas().getMouseZoom().setEnable(false);

lightFrame=graphCanvas.getLightManager().getLightFrame();

lightFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
graphControl.getGraphCanvas().setPickingEnabled(true);
graphControl.getGraphCanvas().getMouseRotate().setEnable(true);
graphControl.getGraphCanvas().getMouseTranslate().setEnable(true);
graphControl.getGraphCanvas().getMouseZoom().setEnable(true);
}
    });
lightFrame.setVisible(true);


Constructor Summary
LightManager(javax.media.j3d.BranchGroup bg, javax.media.j3d.Bounds bounds, java.lang.String propertyFileName)
           
 
Method Summary
 void createAmbLight()
          creates an ambient light with default values and attach it to the scene graph
 void createDirLight()
          creates a directional light with default values and attach it to the scene graph
 void createPointLight()
          creates a point light with default values and attach it to the scene graph
 void createSpotLight()
          creates a spot light with default values and attach it to the scene graph
 void deleteAmbLight(int index)
          deletes the ambient light from the scene graph
 void deleteDirLight(int index)
          deletes the directional light from the scene graph
 void deletePointLight(int index)
          deletes the point light from the scene graph
 void deleteSpotLight(int index)
          deletes the spot light from the scene graph
 java.util.Vector getAmbLightVector()
           
 javax.media.j3d.Bounds getBoundingSphere()
           
 javax.media.j3d.BranchGroup getBranchGroup()
           
 java.util.Vector getDirLightVector()
           
 LightFrame getLightFrame()
           
 java.util.Vector getPointLightVector()
           
 java.lang.String getPropertyFileName()
           
 java.util.Vector getSpotLightVector()
           
 void loadFile(java.lang.String propertyFileName)
          loads the light configuration from the specified property file
 void saveLight()
          Saves the light configuration to the property file
 void saveToNewFile(java.lang.String name)
          Saves the light configuration to a new file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LightManager

public LightManager(javax.media.j3d.BranchGroup bg,
                    javax.media.j3d.Bounds bounds,
                    java.lang.String propertyFileName)
Method Detail

getLightFrame

public LightFrame getLightFrame()
Returns:
A LightFrame instance

saveLight

public void saveLight()
Saves the light configuration to the property file


getAmbLightVector

public java.util.Vector getAmbLightVector()
Returns:
The AmbientLight Vector

getDirLightVector

public java.util.Vector getDirLightVector()
Returns:
The DirectionalLight Vector

getPointLightVector

public java.util.Vector getPointLightVector()
Returns:
The PointLight Vector

getSpotLightVector

public java.util.Vector getSpotLightVector()
Returns:
The SpotLight Vector

getBranchGroup

public javax.media.j3d.BranchGroup getBranchGroup()
Returns:
The branch group that the lights attach

getBoundingSphere

public javax.media.j3d.Bounds getBoundingSphere()
Returns:
The scheduling bounds of the lights

getPropertyFileName

public java.lang.String getPropertyFileName()
Returns:
The file name of light configuration file

createAmbLight

public void createAmbLight()
creates an ambient light with default values and attach it to the scene graph


createDirLight

public void createDirLight()
creates a directional light with default values and attach it to the scene graph


createPointLight

public void createPointLight()
creates a point light with default values and attach it to the scene graph


createSpotLight

public void createSpotLight()
creates a spot light with default values and attach it to the scene graph


deleteAmbLight

public void deleteAmbLight(int index)
deletes the ambient light from the scene graph

Parameters:
index - index in the ambient light vector(ambLightVector)

deleteDirLight

public void deleteDirLight(int index)
deletes the directional light from the scene graph

Parameters:
index - index in the directional light vector(dirLightVector)

deletePointLight

public void deletePointLight(int index)
deletes the point light from the scene graph

Parameters:
index - index in the point light vector(pointLightVector)

deleteSpotLight

public void deleteSpotLight(int index)
deletes the spot light from the scene graph

Parameters:
index - index in the spot light vector(spotLightVector)

loadFile

public void loadFile(java.lang.String propertyFileName)
loads the light configuration from the specified property file


saveToNewFile

public void saveToNewFile(java.lang.String name)
Saves the light configuration to a new file