Save This Page
Home » poi-src-3.2-FINAL-20081019 » org.apache » poi » hssf » usermodel » [javadoc | source]
org.apache.poi.hssf.usermodel
public class: EscherGraphics2d [javadoc | source]
java.lang.Object
   java.awt.Graphics
      java.awt.Graphics2D
         org.apache.poi.hssf.usermodel.EscherGraphics2d
Translates Graphics2d calls into escher calls. The translation is lossy so many features are not supported and some just aren't implemented yet. If in doubt test the specific calls you wish to make. Graphics calls are always drawn into an EscherGroup so one will need to be created.

Important:

One important concept worth considering is that of font size. One of the difficulties in converting Graphics calls into escher drawing calls is that Excel does not have the concept of absolute pixel positions. It measures it's cell widths in 'characters' and the cell heights in points. Unfortunately it's not defined exactly what a type of character it's measuring. Presumably this is due to the fact that the Excel will be using different fonts on different platforms or even within the same platform.

Because of this constraint you have to calculate the verticalPointsPerPixel. This the amount the font should be scaled by when you issue commands such as drawString(). A good way to calculate this is to use the follow formula:

multipler = groupHeightInPoints / heightOfGroup

The height of the group is calculated fairly simply by calculating the difference between the y coordinates of the bounding box of the shape. The height of the group can be calculated by using a convenience called HSSFClientAnchor.getAnchorHeightInPoints().

Constructor:
 public EscherGraphics2d(EscherGraphics escherGraphics) 
    Constructs one escher graphics object from an escher graphics object.
    Parameters:
    escherGraphics - the original EscherGraphics2d object to copy
