/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package visad.java3d;
import java.util.ArrayList;
import javax.media.j3d.Switch;
import visad.AVHandler;
/**
*
* @author rink
*/
public class TrajectoryAVHandlerJ3D implements AVHandler {
int numChildren;
int[] whichVisible;
int numVisible;
int direction;
java.util.BitSet bits;
Switch swit;
ArrayList<Integer> allOffBelow = new ArrayList<Integer>();
ArrayList<Integer> allOffAbove = new ArrayList<Integer>();
public TrajectoryAVHandlerJ3D(Switch swit, int numChildren, int[] whichVisible, int direction) {
this.swit = swit;
this.numChildren = numChildren;
this.whichVisible = whichVisible;
this.numVisible = whichVisible.length;
this.direction = direction;
this.bits = new java.util.BitSet(numChildren);
}
public void setWhichChild(int index) {
if (index == Switch.CHILD_NONE) {
bits.clear();
swit.setWhichChild(Switch.CHILD_NONE);
}
else if (index >= 0) {
bits.clear();
for (int t=0; t<whichVisible.length; t++) {
int k_set = index + whichVisible[t];
if (k_set >= 0) {
bits.set(k_set);
}
}
int offBelow = 0;
for (int k=0; k<allOffBelow.size(); k++) {
int idx = allOffBelow.get(k).intValue();
if (index >= idx) {
offBelow = idx;
}
}
if (offBelow > 0) {
bits.clear(0, offBelow);
}
/* TODO: not working
bits.set(0, numChildren-1);
int offAbove = 0;
for (int k=0; k<allOffAbove.size(); k++) {
int idx = allOffAbove.get(k).intValue();
if (index <= idx) {
offAbove = idx;
}
}
if (offAbove > 0) {
bits.clear(offAbove, numChildren-1);
}
*/
swit.setChildMask(bits);
}
}
public int getWindowSize() {
return numVisible;
}
public void setNoneVisibleIndex(int index) {
if (direction > 0) {
allOffBelow.add(index);
}
else {
// TODO: see above
}
}
}