FileDocCategorySizeDatePackage
InlineGraphics.javaAPI DocExample1656Mon Apr 05 10:25:10 BST 1999None

InlineGraphics

public class InlineGraphics extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    Frame f = new ApplicationFrame("InlineGraphics v1.0") {
      public void paint(Graphics g) {
        Graphics2D g2 = (Graphics2D)g;

        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
        Font serifFont = new Font("Serif", Font.PLAIN, 32);
                
        AttributedString as = new AttributedString("Star \ufffc pin");
        as.addAttribute(TextAttribute.FONT, serifFont);
        
        String filename = "roa2.jpg";
        Image image = new javax.swing.ImageIcon(filename).getImage();
        ImageGraphicAttribute imageAttribute = new ImageGraphicAttribute(
            image, GraphicAttribute.TOP_ALIGNMENT);
        as.addAttribute(TextAttribute.CHAR_REPLACEMENT,
            imageAttribute, 5, 6);
        g2.drawString(as.getIterator(), 20, 120);
        
        as = new AttributedString("Red \ufffc circle");
        as.addAttribute(TextAttribute.FONT, serifFont);
        
        Shape shape = new Ellipse2D.Float(0, -25, 25, 25);
        ShapeGraphicAttribute shapeAttribute = new ShapeGraphicAttribute(
            shape, GraphicAttribute.ROMAN_BASELINE,
            ShapeGraphicAttribute.STROKE);
        as.addAttribute(TextAttribute.CHAR_REPLACEMENT,
            shapeAttribute, 4, 5);
        as.addAttribute(TextAttribute.FOREGROUND, Color.red, 4, 5);
        g2.drawString(as.getIterator(), 20, 200);
      }
    };
    f.setVisible(true);