KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thoughtriver > open > vectorvisuals > example > fundamental > HelloWorld


1 /*
2  * HelloWorld.java
3  *
4  * Created on 2 August 2004, 01:05
5  */

6
7 package com.thoughtriver.open.vectorvisuals.example.fundamental;
8
9 import java.awt.*;
10 import java.awt.geom.*;
11
12 import javax.swing.*;
13
14 import com.thoughtriver.open.vectorvisuals.*;
15
16 /**
17  * This small application illustrates how to create a Vector Visuals drawing
18  * area (a <CODE>VVDisplay</CODE>) and place an object on it.
19  *
20  * @author Brandon Franklin
21  * @version $Date: 2006/11/25 09:35:06 $
22  */

23 public class HelloWorld implements Runnable JavaDoc {
24
25     /** The <CODE>VVDisplay</CODE> used to display the test */
26     private VVDisplay vvDisplay = null;
27
28     /**
29      * Creates a new instance of <CODE>HelloWorld</CODE>.
30      */

31     public HelloWorld() {
32         vvDisplay = new VVDisplay(new VVPanel());
33     }
34
35     /**
36      * Starts the example.
37      */

38     public void run() {
39         JFrame frame = new JFrame("Vector Visuals Hello World Example");
40         frame.setSize(640, 480);
41         frame.getContentPane().setLayout(new BorderLayout());
42         frame.getContentPane().add(vvDisplay.getViewPane(), BorderLayout.CENTER);
43         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
44
45         frame.setVisible(true);
46
47         // Set up the panel itself
48
vvDisplay.getViewPane().setBackground(Color.DARK_GRAY);
49         vvDisplay.setWorldViewScale(1);
50
51         // Create a text object reading "Hello, World!"
52
Brush brush = new Brush(Color.YELLOW, null, null);
53         VisualTextObject textObj = new VisualTextObject("Hello, World!", null, null, brush);
54
55         // Set the location and size of the object
56
AffineTransform transform = textObj.getTransform();
57         transform.scale(6.0, 6.0);
58         transform.translate(15, 40);
59         textObj.setTransform(transform);
60
61         // Display the object on the VVPanel
62
vvDisplay.addObject(textObj);
63     }
64
65     /**
66      * Instantiates a <CODE>HelloWorld</CODE> and executes it.
67      *
68      * @param args the command line arguments, ignored here
69      */

70     public static void main(final String JavaDoc[] args) {
71         Runnable JavaDoc example = new HelloWorld();
72         example.run();
73     }
74
75 }
76
Popular Tags