FileDocCategorySizeDatePackage
PPGraphics2D.javaAPI DocApache Poi 3.0.116715Thu May 31 18:45:28 BST 2007org.apache.poi.hslf.model

PPGraphics2D

public class PPGraphics2D extends Graphics2D
Translates Graphics2D calls into PowerPoint.
author
Yegor Kozlov

Fields Summary
private ShapeGroup
group
private AffineTransform
transform
private Stroke
stroke
private Paint
paint
private Font
font
private Color
foreground
private Color
background
private Shape
clip
int
count
Constructors Summary
public PPGraphics2D(ShapeGroup group)
Construct Java Graphics object which translates graphic calls in ppt drawing layer.

param
group The shape group to write the graphics calls into.

                                          
      
        this.group = group;
        transform = new AffineTransform();
    
Methods Summary
public voidaddRenderingHints(java.util.Map map)

        throw new HSLFException("Not implemented");
    
public voidclearRect(int x, int y, int width, int height)

        throw new HSLFException("Not implemented");
    
public voidclip(java.awt.Shape shape)

        this.clip = transform.createTransformedShape(shape);
        //update size of the escher group which holds the drawing
        group.setAnchor(clip.getBounds());
    
public voidclipRect(int x, int y, int width, int height)

        throw new HSLFException("Not implemented");
    
public voidcopyArea(int x, int y, int width, int height, int dx, int dy)

        throw new HSLFException("Not implemented");
    
public java.awt.Graphicscreate()

        throw new HSLFException("Not implemented");
    
public voiddispose()

        throw new HSLFException("Not implemented");
    
public voiddraw(java.awt.Shape shape)

        if(clip != null) {
            java.awt.Rectangle bounds = getTransform().createTransformedShape(shape).getBounds();
            if (bounds.width == 0) bounds.width = 1;
            if (bounds.height == 0) bounds.height = 1;
            if (!clip.getBounds().contains(bounds)) {
                return;
            }
        }

        PathIterator it = shape.getPathIterator(transform);
        double[] prev = null;
        double[] coords = new double[6];
        double[] first = new double[6];
        if(!it.isDone()) it.currentSegment(first); //first point
        while(!it.isDone()){
            int type = it.currentSegment(coords);
            if (prev != null ){
                Line line = new Line(group);
                if (stroke instanceof BasicStroke){
                    BasicStroke bs = (BasicStroke)stroke;
                    line.setLineWidth(bs.getLineWidth());
                    float[] dash = bs.getDashArray();
                    if (dash != null) line.setLineDashing(Line.PEN_DASH);
                }
                if(getColor() != null) line.setLineColor(getColor());
                if (type == PathIterator.SEG_LINETO) {
                    line.setAnchor(new java.awt.Rectangle((int)prev[0],  (int)prev[1], (int)(coords[0] - prev[0]), (int)(coords[1] - prev[1])));
                } else if (type == PathIterator.SEG_CLOSE){
                    line.setAnchor(new java.awt.Rectangle((int)coords[0],  (int)coords[1], (int)(first[0] - coords[0]), (int)(first[1] - coords[1])));
                }
                group.addShape(line);
            }
            prev = new double[]{coords[0],  coords[1]};
            it.next();
        }

    
public voiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle)

        throw new HSLFException("Not implemented");
    
public voiddrawGlyphVector(java.awt.font.GlyphVector g, float x, float y)

        throw new HSLFException("Not implemented");

    
public booleandrawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)

        throw new HSLFException("Not implemented");
    
public booleandrawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)

        throw new HSLFException("Not implemented");
    
public booleandrawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer)

        throw new HSLFException("Not implemented");
    
public booleandrawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)

        throw new HSLFException("Not implemented");
    
public booleandrawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)

        throw new HSLFException("Not implemented");
    
public booleandrawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)

        throw new HSLFException("Not implemented");
    
public voiddrawImage(java.awt.image.BufferedImage bufferedimage, java.awt.image.BufferedImageOp op, int x, int y)

        throw new HSLFException("Not implemented");
    
public booleandrawImage(java.awt.Image image, java.awt.geom.AffineTransform affinetransform, java.awt.image.ImageObserver imageobserver)

        throw new HSLFException("Not implemented");
    
public voiddrawLine(int x1, int y1, int x2, int y2)

        Line line = new Line();
        line.setAnchor(new java.awt.Rectangle(x1, y1, x2-x1, y2-y1));
        if (stroke instanceof BasicStroke){
            BasicStroke bs = (BasicStroke)stroke;
            line.setLineWidth(bs.getLineWidth());
        }
        if(getColor() != null) line.setLineColor(getColor());
        group.addShape(line);
    
public voiddrawOval(int x, int y, int width, int height)

        AutoShape ellipse = new AutoShape(ShapeTypes.Ellipse);
        ellipse.setAnchor(new java.awt.Rectangle(x-width/2, y-height/2, width, height));
        if (stroke instanceof BasicStroke){
            BasicStroke bs = (BasicStroke)stroke;
            ellipse.setLineWidth(bs.getLineWidth());
        }
        if(getColor() != null) ellipse.setLineColor(getColor());
        if (paint instanceof Color){
            Color color = (Color)paint;
            ellipse.setFillColor(color);
        }

        group.addShape(ellipse);
    
public voiddrawPolygon(int[] xPoints, int[] yPoints, int nPoints)

        throw new HSLFException("Not implemented");
    
public voiddrawPolyline(int[] xPoints, int[] yPoints, int nPoints)

        throw new HSLFException("Not implemented");
    
public voiddrawRenderableImage(java.awt.image.renderable.RenderableImage renderableimage, java.awt.geom.AffineTransform affinetransform)

        throw new HSLFException("Not implemented");
    
public voiddrawRenderedImage(java.awt.image.RenderedImage renderedimage, java.awt.geom.AffineTransform affinetransform)

        throw new HSLFException("Not implemented");
    
public voiddrawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)

        throw new HSLFException("Not implemented");
    
public voiddrawString(java.lang.String string, float x, float y)

         TextBox txt = new TextBox(group);
         txt.getTextRun().supplySlideShow(group.getSheet().getSlideShow());
         txt.getTextRun().setSheet(group.getSheet());
         txt.setText(string);

         RichTextRun rt = txt.getTextRun().getRichTextRuns()[0];
         rt.setFontSize(font.getSize());
         rt.setFontName(font.getFamily());

        if(getColor() != null) rt.setFontColor(getColor());
        if (font.isBold()) rt.setBold(true);
        if (font.isItalic()) rt.setItalic(true);

         txt.setMarginBottom(0);
         txt.setMarginTop(0);
         txt.setMarginLeft(0);
         txt.setMarginRight(0);
         txt.setWordWrap(TextBox.WrapNone);

         if (!"".equals(string)) txt.resizeToFitText();
         int height = (int)txt.getAnchor().getHeight();

         /*
           In powerpoint anchor of a shape is its top left corner.
           Java graphics sets string coordinates by the baseline of the first character
           so we need to shift down by the height of the textbox
         */
        txt.moveTo((int)x, (int)(y - height));

        if(clip != null) {
            if (!clip.getBounds().contains(txt.getAnchor())) {
                ;//return;
            }
        }
       group.addShape(txt);
    
public voiddrawString(java.lang.String str, int x, int y)

        throw new HSLFException("Not implemented");
    
public voiddrawString(java.text.AttributedCharacterIterator iterator, int x, int y)

        throw new HSLFException("Not implemented");
    
public voiddrawString(java.text.AttributedCharacterIterator attributedcharacteriterator, float x, float y)

        throw new HSLFException("Not implemented");
    
public voidfill(java.awt.Shape shape)

        if(clip != null) {
            java.awt.Rectangle bounds = getTransform().createTransformedShape(shape).getBounds();
            if (bounds.width == 0) bounds.width = 1;
            if (bounds.height == 0) bounds.height = 1;
             if (!clip.getBounds().contains(bounds)) {
                return;
            }
        }
        PathIterator it = shape.getPathIterator(transform);
        ArrayList pnt = new ArrayList();
        double[] coords = new double[6];
        while(!it.isDone()){
            int type = it.currentSegment(coords);
            if (type != PathIterator.SEG_CLOSE) {
                pnt.add(new Point((int)coords[0], (int)coords[1]));
            }
            it.next();
        }
        int[] xPoints= new int[pnt.size()];
        int[] yPoints= new int[pnt.size()];
        for (int i = 0; i < pnt.size(); i++) {
            Point p = (Point)pnt.get(i);
            xPoints[i] = p.x;
            yPoints[i] = p.y;
        }

        AutoShape r = new AutoShape(ShapeTypes.Rectangle);
        if (paint instanceof Color){
            Color color = (Color)paint;
            r.setFillColor(color);
        }
        if(getColor() != null) r.setLineColor(getColor());
        if (stroke instanceof BasicStroke){
            BasicStroke bs = (BasicStroke)stroke;
            r.setLineWidth(bs.getLineWidth());
            float[] dash = bs.getDashArray();
            if (dash != null) r.setLineDashing(Line.PEN_DASH);
        }

        java.awt.Rectangle bounds = transform.createTransformedShape(shape).getBounds();
        r.setAnchor(bounds);
        group.addShape(r);
    
public voidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle)

        throw new HSLFException("Not implemented");
    
public voidfillOval(int x, int y, int width, int height)

        throw new HSLFException("Not implemented");
    
public voidfillPolygon(int[] xPoints, int[] yPoints, int nPoints)

        throw new HSLFException("Not implemented");
    
public voidfillRect(int x, int y, int width, int height)

        throw new HSLFException("Not implemented");
    
public voidfillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)

        throw new HSLFException("Not implemented");
    
public java.awt.ColorgetBackground()

        throw new HSLFException("Not implemented");
    
public java.awt.ShapegetClip()

        return clip;
    
public java.awt.RectanglegetClipBounds()

        throw new HSLFException("Not implemented");
    
public java.awt.ColorgetColor()

        return foreground;
    
public java.awt.CompositegetComposite()

        throw new HSLFException("Not implemented");
    
public java.awt.GraphicsConfigurationgetDeviceConfiguration()

        throw new HSLFException("Not implemented");
    
public java.awt.FontgetFont()

        return font;
    
public java.awt.FontMetricsgetFontMetrics(java.awt.Font f)

        throw new HSLFException("Not implemented");
    
public java.awt.font.FontRenderContextgetFontRenderContext()

        return new FontRenderContext(transform, true, true);
    
public java.awt.PaintgetPaint()

        return paint;
    
public java.lang.ObjectgetRenderingHint(java.awt.RenderingHints$Key key)

        throw new HSLFException("Not implemented");
    
public java.awt.RenderingHintsgetRenderingHints()

        throw new HSLFException("Not implemented");
    
public org.apache.poi.hslf.model.ShapeGroupgetShapeGroup()

return
the shape group being used for drawing

        return group;
    
public java.awt.StrokegetStroke()

        return stroke;
    
public java.awt.geom.AffineTransformgetTransform()

        return (AffineTransform)transform.clone();
    
public booleanhit(java.awt.Rectangle rectangle, java.awt.Shape shape, boolean flag)

        throw new HSLFException("Not implemented");
    
public voidrotate(double d)

        throw new HSLFException("Not implemented");

    
public voidrotate(double d, double d1, double d2)

        throw new HSLFException("Not implemented");
    
public voidscale(double sx, double sy)

        AffineTransform at = new AffineTransform();
        at.scale(sx, sy);
        transform.concatenate(at);
    
public voidsetBackground(java.awt.Color c)

        throw new HSLFException("Not implemented");
    
public voidsetClip(java.awt.Shape clip)

        throw new HSLFException("Not implemented");
    
public voidsetClip(int x, int y, int width, int height)

        throw new HSLFException("Not implemented");
    
public voidsetColor(java.awt.Color color)

        this.foreground = color;
    
public voidsetComposite(java.awt.Composite composite)

        throw new HSLFException("Not implemented");

    
public voidsetFont(java.awt.Font font)

        this.font = font;
    
public voidsetPaint(java.awt.Paint paint)

        this.paint = paint;
        if (paint instanceof Color) setColor((Color)paint);
    
public voidsetPaintMode()

        throw new HSLFException("Not implemented");
    
public voidsetRenderingHint(java.awt.RenderingHints$Key key, java.lang.Object obj)

        throw new HSLFException("Not implemented");
    
public voidsetRenderingHints(java.util.Map map)

        throw new HSLFException("Not implemented");

    
public voidsetStroke(java.awt.Stroke s)

        this.stroke = s;
    
public voidsetTransform(java.awt.geom.AffineTransform trans)

        transform = (AffineTransform)trans.clone();
    
public voidsetXORMode(java.awt.Color color1)

        throw new HSLFException("Not implemented");
    
public voidshear(double d, double d1)

        throw new HSLFException("Not implemented");
    
public voidtransform(java.awt.geom.AffineTransform affinetransform)

        throw new HSLFException("Not implemented");
    
public voidtranslate(int x, int y)

        AffineTransform at = new AffineTransform();
        at.translate(x, y);
        transform.concatenate(at);
    
public voidtranslate(double d, double d1)


        throw new HSLFException("Not implemented");