//
// TrackManipulation.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.bom;
import visad.*;
import visad.java3d.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.rmi.*;
/**
TrackManipulation is the VisAD class for direct
manipulation rendering of storm tracks under Java3D
*/
public class TrackManipulation extends Object {
private DisplayImplJ3D display;
private DataReference track1_ref;
private DataReference track2_ref;
private DataReference track3_ref;
private RealTupleType latlonshape = null;
private ScalarMap latmap = null;
private ScalarMap lonmap = null;
private CoordinateSystem coord = null;
private int latindex = -1;
private int lonindex = -1;
private int otherindex = -1;
private float othervalue = 0.0f;
private ScalarMap shapemap = null;
private ShapeControl shapecontrol = null;
private float x_size;
private float y_size;
private float angle;
private static int NE = 32;
private float[] x_ellipse = new float[NE + 1];
private float[] y_ellipse = new float[NE + 1];
/** (lat1, lon1) start of track
(lat2, lon2) end of track
d is a DisplayImplJ3D that has ScalarMaps of Latitude and
Longitude but is not linked yet to any DataReferences;
this constructor will add another ScalarMap to Shape and
link the DisplayImplJ3D d to three data objects, two by
direct manipulation */
public TrackManipulation(float lat1, float lon1, float lat2, float lon2,
DisplayImplJ3D d, float xs, float ys, float ang)
throws VisADException, RemoteException {
// construct RealTuple objects to be manipulated at ends of track
RealTupleType latlon =
new RealTupleType(RealType.Latitude, RealType.Longitude);
RealTuple track1 = new RealTuple(latlon, new double[] {lat1, lon1});
RealTuple track2 = new RealTuple(latlon, new double[] {lat2, lon2});
// construct RealTuple with RealType mapped to Shape that
// creates storm track depiction
RealType shape = RealType.getRealType("shape");
latlonshape =
new RealTupleType(RealType.Latitude, RealType.Longitude, shape);
RealTuple track3 = new RealTuple(latlonshape, new double[] {lat1, lon1, 0.0});
// construct DataReferences for these three RealTuples
track1_ref = new DataReferenceImpl("track1_ref");
track2_ref = new DataReferenceImpl("track2_ref");
track3_ref = new DataReferenceImpl("track3_ref");
track1_ref.setData(track1);
track2_ref.setData(track2);
track3_ref.setData(track3);
// copy reference to DisplayImplJ3D
display = d;
// compute basic ellipse shape according to constructor
// arguments
x_size = (float) Math.abs(xs);
y_size = (float) Math.abs(ys);
angle = ang;
float sa = (float) Math.sin(ang * Data.DEGREES_TO_RADIANS);
float ca = (float) Math.cos(ang * Data.DEGREES_TO_RADIANS);
for (int i=0; i lim) nsteps = lim;
float xstep = xdir / nsteps;
float ystep = ydir / nsteps;
// compute which ellipse points are 'outside' previous
// ellipse (and hence visible)
boolean[] outside = new boolean[NE + 1];
for (int i=0; i radius);
}
// construct geometry for visible points of one ellipse
float[] xe = new float[2 * NE];
float[] ye = new float[2 * NE];
int ne = 0;
for (int i=0; i
Ads help maintain this website.