Forwarded mail.... PickManipulationRenderer

Hi Isaak,

I am not sure. Maybe your code did not make it to the list. So I am
forwarding your e-mail.
I did not use the PickManipulationRenderer myself, so I can't help you.

Desiree

oooooooooooooooooooooooooooooooooooooooooooooooo
Desiree Hilbring

Institut fuer Photogrammetrie und Fernerkundung  
Universitaet Karlsruhe, Germany
email: hilbring@xxxxxxxxxxxxxxxxxxxx             
# 0721 6083676                                   
oooooooooooooooooooooooooooooooooooooooooooooooo


---------- Forwarded message ----------
Date: Sat, 10 Aug 2002 03:36:23 -0400
From: "Brobbey,Isaac" <IBBrobbey@xxxxxxxxxxxxxxx>
To: "'hilbring@xxxxxxxxxxxxxxxxxxxx'" <hilbring@xxxxxxxxxxxxxxxxxxxx>


hello: 
I have a little problem with the PickManipulationRendererJ3D and the range
selection, the attached code compiles and runs fine, but the only problem is
that, at run time, when i enter a  range value it doesnt work as it is
supposed to.Secondly the PickManipulationRendererJ3D cannot pick any sample
when i right click.

Is it because i try to add two data references to the display ? i am
confused here. The "spikes" in the display corresponds to the ratio values
in the file flatxx.txt, so i expect that when i right click, the
PickManipulationRendererJ3D should execute the getClosedIndex()method and
pick the corresponding sample, but it is not happening. i am not sure if i
am doing something wrong since i am "new" to visad, i dont have much
experience with visad.I have spent about three days trying to find it out,

but from the top-level, i think the doAction() method in the cellImpl()
method is not working but i dont really know what i am missing in the code,
and i will be glad to know any workaround. I appreciate your time and hope
to hear from you very soon.

Isaac 
Center for Vascular Biology 

code// 
import javax.swing.JFrame; 
import visad.*; 
import visad.java3d.DisplayImplJ3D; 
import visad.util.*; 
import java.awt.*; 
import javax.swing.*; 
import java.awt.event.*; 
import java.rmi.RemoteException; 
import visad.bom.PickManipulationRendererJ3D; 
import visad.java3d.DirectManipulationRendererJ3D; 
import visad.data.text.TextAdapter; 
import java.io.BufferedWriter.*; 
import java.io.FileOutputStream; 
import java.io.FilePermission; 
import java.io.*; 
import java.util.Vector; 
import java.util.Iterator; 
import java.util.StringTokenizer; 

public class Spikesxx //implements ActionListener 
{ 

  // number of spikes along X axis 
  private static final int NUM_SPIKES_X = 5; 

  // number of spikes along Y axis 
  private static final int NUM_SPIKES_Y = 5; 

  // increase density value to make spikes "thinner" 
  // decrease density value to make spikes "thicker" 
  private static final int DENSITY = 5; 

  private static final int MAX_HEIGHT = 100; 
  
  // The RangeWidget 

  private static RangeWidget ranWid; 

public static String Name=null; 
public  static double Pi; 
public  static double ratiox=0; 
public  static double massx; 
  
 public static Vector sue; 
  
 public static double bex; 
  
 public static Double lex; 

