JavaTM 2D Sample Programs

These sample programs demonstrate new JavaTM 2D features available in the Java Development Kit, version 1.2 -- you will need to download JDKTM 1.2 to run these programs.

List of Sample Programs

Arcs & Curves
Arc2D Open, Chord, & Pie arcs; Animated Pie Arc. Source Applet Plugin
Animated Bezier Curve includes controls for changing graphic attributes. Source Applet Plugin
CubicCurve2D & QuadCurve2D curves includes FlatteningPathIterator example. Source Applet Plugin
Ellipse2D 25 animated expanding ellipses. Source Applet Plugin
Clipping
CAG (Constructive Area Geometry) operations : Add(union), Subtract, Intersect, and ExclusiveOR. Source Applet Plugin
Animated clipping of an image & composited shapes. Source Applet Plugin
Animated intersection clipping of lines, an image and a textured rectangle. Source Applet Plugin
Clipping an image, lines, and text with text. Source Applet Plugin
Colors
Animated colored balls bouncing. Source Applet Plugin
Creating colors with an alpha value. Source Applet Plugin
ColorConvertOp a ColorSpace.TYPE_RGB BufferedImage to a ColorSpace.CS_GRAY BufferedImage. Source Applet Plugin
3D objects with color & lighting translated, rotated and scaled. Source Applet Plugin
Composite
Compositing shapes on images. Source Applet Plugin
All the AlphaCompositing rules demonstrated. Source Applet Plugin
Animation of compositing shapes, text, and images fading in and out. Source Applet Plugin
Fonts
Scrolling text of fonts returned from GraphicsEnvironment.getAllFonts(). Source Applet Plugin
Build an AttributedString and then render the string broken over lines. Source Applet Plugin
Highlighting of text showing the caret, the highlight & the character advances. Source Applet Plugin
Rendering text as an outline shape. Source Applet Plugin
Transformation of characters. Source Applet Plugin
Image
Animated gif with a transparent background. Source Applet Plugin
Images drawn using operators such as ConvolveOp LowPass & Sharpen, LookupOp and RescaleOp. Source Applet Plugin
Render into a BufferedImage, save the BufferedImage as a JPEG, display the BufferedImage, using the decoded JPEG BufferedImage DataBuffer flip the elements, display the JPEG flipped BufferedImage. Source Applet Plugin
Warps a image on a CubicCurve2D flattened path. Source Applet Plugin
Lines
Various shapes stroked with a dashing pattern. Source Applet Plugin
Lines & Paths animation illustrating all of BasicStroke attributes. Source Applet Plugin
Modify a star's BasicStroke attributes. Source Applet Plugin
Paint
GradientPaint animation. Source Applet Plugin
GradientPaint burst effect, controls for different colors. Source Applet Plugin
TexturePaint of shapes, gradients and rgb values. Source Applet Plugin
Texture animation with controls for transformations. Source Applet Plugin
Paths
Simple append of rectangle to path with and without the connect. Source Applet Plugin
Cubic & Quad curves implemented through GeneralPath. Source Applet Plugin
Basic implementation of GeneralPath, filling & drawing a path. Source Applet Plugin
3D text shape with GeneralPath & a 300 of small multi-colored rectangles Source Applet Plugin
Rectangles filled to illustrate the GeneralPath winding rule, determining the interior of a path. Source Applet Plugin
Transforms
Simple 45 degree rotate of a rectangle. Source Applet Plugin
Scaling or Shearing or Rotating an image & rectangle. Source Applet Plugin
Animation of shapes, text and images rotating, scaling and translating around a canvas. Source Applet Plugin

Compiling the Sample Programs

You can compile the samples by changing to the sample program's directory and compiling the *.java files, e.g.

cd Arcs_Curves
javac *.java


(This assumes javac is in your executible path, and you are using JDK 1.2 or greater)

For your convenience, we have provided a script to compile all the samples -- execute compile.bat (for Windows) or compile.sh (for Solaris).

Running the Sample Programs

These sample programs are designed to run as standalone Java applications. To run them, you need to change to the sample program's directory and execute the java command on the class name, e.g.

cd Arcs_Curves
java Arcs


(This assumes java is in your executible path, and you are using JDK 1.2 or greater)

For your convenience, we have provided another script to run the samples -- execute run.bat (for Windows) or run.sh (for Solaris).

[an error occurred while processing this directive]