//
// ShadowAnimationFunctionTypeJ3D.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.java3d;
import visad.*;
import javax.media.j3d.*;
import java.util.Vector;
import java.rmi.*;
/**
The ShadowAnimationFunctionTypeJ3D class shadows the FunctionType class for
AnimationRendererJ3D, within a DataDisplayLink, under Java3D.
*/
public class ShadowAnimationFunctionTypeJ3D extends ShadowFunctionTypeJ3D {
private static final int MISSING1 = Byte.MIN_VALUE; // least byte
public ShadowAnimationFunctionTypeJ3D(MathType t, DataDisplayLink link,
ShadowType parent)
throws VisADException, RemoteException {
super(t, link, parent);
}
public boolean doTransform(Object group, Data data, float[] value_array,
float[] default_values, DataRenderer renderer)
throws VisADException, RemoteException {
DataDisplayLink link = renderer.getLink();
// return if data is missing or no ScalarMaps
if (data.isMissing()) {
((AnimationRendererJ3D) renderer).markMissingVisADBranch();
return false;
}
if (getLevelOfDifficulty() == NOTHING_MAPPED) return false;
ShadowFunctionOrSetType adaptedShadowType =
(ShadowFunctionOrSetType) getAdaptedShadowType();
DisplayImpl display = getDisplay();
// analyze data's domain (its a Field)
Set domain_set = ((Field) data).getDomainSet();
// ShadowRealTypes of Domain
ShadowRealType[] DomainComponents = adaptedShadowType.getDomainComponents();
//if (((AnimationRendererJ3D)renderer).animation1D &&
// domain_set.getDimension() == 1) {
if (((AnimationRendererJ3D)renderer).animation1D) {
Vector domain_maps = DomainComponents[0].getSelectedMapVector();
ScalarMap amap = null;
if (domain_set.getDimension() == 1 && domain_maps.size() == 1) {
ScalarMap map = (ScalarMap) domain_maps.elementAt(0);
if (Display.Animation.equals(map.getDisplayScalar())) {
amap = map;
}
}
if (amap == null) {
throw new BadMappingException("time must be mapped to Animation");
}
AnimationControlJ3D control = (AnimationControlJ3D) amap.getControl();
((AnimationRendererJ3D)renderer).animation1D = false;
// get any usable frames from the old scene graph
Switch old_swit = null;
BranchGroup[] old_nodes = null;
double[] old_times = null;
boolean[] old_mark = null;
int old_len = 0;
boolean reuse = ((AnimationRendererJ3D) renderer).getReUseFrames();
if (group instanceof BranchGroup &&
((BranchGroup) group).numChildren() > 0) {
Node g = ((BranchGroup) group).getChild(0);
// WLH 06 Feb 06 - support switch in a branch group.
if (g instanceof BranchGroup &&
((BranchGroup) g).numChildren() > 0) {
g = ((BranchGroup) g).getChild(0);
}
if (g instanceof Switch) {
old_swit = (Switch) g;
old_len = old_swit.numChildren();
if (old_len > 0) {
old_nodes = new BranchGroup[old_len];
for (int i=0; i 0)
// create frames for new scene graph
double[][] values = domain_set.getDoubles();
double[] times = values[0];
int len = times.length;
double delta = Math.abs((times[len-1] - times[0]) / (1000.0 * len));
// create new Switch and make live
// control.clearSwitches(this); // already done in DataRenderer.doAction
Switch swit = null;
if (old_swit != null) {
swit = old_swit;
((AVControlJ3D) control).addPair((Switch) swit, domain_set, renderer);
((AVControlJ3D) control).init();
}
else {
swit = (Switch) makeSwitch();
swit.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
swit.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
swit.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
addSwitch(group, swit, control, domain_set, renderer);
}
// insert old frames into new scene graph, and make
// new (blank) VisADBranchGroups for rendering new frames
VisADBranchGroup[] nodes = new VisADBranchGroup[len];
boolean[] mark = new boolean[len];
for (int i=0; i
Ads help maintain this website.