  public static void main(String[] args) throws Exception 
  { 
    Integer2DSet set = new Integer2DSet( 
      DENSITY * NUM_SPIKES_X, DENSITY * NUM_SPIKES_Y); 
    RealType xtype = RealType.getRealType("x"); 
    RealType ytype = RealType.getRealType("y"); 
    RealType ratio = RealType.getRealType("ratio"); 
    FunctionType type = new FunctionType( 
      new RealTupleType(xtype, ytype), ratio); 
    FlatField field = new FlatField(type, set); 
        final FieldImpl fieldx = 
      (FieldImpl) new TextAdapter("flat54xe.txt").getData(); 
        
                   
         int i=-1;               
    double[][] samples = 
      new double[1][DENSITY * NUM_SPIKES_X * DENSITY * NUM_SPIKES_Y]; 
    for (int y=0; y<DENSITY * NUM_SPIKES_Y; y++) 
    { 
      for (int x=0; x<DENSITY * NUM_SPIKES_X; x++) 
       { 
        int ndx = y * DENSITY * NUM_SPIKES_X + x; 
        if (x % DENSITY == 0 && y % DENSITY == 0 ) 
        { 
                            i+=1; 
            Tuple data = (Tuple)fieldx.getSample(i); 
            System.out.println("Ratio = " +
((Real)data.getComponent(0)).getValue()+ ", "); 
                samples[0][ndx] =((Real)data.getComponent(0)).getValue(); 
                 //else samples[0][ndx] =0;        } 
        else samples[0][ndx]
=-1*Math.random();//((Double)sue.get()).doubleValue(); 
       
        } 
        
      
    } 
    field.setSamples(samples); 

    DisplayImplJ3D display = new DisplayImplJ3D("display"); 

    
   // display.getGraphicsModeControl().setTextureEnable(false); 
    GraphicsModeControl gmc = display.getGraphicsModeControl(); 
    //gmc.setPointSize(5.0f); 
    gmc.setTextureEnable(false); 
    gmc.setScaleEnable(true); 
  
        //freeze the screen 
        ScalarMap xmap0=new ScalarMap(xtype, Display.XAxis); 
        xmap0.getAxisScale().setScreenBased(false); 
    display.addMap(xmap0); 
    display.addMap(new ScalarMap(ytype, Display.YAxis)); 
    display.addMap(new ScalarMap(ratio, Display.ZAxis)); 
    display.addMap(new ScalarMap(ratio, Display.RGB)); 
    
    
    // This is NEW! 
    // Create a RangeWidget with the ScalarMap timeMap 
    java.util.Vector mapVector = display.getMapVector(); 
    final int numMaps = mapVector.size(); 
     ScalarMap map1color = (ScalarMap )mapVector.elementAt(numMaps-1); 
     JPanel panel = new JPanel(); 
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); 
    panel.add(new LabeledColorWidget(map1color)); 




    ranWid = new RangeWidget(new ScalarMap(xtype, Display.XAxis)); 
    
   

    DataReferenceImpl ref = new DataReferenceImpl("ref"); 
     DataReferenceImpl refx = new DataReferenceImpl("refx"); 
  final PickManipulationRendererJ3D pmr3d = new
PickManipulationRendererJ3D(); 
    ref.setData(field); 
    refx.setData(fieldx); 
    display.addReference(ref); 
    display.addReferences(pmr3d,refx); 
    //cellImpl computation and data retrieval 
       CellImpl cellfield2d = new CellImpl() 
    { 
      private boolean nice = true; 
      public void doAction() throws VisADException,RemoteException 
      { 
        if (nice) nice = false; 
        else { 
          int i = pmr3d.getCloseIndex(); 
          System.out.println("i="+i); 
          //System.out.println("3-D Field picked, index = " + i); 
          //System.out.println("value = " + field.getSample(i)); 
          Tuple data = (Tuple)fieldx.getSample(i); 
          Set domainSet = fieldx.getDomainSet(); 
          float[][] values = domainSet.indexToValue(new int[] { i }); 
                  } 
      } 
    }; 
    cellfield2d.addReference(refx); 

    
    //create a panel and add your buttons 
    
    
    JFrame frame = new JFrame("Protein-Spikes,neuron(cvb)  Isaac"); 
    //frame.getContentPane().setLayout(new GridLayout(1,2) ); 
    //frame.getContentPane().add("South",subViewOne()); 
    //frame.getContentPane().setLayout(new FlowLayout()); 
    frame.getContentPane().add(display.getComponent()); 
    
    // make a panel 
    JPanel big_panel = new JPanel(); 
    big_panel.setLayout(new BorderLayout()); 
    big_panel.add("Center", ranWid); 
    big_panel.add("South", subViewOne()); 
    big_panel.add("North", panel); 

    // Add the RangeWidget to the frame 
    JFrame jframe2=new JFrame("Protein-Spikes Controls,neuron(cvb)
copyright*2002 Isaac"); 
    
        jframe2.setContentPane(big_panel); 
    jframe2.pack(); 
    jframe2.setVisible(true); 

    //frame.getContentPane().add(ranWid ); 
    frame.setSize(600, 500); 
   Util.centerWindow(frame); 
    frame.setVisible(true); 
  } 
   

        private static JPanel subViewOne() 
     {  
       JButton A; 
     JPanel main = new JPanel(); 
     main.setLayout(new FlowLayout(FlowLayout.LEFT,5,5)); 
     ImageIcon buttonx; 
     buttonx = new ImageIcon("screen.JPEG"); 
     A=new JButton("select range",buttonx); 
    // A.addActionListener(this); 
     //main.addButtons("Images/"); 
     //homeButton.addActionListener(this); 
     main.add(A); 
     //main.add(widgetPanel); 
          return main; 
     }    
     
     
     public static  void actionPerformed (java.awt.event.ActionEvent e) 
          {  
          
            String  aix = e.getActionCommand(); 
            if(aix.equals("")) 
                    { 
                        ; 
                    } 
                  } 




                
} 
//data file flatxx.txt 
(isotopicMass, pi) -> (Ratio,name(Text)) 
Ratio, isotopicMass, pi,name(Text) 
69 22100 2 "ACTIN23w_HUMAN" 
20 22100 1.5 "ACTIN_HUMAN" 
90 22100 2.5 "ACTIN_HUMAN" 
79 12100 1.5 "ACTIN2xf_HUMAN" 
50 12100 1 "ACTIN_HUMAN" 
10 12100 3 "ACTIN_HUMAN" 

  

  


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