Method from org.apache.poi.hssf.usermodel.EscherGraphics2d Summary:
addRenderingHints,   clearRect,   clip,   clipRect,   copyArea,   create,   dispose,   draw,   drawArc,   drawGlyphVector,   drawImage,   drawImage,   drawImage,   drawImage,   drawImage,   drawImage,   drawImage,   drawImage,   drawLine,   drawLine,   drawOval,   drawPolygon,   drawPolyline,   drawRect,   drawRenderableImage,   drawRenderedImage,   drawRoundRect,   drawString,   drawString,   drawString,   drawString,   fill,   fillArc,   fillOval,   fillPolygon,   fillRect,   fillRoundRect,   getBackground,   getClip,   getClipBounds,   getColor,   getComposite,   getDeviceConfiguration,   getFont,   getFontMetrics,   getFontRenderContext,   getPaint,   getRenderingHint,   getRenderingHints,   getStroke,   getTransform,   hit,   rotate,   rotate,   scale,   setBackground,   setClip,   setClip,   setColor,   setComposite,   setFont,   setPaint,   setPaintMode,   setRenderingHint,   setRenderingHints,   setStroke,   setTransform,   setXORMode,   shear,   transform,   translate,   translate
Methods from java.awt.Graphics2D:
addRenderingHints,   clip,   draw,   draw3DRect,   drawGlyphVector,   drawImage,   drawImage,   drawRenderableImage,   drawRenderedImage,   drawString,   drawString,   drawString,   drawString,   fill,   fill3DRect,   getBackground,   getComposite,   getDeviceConfiguration,   getFontRenderContext,   getPaint,   getRenderingHint,   getRenderingHints,   getStroke,   getTransform,   hit,   rotate,   rotate,   scale,   setBackground,   setComposite,   setPaint,   setRenderingHint,   setRenderingHints,   setStroke,   setTransform,   shear,   transform,   translate,   translate
Methods from java.awt.Graphics:
clearRect,   clipRect,   copyArea,   create,   create,   dispose,   draw3DRect,   drawArc,   drawBytes,   drawChars,   drawImage,   drawImage,   drawImage,   drawImage,   drawImage,   drawImage,   drawLine,   drawOval,   drawPolygon,   drawPolygon,   drawPolyline,   drawRect,   drawRoundRect,   drawString,   drawString,   fill3DRect,   fillArc,   fillOval,   fillPolygon,   fillPolygon,   fillRect,   fillRoundRect,   finalize,   getClip,   getClipBounds,   getClipBounds,   getClipRect,   getColor,   getFont,   getFontMetrics,   getFontMetrics,   hitClip,   setClip,   setClip,   setColor,   setFont,   setPaintMode,   setXORMode,   toString,   translate
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.poi.hssf.usermodel.EscherGraphics2d Detail:
 public  void addRenderingHints(Map map) 
 public  void clearRect(int i,
    int j,
    int k,
    int l) 
 public  void clip(Shape shape) 
 public  void clipRect(int x,
    int y,
    int width,
    int height) 
 public  void copyArea(int x,
    int y,
    int width,
    int height,
    int dx,
    int dy) 
 public Graphics create() 
 public  void dispose() 
 public  void draw(Shape shape) 
 public  void drawArc(int x,
    int y,
    int width,
    int height,
    int startAngle,
    int arcAngle) 
 public  void drawGlyphVector(GlyphVector g,
    float x,
    float y) 
 public boolean drawImage(Image image,
    AffineTransform affinetransform,
    ImageObserver imageobserver) 
 public boolean drawImage(Image image,
    int x,
    int y,
    ImageObserver imageobserver) 
 public  void drawImage(BufferedImage bufferedimage,
    BufferedImageOp op,
    int x,
    int y) 
 public boolean drawImage(Image image,
    int x,
    int y,
    Color bgColor,
    ImageObserver imageobserver) 
 public boolean drawImage(Image img,
    int x,
    int y,
    int width,
    int height,
    ImageObserver observer) 
 public boolean drawImage(Image image,
    int dx1,
    int dy1,
    int dx2,
    int dy2,
    Color bgColor,
    ImageObserver imageobserver) 
 public boolean drawImage(Image image,
    int dx1,
    int dy1,
    int dx2,
    int dy2,
    int sx1,
    int sy1,
    int sx2,
    int sy2,
    ImageObserver imageobserver) 
 public boolean drawImage(Image image,
    int dx1,
    int dy1,
    int dx2,
    int dy2,
    int sx1,
    int sy1,
    int sx2,
    int sy2,
    Color bgColor,
    ImageObserver imageobserver) 
 public  void drawLine(int x1,
    int y1,
    int x2,
    int y2) 
 public  void drawLine(int x1,
    int y1,
    int x2,
    int y2,
    int width) 
 public  void drawOval(int x,
    int y,
    int width,
    int height) 
 public  void drawPolygon(int[] xPoints,
    int[] yPoints,
    int nPoints) 
 public  void drawPolyline(int[] xPoints,
    int[] yPoints,
    int nPoints) 
 public  void drawRect(int x,
    int y,
    int width,
    int height) 
 public  void drawRenderableImage(RenderableImage renderableimage,
    AffineTransform affinetransform) 
 public  void drawRenderedImage(RenderedImage renderedimage,
    AffineTransform affinetransform) 
 public  void drawRoundRect(int i,
    int j,
    int k,
    int l,
    int i1,
    int j1) 
 public  void drawString(String string,
    float x,
    float y) 
 public  void drawString(String string,
    int x,
    int y) 
 public  void drawString(AttributedCharacterIterator attributedcharacteriterator,
    float x,
    float y) 
 public  void drawString(AttributedCharacterIterator attributedcharacteriterator,
    int x,
    int y) 
 public  void fill(Shape shape) 
 public  void fillArc(int i,
    int j,
    int k,
    int l,
    int i1,
    int j1) 
 public  void fillOval(int x,
    int y,
    int width,
    int height) 
 public  void fillPolygon(int[] xPoints,
    int[] yPoints,
    int nPoints) 
    Fills a (closed) polygon, as defined by a pair of arrays, which hold the x and y coordinates.

    This draws the polygon, with nPoint line segments. The first nPoint - 1 line segments are drawn between sequential points (xPoints[i],yPoints[i],xPoints[i+1],yPoints[i+1]). The final line segment is a closing one, from the last point to the first (assuming they are different).

    The area inside of the polygon is defined by using an even-odd fill rule (also known as the alternating rule), and the area inside of it is filled.

 public  void fillRect(int x,
    int y,
    int width,
    int height) 
 public  void fillRoundRect(int x,
    int y,
    int width,
    int height,
    int arcWidth,
    int arcHeight) 
 public Color getBackground() 
 public Shape getClip() 
 public Rectangle getClipBounds() 
 public Color getColor() 
 public Composite getComposite() 
 public GraphicsConfiguration getDeviceConfiguration() 
 public Font getFont() 
 public FontMetrics getFontMetrics(Font font) 
 public FontRenderContext getFontRenderContext() 
 public Paint getPaint() 
 public Object getRenderingHint(RenderingHints.Key key) 
 public RenderingHints getRenderingHints() 
 public Stroke getStroke() 
 public AffineTransform getTransform() 
 public boolean hit(Rectangle rectangle,
    Shape shape,
    boolean flag) 
 public  void rotate(double d) 
 public  void rotate(double d,
    double d1,
    double d2) 
 public  void scale(double d,
    double d1) 
 public  void setBackground(Color c) 
 public  void setClip(Shape shape) 
 public  void setClip(int i,
    int j,
    int k,
    int l) 
 public  void setColor(Color c) 
 public  void setComposite(Composite composite) 
 public  void setFont(Font font) 
 public  void setPaint(Paint paint1) 
 public  void setPaintMode() 
 public  void setRenderingHint(RenderingHints.Key key,
    Object obj) 
 public  void setRenderingHints(Map map) 
 public  void setStroke(Stroke s) 
 public  void setTransform(AffineTransform affinetransform) 
 public  void setXORMode(Color color1) 
 public  void shear(double d,
    double d1) 
 public  void transform(AffineTransform affinetransform) 
 public  void translate(double d,
    double d1) 
 public  void translate(int i,
    int j)