FileDocCategorySizeDatePackage
CustomStrokes.javaAPI DocExample7547Sat Jan 24 10:44:36 GMT 2004je3.graphics

CustomStrokes

public class CustomStrokes extends Object implements GraphicsExample
A demonstration of writing custom Stroke classes

Fields Summary
static final int
WIDTH
static final int
HEIGHT
Stroke[]
strokes
Constructors Summary
Methods Summary
public voiddraw(java.awt.Graphics2D g, java.awt.Component c)
Draw the example


        
          
	// Get a shape to work with.  Here we'll use the letter B
	Font f = new Font("Serif", Font.BOLD, 200);
	GlyphVector gv = f.createGlyphVector(g.getFontRenderContext(), "B");
	Shape shape = gv.getOutline();

	// Set drawing attributes and starting position
	g.setColor(Color.black);
	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
			   RenderingHints.VALUE_ANTIALIAS_ON);
	g.translate(10, 175);

	// Draw the shape once with each stroke
	for(int i = 0; i < strokes.length; i++) {
	    g.setStroke(strokes[i]);   // set the stroke
	    g.draw(shape);             // draw the shape
	    g.translate(140,0);        // move to the right
	}
    
public intgetHeight()

 return HEIGHT; 
public java.lang.StringgetName()

        // Size of our example
       return "Custom Strokes";
public intgetWidth()

 return WIDTH;