Please review any and all PUBLIC repositories, groups, and associated files. These allow anyone on the Internet to access without authentication. Repository and group owners are responsible for their content and permission settings. Go to your project(s), click on Settings > General and expand the "Visibility, project features, permissions" to change this setting.

Commit 10f5fa4e authored by Norbraten, Terry's avatar Norbraten, Terry
Browse files

[Terry N.] use foreach loop for clarity

parent 37c3e43e
......@@ -246,19 +246,6 @@ public class DefaultEventModelEvaluator implements EventModelEvaluator {
// Methods defined by EventModelEvaluator
//----------------------------------------------------------
/**
* Initialise the evaluator with the given managers.
*
* @param scripts The manager for loading scripts
* @param router The manager for handling routes
* @param sensors The manager for all sensors
* @param fsm State manager for the frame
* @param elm Manager for loading external content
* @param lmf Factory for producing new layer managers
* @param lrm Manager for handling layer rendering
* @param vm Manager of viewpoint interactions
* @param extManagers List of external managers to handle
*/
@Override
public void initialize(ScriptManager scripts,
RouteManager router,
......@@ -281,14 +268,13 @@ public class DefaultEventModelEvaluator implements EventModelEvaluator {
// Find out how many node managers we have and sort them into the two
// lists for pre and post event model processing.
int num_mgr = (extManagers == null) ? 0 : extManagers.length;
int ext_cnt = 0;
int int_cnt = 0;
for(int i = 0; i < num_mgr; i++) {
if(extManagers[i].evaluatePreEventModel())
for(NodeManager nm : extManagers) {
if(nm.evaluatePreEventModel())
int_cnt++;
if(extManagers[i].evaluatePostEventModel())
if(nm.evaluatePostEventModel())
ext_cnt++;
}
......@@ -299,10 +285,10 @@ public class DefaultEventModelEvaluator implements EventModelEvaluator {
ext_cnt = 0;
VRMLClock clk = sensorManager.getVRMLClock();
for(int i = 0; i < num_mgr; i++) {
if(!extManagers[i].initialize()) {
for(NodeManager nm : extManagers) {
if(!nm.initialize()) {
errorReporter.warningReport(
"Manager " + extManagers[i].getClass() +
"Manager " + nm.getClass() +
" failed to initialise. Ignoring", null);
// Go through the list of its supported components and disable
......@@ -310,15 +296,15 @@ public class DefaultEventModelEvaluator implements EventModelEvaluator {
continue;
}
if(extManagers[i].evaluatePreEventModel())
preEventManagers[int_cnt++] = extManagers[i];
if(nm.evaluatePreEventModel())
preEventManagers[int_cnt++] = nm;
if(extManagers[i].evaluatePostEventModel())
postEventManagers[ext_cnt++] = extManagers[i];
if(nm.evaluatePostEventModel())
postEventManagers[ext_cnt++] = nm;
stateManager.listenFor(extManagers[i].getManagedNodeTypes());
extManagers[i].setErrorReporter(errorReporter);
extManagers[i].setVRMLClock(clk);
stateManager.listenFor(nm.getManagedNodeTypes());
nm.setErrorReporter(errorReporter);
nm.setVRMLClock(clk);
}
stateManager.listenFor(new int[] { TypeConstants.ViewpointNodeType});
......@@ -336,15 +322,6 @@ public class DefaultEventModelEvaluator implements EventModelEvaluator {
numActiveLayerManagers = 0;
}
/**
* Add an observer for a specific node type. A single instance may be
* registered for more than one type. Each type registered will result in
* a separate call per frame - one per type. If the observer is currently
* added for this type ID, the request is ignored.
*
* @param nodeType The type identifier of the node being observed
* @param obs The observer instance to add
*/
@Override
public void addNodeObserver(int nodeType, NodeObserver obs) {
List<NodeObserver> observers = nodeObserverMap.get(nodeType);
......@@ -361,15 +338,6 @@ public class DefaultEventModelEvaluator implements EventModelEvaluator {
observers.add(obs);
}
/**
* Remove the given node observer instance for the specific node type. It
* will not be removed for any other requested node types. If the instance
* is not registered for the given node type ID, the request will be
* silently ignored.
*
* @param nodeType The type identifier of the node being observed
* @param obs The observer instance to remove
*/
@Override
public void removeNodeObserver(int nodeType, NodeObserver obs) {
List<NodeObserver> observers = nodeObserverMap.get(nodeType);
......@@ -387,10 +355,6 @@ public class DefaultEventModelEvaluator implements EventModelEvaluator {
// memory anyway.
}
/**
* Shutdown the node manager now. If this is using any external resources
* it should remove those now as the entire application is about to die
*/
@Override
public void shutdown() {
shutdownNow = true;
......@@ -408,15 +372,6 @@ public class DefaultEventModelEvaluator implements EventModelEvaluator {
viewpointManager.shutdown();
}
/**
* Register an error reporter with the engine so that any errors generated
* by the loading of script code can be reported in a nice, pretty fashion.
* Setting a value of null will clear the currently set reporter. If one
* is already set, the new value replaces the old. This call will
* automatically set the reporter in all the contained managers.
*
* @param reporter The instance to use or null
*/
@Override
public void setErrorReporter(ErrorReporter reporter) {
errorReporter = reporter;
......@@ -443,12 +398,6 @@ public class DefaultEventModelEvaluator implements EventModelEvaluator {
postEventManagers[i].setErrorReporter(errorReporter);
}
/**
* Get the layer manager for the the layer ID.
*
* @param id a value &gt;= 0 that is the ID of the layer to get
* @return The layer manager for it
*/
@Override
public LayerManager getLayerManager(int id) {
if(id < numValidLayerManagers)
......@@ -457,49 +406,22 @@ public class DefaultEventModelEvaluator implements EventModelEvaluator {
return null;
}
/**
* Get the VRMLClock instance in use by this evaluator.
*
* @return A reference to the clock
*/
@Override
public VRMLClock getVRMLClock() {
return sensorManager.getVRMLClock();
}
/**
* Add an external view to the evaluator. A view can only be added once.
* If the view is added more than once, the second and subsequent calls
* are ignored.
*
* @param view The new view to add
*/
@Override
public void addExternalView(ExternalView view) {
if(!externalViews.contains(view))
externalViews.add(view);
}
/**
* Remove the external view from this evaluator. If the view is not
* currently registered, the request is silently ignored.
*
* @param view The new view to remove
*/
@Override
public void removeExternalView(ExternalView view) {
externalViews.remove(view);
}
/**
* Used to set the scene to the new content. Will automatically shutdown
* the old scene. Assumes a valid scene instance is passed. Also assumes
* that no clock ticks will be received during the setup phase.
*
* @param scene The new scene instance to use.
* @param useView The initial viewpoint DEF name to bind to,
* Null means normal spec'd viewpoint.
*/
@Override
public void setScene(VRMLScene scene, String useView) {
sceneNeedsChanging = true;
......@@ -507,25 +429,11 @@ public class DefaultEventModelEvaluator implements EventModelEvaluator {
initialViewpoint = useView;
}
/**
* Request that this viewpoint object is bound at the start of the next
* frame. This method should only be called by external users such as
* UI toolkits etc that need to synchronize the viewpoint change with
* rendering loop, but are not able to synchronize themselves because they
* exist on a different thread that cannot block.
*
* @param vp The new viewpoint instance to bind to
*/
@Override
public void changeViewpoint(VRMLViewpointNodeType vp) {
pendingViewpoint = vp;
}
/**
* Force clearing all state from this manager now. This is used to indicate
* that a new world is about to be loaded and everything should be cleaned
* out now. Assumes the clock has stopped ticking.
*/
@Override
public void clear() {
active = false;
......@@ -562,12 +470,6 @@ public class DefaultEventModelEvaluator implements EventModelEvaluator {
haveLayerSet = false;
}
/**
* Run the event model for this frame now. This is a blocking call and
* does not return until the event model is complete for this frame.
*
* @param time The timestamp of this frame to evaluate in Java time
*/
@Override
public void evaluate(long time) {
lastTime = time;
......@@ -613,63 +515,31 @@ public class DefaultEventModelEvaluator implements EventModelEvaluator {
}
}
/**
* Set the listener for initialization information. Setting null will
* clear the current instance.
*
* @param l The listener instance to set
*/
@Override
public void setInitListener(EventModelInitListener l) {
initListener = l;
}
/**
* Get the script manager in use by the evaluator.
*
* @return The script manager implementation
*/
@Override
public ScriptManager getScriptManager() {
return scriptManager;
}
/**
* Get the route manager in use by the evaluator.
*
* @return The route manager implementation
*/
@Override
public RouteManager getRouteManager() {
return routeManager;
}
/**
* Get the content loader in use by the evaluator.
*
* @return The content loader implementation
*/
@Override
public ContentLoadManager getContentLoader() {
return contentLoader;
}
/**
* Get the frame state manager in use by the evaluator.
*
* @return The frame state manager implementation
*/
@Override
public FrameStateManager getFrameStateManager() {
return stateManager;
}
/**
* Get the list of external node managers currently in use. If there are no
* registered managers, returns null.
*
* @return An array of managers or null
*/
@Override
public NodeManager[] getNodeManagers() {
int size = numPreEventManagers + numPostEventManagers;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment