Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VTK Examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VTK
VTK Examples
Commits
946dc236
Commit
946dc236
authored
6 years ago
by
Andrew Maclean
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #398 from chakravarthi589/Update_TextActor
Update text actor
parents
9622cbbc
434cc97b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Java/GeometricObjects/TextActor.java
+36
-64
36 additions, 64 deletions
src/Java/GeometricObjects/TextActor.java
with
36 additions
and
64 deletions
src/Java/GeometricObjects/TextActor.java
+
36
−
64
View file @
946dc236
import
java.awt.BorderLayout
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
javax.swing.JButton
;
import
javax.swing.JFrame
;
import
javax.swing.JPanel
;
import
javax.swing.SwingUtilities
;
import
vtk.vtkNativeLibrary
;
import
vtk.vtkPanel
;
import
vtk.vtkRenderWindow
;
import
vtk.vtkRenderWindowInteractor
;
import
vtk.vtkRenderer
;
import
vtk.vtkTextActor
;
import
vtk.vtkNamedColors
;
public
class
TextActor
extends
JPanel
implements
ActionListener
{
private
static
final
long
serialVersionUID
=
1L
;
private
vtkPanel
renWin
;
private
JButton
exitButton
;
// -----------------------------------------------------------------
public
class
TextActor
{
//-----------------------------------------------------------------
// Load VTK library and print which library was not properly loaded
static
{
if
(!
vtkNativeLibrary
.
LoadAllNativeLibraries
())
{
for
(
vtkNativeLibrary
lib
:
vtkNativeLibrary
.
values
())
{
if
(!
lib
.
IsLoaded
())
{
static
{
if
(!
vtkNativeLibrary
.
LoadAllNativeLibraries
())
{
for
(
vtkNativeLibrary
lib
:
vtkNativeLibrary
.
values
())
{
if
(!
lib
.
IsLoaded
())
{
System
.
out
.
println
(
lib
.
GetLibraryName
()
+
" not loaded"
);
}
}
}
vtkNativeLibrary
.
DisableOutputWindow
(
null
);
}
// -----------------------------------------------------------------
//-----------------------------------------------------------------
public
TextActor
()
{
super
(
new
BorderLayout
());
public
static
void
main
(
String
s
[])
{
vtkNamedColors
Color
=
new
vtkNamedColors
();
//For Actor Color
double
ActorColor
[]
=
new
double
[
4
];
//For Renderer Background Color
double
Bg
C
olor
[]
=
new
double
[
4
];
double
Bg
c
olor
[]
=
new
double
[
4
];
//Change Color Name to Use your own Color for Change Actor Color
Color
.
GetColor
(
"Red"
,
ActorColor
);
//Change Color Name to Use your own Color for Renderer Background
Color
.
GetColor
(
"Black"
,
Bg
C
olor
);
Color
.
GetColor
(
"Black"
,
Bg
c
olor
);
vtkTextActor
Text
=
new
vtkTextActor
();
Text
.
SetInput
(
"Hello World"
);
Text
.
SetDisplayPosition
(
20
,
30
);
...
...
@@ -60,39 +49,22 @@ public class TextActor extends JPanel implements ActionListener {
Text
.
GetTextProperty
().
ShadowOn
();
Text
.
GetTextProperty
().
GetShadowOffset
();
Text
.
GetTextProperty
().
SetColor
(
ActorColor
);
renWin
=
new
vtkPanel
();
renWin
.
GetRenderer
().
AddActor
(
Text
);
renWin
.
resetCamera
();
renWin
.
GetRenderer
().
SetBackground
(
BgColor
);
// Add Java UI components
exitButton
=
new
JButton
(
"Exit"
);
exitButton
.
addActionListener
(
this
);
add
(
renWin
,
BorderLayout
.
CENTER
);
add
(
exitButton
,
BorderLayout
.
SOUTH
);
}
// Create the renderer, render window and interactor.
vtkRenderer
ren
=
new
vtkRenderer
();
vtkRenderWindow
renWin
=
new
vtkRenderWindow
();
renWin
.
AddRenderer
(
ren
);
vtkRenderWindowInteractor
iren
=
new
vtkRenderWindowInteractor
();
iren
.
SetRenderWindow
(
renWin
);
/** An ActionListener that listens to the button. */
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
e
.
getSource
().
equals
(
exitButton
))
{
System
.
exit
(
0
);
}
}
// Visualize the Actor
ren
.
AddActor
(
Text
);
ren
.
SetBackground
(
Bgcolor
);
public
static
void
main
(
String
s
[])
{
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
public
void
run
()
{
JFrame
frame
=
new
JFrame
(
"Text Actor"
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
getContentPane
().
setLayout
(
new
BorderLayout
());
frame
.
getContentPane
().
add
(
new
TextActor
(),
BorderLayout
.
CENTER
);
frame
.
setSize
(
400
,
400
);
frame
.
setLocationRelativeTo
(
null
);
frame
.
setVisible
(
true
);
}
});
renWin
.
SetSize
(
300
,
300
);
renWin
.
Render
();
iren
.
Initialize
();
iren
.
Start
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment