FileDocCategorySizeDatePackage
Text.javaAPI DocApache Ant 1.703987Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.types.optional.image

Text

public class Text extends ImageOperation implements DrawOperation
see
org.apache.tools.ant.taskdefs.optional.image.Image

Fields Summary
private static final int
DEFAULT_POINT
private String
strText
private String
font
private int
point
private boolean
bold
private boolean
italic
private String
color
Constructors Summary
Methods Summary
public javax.media.jai.PlanarImageexecuteDrawOperation()
Draw the text.

return
the resultant image.

        log("\tCreating Text \"" + strText + "\"");

        Color couloir = ColorMapper.getColorByName(color);
        int width = 1;
        int height = 1;

        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE);
        Graphics2D graphics = (Graphics2D) bi.getGraphics();
        graphics.setRenderingHint(
            RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        graphics.setRenderingHint(
            RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
        Font f = new Font(font, Font.PLAIN, point);
        FontMetrics fmetrics = graphics.getFontMetrics(f);
        height = fmetrics.getMaxAscent() + fmetrics.getMaxDescent();
        width = fmetrics.stringWidth(strText);


        bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE);
        graphics = (Graphics2D) bi.getGraphics();

        graphics.setRenderingHint(
            RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        graphics.setRenderingHint(
            RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);

        graphics.setFont(f);
        graphics.setColor(couloir);
        graphics.drawString(strText, 0, height - fmetrics.getMaxDescent());
        PlanarImage image = PlanarImage.wrapRenderedImage(bi);
        return image;
    
public voidsetBold(boolean state)

todo
is this used?
param
state not used at the moment.

        bold = state;
    
public voidsetColor(java.lang.String c)
Set the color of the text.

param
c the color name.

        color = c;
    
public voidsetFont(java.lang.String f)
Set the font to be used to draw the text.

param
f the font to be used.

        font = f;
    
public voidsetItalic(boolean state)

todo
is this used?
param
state not used at the moment.

        italic = state;
    
public voidsetPoint(java.lang.String p)
Set the number of points to be used.

param
p an integer value as a string.

        point = Integer.parseInt(p);
    
public voidsetString(java.lang.String str)
Set the string to be used as text.

param
str the string to be used.


                        
        
        strText = str;