Hi Mathias,
> Thanks for your efforts. I looked into your code and could not find any
> problem. But when I changed the
> RealType range = new RealType("range");
> to
> RealType range = RealType.Altitude;
> and the
> display.addMap(new ScalarMap(range, Display.Green));
> to
> display.addMap(new ScalarMap(range, Display.ZAxis));
> and changed the DisplayImplJ2D into a DisplayImplJ3D I get obviously wrong
> results. Please look into the attached code.
The problem is that the Linear2DSet only has length = 2 along the
Longitude axis, so the edges of this polygon span the entire span
from -180 to +180. Unfortunately, this is the criterion used by code
designed to avoid map segments (and polygons) that wrap all the way
around the earth because they cross the date line. You can fix it
by subdividing the segment into shorter segments, as in the attached
Junk.java (note length = 3 didn't work, so the criterion for long
lines or polygon edges must not be the entire 360 degree span).
This is pretty unavoidable, since the system needs to use some sort
of criterion to automatically detect and fix errant map segments
and polygons.
> I need the ConstantMaps to fix the Handle-Positions along the x-/y-Axis:
>
> Real[] slider = new Real[3];
> . . .
I see. I think the problem you originally described is because
the autoscaling includes these drag points and hence always
sizes the box to fit them (the drag points must lie outside
the bounds of your data). You can fix it by explicit calls to
ScalarMap.setRange() for your ScalarMaps to XAxis and YAxis.
Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI 53706
hibbard@xxxxxxxxxxxxxxxxx 608-263-4427 fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html
// import needed classes
import visad.*;
import visad.java3d.DisplayImplJ3D;
import visad.java2d.DisplayImplJ2D;
import visad.util.VisADSlider;
import visad.data.netcdf.Plain;
import java.rmi.RemoteException;
import java.io.IOException;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Junk {
// type 'java Junk' to run this application
public static void main(String args[])
throws VisADException, RemoteException, IOException {
RealTupleType earth
new RealTupleType(RealType.Longitude, RealType.Latitude);
Linear2DSet region = new Linear2DSet(earth, -180.0, 180.0, 4, -90.0, 90.0,
4);
RealType range = RealType.Altitude;
FunctionType ftype = new FunctionType(earth, range);
FlatField field = new FlatField(ftype, region);
field.setSamples(new float[][] {{0.0f, 0.17f, 0.33f, 0.5f,
0.17f, 0.33f, 0.5f, 0.67f,
0.33f, 0.5f, 0.67f, 0.83f,
0.5f, 0.67f, 0.83f, 1.0f}});
// create a DataReference for region
final DataReference region_ref = new DataReferenceImpl("region");
// region_ref.setData(region);
region_ref.setData(field);
// create a Display using Java3D
// DisplayImpl display = new DisplayImplJ3D("image display");
// create a Display using Java2D
DisplayImpl display = new DisplayImplJ3D("image display");
// map earth coordinates to display coordinates
display.addMap(new ScalarMap(RealType.Longitude, Display.XAxis));
display.addMap(new ScalarMap(RealType.Latitude, Display.YAxis));
display.addMap(new ScalarMap(range, Display.ZAxis));
GraphicsModeControl mode = display.getGraphicsModeControl();
mode.setScaleEnable(true);
// link the Display to region_ref
display.addReference(region_ref);
// create JFrame (i.e., a window) for display and slider
JFrame frame = new JFrame("Junk VisAD Application");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
});
// create JPanel in JFrame
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.setAlignmentY(JPanel.TOP_ALIGNMENT);
panel.setAlignmentX(JPanel.LEFT_ALIGNMENT);
frame.getContentPane().add(panel);
// add display to JPanel
panel.add(display.getComponent());
// set size of JFrame and make it visible
frame.setSize(500, 500);
frame.setVisible(true);
}
}