PickManiplulationRenderer Not Working


Greetings,

Sorry to disturb your weekend. I cannot seem to get a PickManiplulationRenderer to allow direct manipulation of my FlatField, however, if I use a DirectManipulationRenderer it works fine.

Please see the attached code.  In the line:

   display.addReferences( pmr, dataRef );

if you change "pmr" to "dmr" the direct manipulation behaves normaly, but when using "pmr" it does not. I thought that since PickManiplulationRenderer extended DirectManipulationRenderer, that it should behave the same way. It this correct? Is there something wrong in my code?

Many thanks!!

-kevin.

import java.*;
import javax.swing.*;
import javax.swing.event.*;

import java.awt.*;
import java.awt.event.*;

import visad.*;
import java.rmi.RemoteException;
import visad.java3d.*;
import visad.bom.PickManipulationRendererJ3D;

public class coordTest extends JPanel implements ActionListener
{

  private DisplayImpl display;
  private RealType rad, lon;
  private RealTupleType radLon_tt, lonRad_tt;
  private ScalarMap radMap, lonMap;
  private DataReferenceImpl dataRef;
  private DirectManipulationRendererJ3D dmr;
  private PickManipulationRendererJ3D pmr;
  private double[] projMatrix;
  private JButton reset = new JButton("Reset");


  public coordTest() throws VisADException, RemoteException
  {

    reset.addActionListener(this);

    rad = RealType.Radius;
    lon = RealType.Longitude;

    radLon_tt = new RealTupleType(rad, lon);

    radMap = new ScalarMap(rad, Display.Radius);
    lonMap = new ScalarMap(lon, Display.Longitude);


    display = new DisplayImplJ3D( "TextDisplay", new TwoDDisplayRendererJ3D() );
    display.addMap(radMap);
    display.addMap(lonMap);
    radMap.setRange(0.0, 5.0);
    lonMap.setRange(0.0, 359.99);

    ProjectionControl initPC = display.getProjectionControl();
    projMatrix = initPC.getMatrix();
    GraphicsModeControl gmc = display.getGraphicsModeControl();
    gmc.setScaleEnable(true);

    dataRef = new DataReferenceImpl("dataRef");
    dmr = new DirectManipulationRendererJ3D();
    pmr = new PickManipulationRendererJ3D();
    display.addReferences( pmr, dataRef );


    final int size = 20;
    double[][] rad_pts = new double[1][size];
    double[][] lon_pts = new double[1][size];
    for (int i = 0; i < size; ++i)
    {
      rad_pts[0][i] = i * (5.0/size/2.0);
      lon_pts[0][i] = 0.0;;
    }

    Gridded1DDoubleSet rad_set = new Gridded1DDoubleSet(rad, rad_pts, size);
    FunctionType func = new FunctionType(rad, lon);
    final FlatField ff = new FlatField(func, rad_set);
    ff.setSamples(lon_pts);
    dataRef.setData(ff);

    CellImpl cell = new CellImpl()
    {
      public void doAction() throws RemoteException, VisADException
      {

//System.out.println(pmr.getCloseIndex());
System.out.println(dataRef.getData());
/*
        if ( dare.get_any_changed() )
        {
          double[][] newlons = new double[1][size];
          java.util.Arrays.fill(newlons[0], dr.getDirectAxisValue(lon));
          ff.setSamples(newlons);
          dataRef.setData(ff);
        }
*/
      }
    };
    cell.addReference(dataRef);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setAlignmentY(JPanel.TOP_ALIGNMENT);
    setAlignmentX(JPanel.LEFT_ALIGNMENT);
    Component comp = display.getComponent();
    ((JComponent)comp).setPreferredSize( new Dimension(400,400) );


    add(comp);
    add(reset);

  }

  public void actionPerformed(ActionEvent e)
  { resetOrientation(); }


  /**
   * Resets the display projection to its original value.
   * Borrowed from VisAD SpreadSheet
   */
  public void resetOrientation() {
    if (display != null) {
      ProjectionControl pc = display.getProjectionControl();
      if (pc != null) {
        try {
          pc.setMatrix(projMatrix);
        }
        catch (VisADException exc) {
          System.out.println("Cannot reset orientation" + exc);
        }
        catch (RemoteException exc) {
          System.out.println("Cannot reset orientation" + exc);
        }
      }
    }
  }

  public static void main(String[] args) throws VisADException, RemoteException
  {
    JFrame frame = new JFrame("First VisAd Example");
    coordTest me = new coordTest();

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(me);
    frame.pack();
    frame.setVisible(true);
  }


  }


  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: