Search in sources :

Example 1 with HwmfHatchStyle

use of org.apache.poi.hwmf.record.HwmfHatchStyle in project poi by apache.

the class HwmfGraphics method getHatchedFill.

protected Paint getHatchedFill() {
    int dim = 7, mid = 3;
    BufferedImage bi = new BufferedImage(dim, dim, BufferedImage.TYPE_4BYTE_ABGR);
    Graphics2D g = bi.createGraphics();
    Color c = (prop.getBkMode() == HwmfBkMode.TRANSPARENT) ? new Color(0, true) : prop.getBackgroundColor().getColor();
    g.setColor(c);
    g.fillRect(0, 0, dim, dim);
    g.setColor(prop.getBrushColor().getColor());
    HwmfHatchStyle h = prop.getBrushHatch();
    if (h == HwmfHatchStyle.HS_HORIZONTAL || h == HwmfHatchStyle.HS_CROSS) {
        g.drawLine(0, mid, dim, mid);
    }
    if (h == HwmfHatchStyle.HS_VERTICAL || h == HwmfHatchStyle.HS_CROSS) {
        g.drawLine(mid, 0, mid, dim);
    }
    if (h == HwmfHatchStyle.HS_FDIAGONAL || h == HwmfHatchStyle.HS_DIAGCROSS) {
        g.drawLine(0, 0, dim, dim);
    }
    if (h == HwmfHatchStyle.HS_BDIAGONAL || h == HwmfHatchStyle.HS_DIAGCROSS) {
        g.drawLine(0, dim, dim, 0);
    }
    g.dispose();
    return new TexturePaint(bi, new Rectangle(0, 0, dim, dim));
}
Also used : TexturePaint(java.awt.TexturePaint) Color(java.awt.Color) Rectangle(java.awt.Rectangle) HwmfHatchStyle(org.apache.poi.hwmf.record.HwmfHatchStyle) TexturePaint(java.awt.TexturePaint) Paint(java.awt.Paint) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Aggregations

Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 Paint (java.awt.Paint)1 Rectangle (java.awt.Rectangle)1 TexturePaint (java.awt.TexturePaint)1 BufferedImage (java.awt.image.BufferedImage)1 HwmfHatchStyle (org.apache.poi.hwmf.record.HwmfHatchStyle)1