[vtkusers] vtkVectorText or vtkFollower Bug

Randy Heiland heiland at ncsa.uiuc.edu
Thu Mar 21 07:09:45 EST 2002


Ahmed,

I don't have any problem with your code - the text gets displayed.  You didn't
indicate which version of VTK you're using.  Nor did you include your entire
Java pgm.  I'm using 4.0 and I attached the Java pgm I used to test this
(simply using /VTK/Wrapping/Java/SimpleVTK.java as a template).  Also, don't
forget to include:
    System.loadLibrary("vtkHybridJava");

in vtkPanel.java since that's where vtkVectorText is.  But I assume you would
have got an error otherwise.

--Randy



On Mar 21, 11:56am, ahmed Tokalak wrote:
> Subject: [vtkusers] vtkVectorText or vtkFollower Bug
> Hi Everybody,
>
> I use vtkVectorText to show text-labels but nothing is visible. Any idea?
This is my code:
>
> vtkVectorText atext = new vtkVectorText();
> atext.SetText("Test");
> vtkPolyDataMapper followMapper = new vtkPolyDataMapper();
> followMapper.SetInput(atext.GetOutput());
> vtkFollower followActor = new vtkFollower();
> followActor.SetMapper(followMapper);
> followActor.SetScale( 0.2, 0.2, 0.2);
> followActor.GetProperty().SetColor( 1, 0.2, 0.2);
> followActor.SetPosition(0, -0.2, 0);
>
> renderer.AddActor(followActor);
-------------- next part --------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import vtk.*;
import vtkPanel;

public class VText extends JPanel implements ActionListener {
    static JFrame frame;

    Button exitButton;

    public VText() {
	// Create the buttons.
	vtkPanel renWin = new vtkPanel();

        vtkVectorText atext = new vtkVectorText();
        atext.SetText("Test");
        vtkPolyDataMapper followMapper = new vtkPolyDataMapper();
        followMapper.SetInput(atext.GetOutput());
        vtkFollower followActor = new vtkFollower();
        followActor.SetMapper(followMapper);
        followActor.SetScale( 0.2, 0.2, 0.2);
        followActor.GetProperty().SetColor( 1, 0.2, 0.2);
        followActor.SetPosition(0, -0.2, 0);

//        renderer.AddActor(followActor);
        renWin.GetRenderer().AddActor(followActor);

        exitButton = new Button("Exit");
        exitButton.addActionListener(this);

	add(renWin);
	add(exitButton);
    }


    /** An ActionListener that listens to the radio buttons. */
    public void actionPerformed(ActionEvent e) 
    {
        if (e.getSource().equals(exitButton)) 
            {
                System.exit(0);
            }
    }

    public static void main(String s[]) 
    {
	VText panel = new VText();
	
	frame = new JFrame("VText");
	frame.addWindowListener(new WindowAdapter() 
            {
                public void windowClosing(WindowEvent e) {System.exit(0);}
            });
	frame.getContentPane().add("Center", panel);
	frame.pack();
	frame.setVisible(true);
    }
}


More information about the vtkusers mailing list