//
// NodeRendererJ3D.java
//
/*
VisAD system for interactive analysis and visualization of numerical
data. Copyright (C) 1996 - 2017 Bill Hibbard, Curtis Rueden, Tom
Rink, Dave Glowacki, Steve Emmerson, Tom Whittaker, Don Murray, and
Tommy Jasmin.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/
package visad.cluster;
import visad.*;
import visad.java3d.*;
import visad.util.Delay;
import java.awt.event.*;
import javax.swing.*;
import java.rmi.*;
/**
NodeRendererJ3D is the VisAD class for transforming
data into VisADSceneGraphObjects, but not rendering,
on cluster nodes
*/
public class NodeRendererJ3D extends DefaultRendererJ3D {
private NodeAgent agent = null;
private boolean enable_transform = false;
private int resolution = 1;
/** this constructor is need for NodeDisplayRendererJ3D.makeDefaultRenderer()
but it should never be called */
public NodeRendererJ3D () {
this(null);
}
/** this DataRenderer transforms data into VisADSceneGraphObjects,
but does not render, on cluster nodes;
send scene graphs back via NodeAgent */
public NodeRendererJ3D (NodeAgent a) {
super();
agent = a;
}
public ShadowType makeShadowFunctionType(
FunctionType type, DataDisplayLink link, ShadowType parent)
throws VisADException, RemoteException {
return new ShadowNodeFunctionTypeJ3D(type, link, parent);
}
public ShadowType makeShadowRealTupleType(
RealTupleType type, DataDisplayLink link, ShadowType parent)
throws VisADException, RemoteException {
return new ShadowNodeRealTupleTypeJ3D(type, link, parent);
}
public ShadowType makeShadowRealType(
RealType type, DataDisplayLink link, ShadowType parent)
throws VisADException, RemoteException {
return new ShadowNodeRealTypeJ3D(type, link, parent);
}
public ShadowType makeShadowSetType(
SetType type, DataDisplayLink link, ShadowType parent)
throws VisADException, RemoteException {
return new ShadowNodeSetTypeJ3D(type, link, parent);
}
public ShadowType makeShadowTupleType(
TupleType type, DataDisplayLink link, ShadowType parent)
throws VisADException, RemoteException {
return new ShadowNodeTupleTypeJ3D(type, link, parent);
}
public void setResolution(int r) {
resolution = r;
}
public int getResolution() {
return resolution;
}
public void enableTransform() {
enable_transform = true;
}
public DataShadow prepareAction(boolean go, boolean initialize,
DataShadow shadow)
throws VisADException, RemoteException {
// don't autoscale: initialize = false
return super.prepareAction(go, false, shadow);
}
/** re-transform if needed;
return false if not done */
public boolean doAction() throws VisADException, RemoteException {
boolean all_feasible = get_all_feasible();
boolean any_changed = get_any_changed();
boolean any_transform_control = get_any_transform_control();
if (all_feasible && (any_changed || any_transform_control)) {
/*
System.out.println("RendererJ3D.doAction: any_changed = " + any_changed +
" any_transform_control = " + any_transform_control);
System.out.println(getLinks()[0].getThingReference().getName());
*/
boolean branch = false;
// exceptionVector.removeAllElements();
clearAVControls();
try {
// doTransform creates a BranchGroup from a Data object
branch = fakeTransform();
}
catch (OutOfMemoryError e) {
// System.out.println("OutOfMemoryError, try again ...");
branch = false;
new Delay(250);
Runtime.getRuntime().gc();
Runtime.getRuntime().runFinalization();
try {
branch = fakeTransform();
}
catch (BadMappingException ee) {
addException(ee);
}
catch (UnimplementedException ee) {
addException(ee);
branch = false;
}
catch (RemoteException ee) {
addException(ee);
branch = false;
}
catch (DisplayInterruptException ee) {
branch = false;
}
}
catch (BadMappingException e) {
addException(e);
branch = false;
}
catch (UnimplementedException e) {
addException(e);
branch = false;
}
catch (RemoteException e) {
addException(e);
branch = false;
}
catch (DisplayInterruptException e) {
branch = false;
}
if (!branch) {
all_feasible = false;
set_all_feasible(all_feasible);
}
}
else { // !(all_feasible && (any_changed || any_transform_control))
DataDisplayLink[] links = getLinks();
for (int i=0; i
Ads help maintain this website.