Class EscherGraphics2d
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 / heightOfGroupThe 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().
- Author:
- Glen Stampoultzis (glens at apache.org)
-
Constructor Summary
ConstructorsConstructorDescriptionEscherGraphics2d(EscherGraphics escherGraphics) Constructs one escher graphics object from an escher graphics object. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRenderingHints(Map map) voidclearRect(int i, int j, int k, int l) voidvoidclipRect(int x, int y, int width, int height) voidcopyArea(int x, int y, int width, int height, int dx, int dy) create()voiddispose()voidvoiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle) voiddrawGlyphVector(GlyphVector g, float x, float y) voiddrawImage(BufferedImage bufferedimage, BufferedImageOp op, int x, int y) booleandrawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgColor, ImageObserver imageobserver) booleandrawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver imageobserver) booleandrawImage(Image image, int dx1, int dy1, int dx2, int dy2, Color bgColor, ImageObserver imageobserver) booleandrawImage(Image img, int x, int y, int width, int height, ImageObserver observer) booleandrawImage(Image image, int x, int y, Color bgColor, ImageObserver imageobserver) booleandrawImage(Image image, int x, int y, ImageObserver imageobserver) booleandrawImage(Image image, AffineTransform affinetransform, ImageObserver imageobserver) voiddrawLine(int x1, int y1, int x2, int y2) voiddrawLine(int x1, int y1, int x2, int y2, int width) voiddrawOval(int x, int y, int width, int height) voiddrawPolygon(int[] xPoints, int[] yPoints, int nPoints) voiddrawPolyline(int[] xPoints, int[] yPoints, int nPoints) voiddrawRect(int x, int y, int width, int height) voiddrawRenderableImage(RenderableImage renderableimage, AffineTransform affinetransform) voiddrawRenderedImage(RenderedImage renderedimage, AffineTransform affinetransform) voiddrawRoundRect(int i, int j, int k, int l, int i1, int j1) voiddrawString(String string, float x, float y) voiddrawString(String string, int x, int y) voiddrawString(AttributedCharacterIterator attributedcharacteriterator, float x, float y) voiddrawString(AttributedCharacterIterator attributedcharacteriterator, int x, int y) voidvoidfillArc(int i, int j, int k, int l, int i1, int j1) voidfillOval(int x, int y, int width, int height) voidfillPolygon(int[] xPoints, int[] yPoints, int nPoints) Fills a (closed) polygon, as defined by a pair of arrays, which hold the x and y coordinates.voidfillRect(int x, int y, int width, int height) voidfillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) getClip()getColor()getFont()getFontMetrics(Font font) getPaint()booleanvoidrotate(double d) voidrotate(double d, double d1, double d2) voidscale(double d, double d1) voidvoidsetClip(int i, int j, int k, int l) voidvoidvoidsetComposite(Composite composite) voidvoidvoidvoidsetRenderingHint(RenderingHints.Key key, Object obj) voidsetRenderingHints(Map map) voidvoidsetTransform(AffineTransform affinetransform) voidsetXORMode(Color color1) voidshear(double d, double d1) voidtransform(AffineTransform affinetransform) voidtranslate(double d, double d1) voidtranslate(int i, int j) Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRectMethods inherited from class java.awt.Graphics
create, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
-
Constructor Details
-
EscherGraphics2d
Constructs one escher graphics object from an escher graphics object.- Parameters:
escherGraphics- the original EscherGraphics2d object to copy
-
-
Method Details
-
addRenderingHints
- Specified by:
addRenderingHintsin classGraphics2D
-
clearRect
public void clearRect(int i, int j, int k, int l) -
clip
- Specified by:
clipin classGraphics2D
-
clipRect
public void clipRect(int x, int y, int width, int height) -
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy) -
create
-
dispose
public void dispose() -
draw
- Specified by:
drawin classGraphics2D
-
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) -
drawGlyphVector
- Specified by:
drawGlyphVectorin classGraphics2D
-
drawImage
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) -
drawImage
public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver imageobserver) -
drawImage
public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, Color bgColor, ImageObserver imageobserver) -
drawImage
-
drawImage
-
drawImage
-
drawImage
- Specified by:
drawImagein classGraphics2D
-
drawImage
- Specified by:
drawImagein classGraphics2D
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2, int width) -
drawLine
public void drawLine(int x1, int y1, int x2, int y2) -
drawOval
public void drawOval(int x, int y, int width, int height) -
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) - Specified by:
drawPolygonin classGraphics
-
drawPolyline
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) - Specified by:
drawPolylinein classGraphics
-
drawRect
public void drawRect(int x, int y, int width, int height) -
drawRenderableImage
- Specified by:
drawRenderableImagein classGraphics2D
-
drawRenderedImage
- Specified by:
drawRenderedImagein classGraphics2D
-
drawRoundRect
public void drawRoundRect(int i, int j, int k, int l, int i1, int j1) - Specified by:
drawRoundRectin classGraphics
-
drawString
- Specified by:
drawStringin classGraphics2D
-
drawString
- Specified by:
drawStringin classGraphics2D
-
drawString
- Specified by:
drawStringin classGraphics2D
-
drawString
- Specified by:
drawStringin classGraphics2D
-
fill
- Specified by:
fillin classGraphics2D
-
fillArc
public void fillArc(int i, int j, int k, int l, int i1, int j1) -
fillOval
public void fillOval(int x, int y, int width, int height) -
fillPolygon
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
nPointline segments. The firstnPoint - 1line 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.
- Specified by:
fillPolygonin classGraphics- Parameters:
xPoints- array of thexcoordinates.yPoints- array of theycoordinates.nPoints- the total number of points in the polygon.- See Also:
-
fillRect
public void fillRect(int x, int y, int width, int height) -
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - Specified by:
fillRoundRectin classGraphics
-
getBackground
- Specified by:
getBackgroundin classGraphics2D
-
getClip
-
getClipBounds
- Specified by:
getClipBoundsin classGraphics
-
getColor
-
getComposite
- Specified by:
getCompositein classGraphics2D
-
getDeviceConfiguration
- Specified by:
getDeviceConfigurationin classGraphics2D
-
getFont
-
getFontMetrics
- Specified by:
getFontMetricsin classGraphics
-
getFontRenderContext
- Specified by:
getFontRenderContextin classGraphics2D
-
getPaint
- Specified by:
getPaintin classGraphics2D
-
getRenderingHint
- Specified by:
getRenderingHintin classGraphics2D
-
getRenderingHints
- Specified by:
getRenderingHintsin classGraphics2D
-
getStroke
- Specified by:
getStrokein classGraphics2D
-
getTransform
- Specified by:
getTransformin classGraphics2D
-
hit
- Specified by:
hitin classGraphics2D
-
rotate
public void rotate(double d) - Specified by:
rotatein classGraphics2D
-
rotate
public void rotate(double d, double d1, double d2) - Specified by:
rotatein classGraphics2D
-
scale
public void scale(double d, double d1) - Specified by:
scalein classGraphics2D
-
setBackground
- Specified by:
setBackgroundin classGraphics2D
-
setClip
public void setClip(int i, int j, int k, int l) -
setClip
-
setColor
-
setComposite
- Specified by:
setCompositein classGraphics2D
-
setFont
-
setPaint
- Specified by:
setPaintin classGraphics2D
-
setPaintMode
public void setPaintMode()- Specified by:
setPaintModein classGraphics
-
setRenderingHint
- Specified by:
setRenderingHintin classGraphics2D
-
setRenderingHints
- Specified by:
setRenderingHintsin classGraphics2D
-
setStroke
- Specified by:
setStrokein classGraphics2D
-
setTransform
- Specified by:
setTransformin classGraphics2D
-
setXORMode
- Specified by:
setXORModein classGraphics
-
shear
public void shear(double d, double d1) - Specified by:
shearin classGraphics2D
-
transform
- Specified by:
transformin classGraphics2D
-
translate
public void translate(double d, double d1) - Specified by:
translatein classGraphics2D
-
translate
public void translate(int i, int j) - Specified by:
translatein classGraphics2D
-