FileDocCategorySizeDatePackage
Caps.javaAPI DocExample2739Wed Aug 08 15:13:48 BST 2001demos.Lines

Caps

public class Caps extends Surface
Shows the three different styles of stroke ending.

Fields Summary
private static int[]
cap
private static String[]
desc
Constructors Summary
public Caps()



      
        setBackground(Color.white);
    
Methods Summary
public static voidmain(java.lang.String[] s)

        createDemoFrame(new Caps());
    
public voidrender(int w, int h, java.awt.Graphics2D g2)

        FontRenderContext frc = g2.getFontRenderContext();
        Font font = g2.getFont();
        g2.setColor(Color.black);
        for (int i=0; i < 3; i++) {
            g2.setStroke(new BasicStroke(15, cap[i], BasicStroke.JOIN_MITER));
            g2.draw(new Line2D.Float(w/4,(i+1)*h/4,w-w/4,(i+1)*h/4));
            TextLayout tl = new TextLayout(desc[i], font, frc);
            tl.draw(g2,(float)(w/2-tl.getBounds().getWidth()/2),(i+1)*h/4-10);
        }