/*
 * 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;

import java.util.ArrayList;
import java.rmi.RemoteException;
import javax.media.j3d.*;


public class FixGeomSizeAppearance implements ControlListener {

  /**  */
  ArrayList FSTarray = new ArrayList();

  /**  */
  ProjectionControl p_cntrl = null;

  /**  */
  double last_scale;

  /**  */
  protected double first_scale = Double.NaN;
  
  double baseScale = Double.NaN;
  
  double rescaleThreshold = 1.15;

  /**  */
  int cnt = 0;
  
  VisADGeometryArray array;
  
  Object topBranch;
  
  ArrayList anchors;
  
  protected ShadowType shadow;
  
  GraphicsModeControl mode;
  
  float constant_alpha;
  
  float[] constant_color;
  
  private boolean locked = false;
  
  MouseBehavior mouseBehav;
  
  /**
   *
   *
   * @param p_cntrl
   */
  public FixGeomSizeAppearance(ProjectionControl p_cntrl, ShadowType shadow, MouseBehavior mouseBehav) {
    this.p_cntrl = p_cntrl;
    this.shadow = shadow;
    this.mouseBehav = mouseBehav;
    double[] matrix = p_cntrl.getMatrix();
    double[] rot_a = new double[3];
    double[] trans_a = new double[3];
    double[] scale_a = new double[1];
    mouseBehav.instance_unmake_matrix(rot_a, scale_a, trans_a, matrix);
    last_scale = scale_a[0];
    first_scale = last_scale;
  }

  /**
   *
   *
   * @param e
   *
   * @throws RemoteException
   * @throws VisADException
   */
  public synchronized void controlChanged(ControlEvent e)
      throws VisADException, RemoteException {
    if (locked) {
       return;
    }
    update();
  }
  
  public void update() throws VisADException {
    double[] matrix = p_cntrl.getMatrix();
    double[] rot_a = new double[3];
    double[] trans_a = new double[3];
    double[] scale_a = new double[1];

    mouseBehav.instance_unmake_matrix(rot_a, scale_a, trans_a, matrix);

    // - identify scale change events.
    if (!visad.util.Util.isApproximatelyEqual(scale_a[0], last_scale)) {
      if (scale_a[0] / last_scale > rescaleThreshold || scale_a[0] / last_scale < 1 / rescaleThreshold) {
        for (int k=0; k anchors, GraphicsModeControl mode, float constant_alpha, float[] constant_color) 
       throws VisADException {
    throw new VisADException("rescaleAndReplace unimplemented");
  }
  
  public void add(Object branch, VisADGeometryArray array, ArrayList anchors, GraphicsModeControl mode, float constant_alpha, float[] constant_color) {
     Info info = new Info();
     info.branch = branch;
     info.array = array;
     info.anchors = anchors;
     info.mode = mode;
     info.constant_alpha = constant_alpha;
     info.constant_color = constant_color;
     FSTarray.add(info);
  }
  
  public synchronized void lock() {
     locked = true;
  }
  
  public synchronized void unlock() {
     locked = false;
  }
  
  public boolean isLocked() {
     return locked;
  }
}

class Info {
   Object branch;
   VisADGeometryArray array;
   ArrayList anchors;
   GraphicsModeControl mode;
   float constant_alpha;
   float[] constant_color;
}

 
 

Ads help maintain this website.