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()
.
-
Constructor Summary
ConstructorsConstructorDescriptionEscherGraphics2d
(EscherGraphics escherGraphics) Constructs one escher graphics object from an escher graphics object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRenderingHints
(Map<?, ?> map) void
clearRect
(int i, int j, int k, int l) void
void
clipRect
(int x, int y, int width, int height) void
copyArea
(int x, int y, int width, int height, int dx, int dy) create()
void
dispose()
void
void
drawArc
(int x, int y, int width, int height, int startAngle, int arcAngle) void
drawGlyphVector
(GlyphVector g, float x, float y) void
drawImage
(BufferedImage bufferedimage, BufferedImageOp op, int x, int y) boolean
drawImage
(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgColor, ImageObserver imageobserver) boolean
drawImage
(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver imageobserver) boolean
drawImage
(Image image, int dx1, int dy1, int dx2, int dy2, Color bgColor, ImageObserver imageobserver) boolean
drawImage
(Image img, int x, int y, int width, int height, ImageObserver observer) boolean
drawImage
(Image image, int x, int y, Color bgColor, ImageObserver imageobserver) boolean
drawImage
(Image image, int x, int y, ImageObserver imageobserver) boolean
drawImage
(Image image, AffineTransform affinetransform, ImageObserver imageobserver) void
drawLine
(int x1, int y1, int x2, int y2) void
drawLine
(int x1, int y1, int x2, int y2, int width) void
drawOval
(int x, int y, int width, int height) void
drawPolygon
(int[] xPoints, int[] yPoints, int nPoints) void
drawPolyline
(int[] xPoints, int[] yPoints, int nPoints) void
drawRect
(int x, int y, int width, int height) void
drawRenderableImage
(RenderableImage renderableimage, AffineTransform affinetransform) void
drawRenderedImage
(RenderedImage renderedimage, AffineTransform affinetransform) void
drawRoundRect
(int i, int j, int k, int l, int i1, int j1) void
drawString
(String string, float x, float y) void
drawString
(String string, int x, int y) void
drawString
(AttributedCharacterIterator attributedcharacteriterator, float x, float y) void
drawString
(AttributedCharacterIterator attributedcharacteriterator, int x, int y) void
void
fillArc
(int i, int j, int k, int l, int i1, int j1) void
fillOval
(int x, int y, int width, int height) 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.void
fillRect
(int x, int y, int width, int height) void
fillRoundRect
(int x, int y, int width, int height, int arcWidth, int arcHeight) getClip()
getColor()
getFont()
getFontMetrics
(Font font) getPaint()
boolean
void
rotate
(double d) void
rotate
(double d, double d1, double d2) void
scale
(double d, double d1) void
void
setClip
(int i, int j, int k, int l) void
void
void
setComposite
(Composite composite) void
void
void
void
setRenderingHint
(RenderingHints.Key key, Object obj) void
setRenderingHints
(Map<?, ?> map) void
void
setTransform
(AffineTransform affinetransform) void
setXORMode
(Color color1) void
shear
(double d, double d1) void
transform
(AffineTransform affinetransform) void
translate
(double d, double d1) void
translate
(int i, int j) Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRect
Methods 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:
addRenderingHints
in classGraphics2D
-
clearRect
public void clearRect(int i, int j, int k, int l) -
clip
- Specified by:
clip
in 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:
draw
in classGraphics2D
-
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) -
drawGlyphVector
- Specified by:
drawGlyphVector
in 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:
drawImage
in classGraphics2D
-
drawImage
- Specified by:
drawImage
in 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:
drawPolygon
in classGraphics
-
drawPolyline
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) - Specified by:
drawPolyline
in classGraphics
-
drawRect
public void drawRect(int x, int y, int width, int height) -
drawRenderableImage
- Specified by:
drawRenderableImage
in classGraphics2D
-
drawRenderedImage
- Specified by:
drawRenderedImage
in classGraphics2D
-
drawRoundRect
public void drawRoundRect(int i, int j, int k, int l, int i1, int j1) - Specified by:
drawRoundRect
in classGraphics
-
drawString
- Specified by:
drawString
in classGraphics2D
-
drawString
- Specified by:
drawString
in classGraphics2D
-
drawString
- Specified by:
drawString
in classGraphics2D
-
drawString
- Specified by:
drawString
in classGraphics2D
-
fill
- Specified by:
fill
in 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
nPoint
line segments. The firstnPoint - 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.
- Specified by:
fillPolygon
in classGraphics
- Parameters:
xPoints
- array of thex
coordinates.yPoints
- array of they
coordinates.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:
fillRoundRect
in classGraphics
-
getBackground
- Specified by:
getBackground
in classGraphics2D
-
getClip
-
getClipBounds
- Specified by:
getClipBounds
in classGraphics
-
getColor
-
getComposite
- Specified by:
getComposite
in classGraphics2D
-
getDeviceConfiguration
- Specified by:
getDeviceConfiguration
in classGraphics2D
-
getFont
-
getFontMetrics
- Specified by:
getFontMetrics
in classGraphics
-
getFontRenderContext
- Specified by:
getFontRenderContext
in classGraphics2D
-
getPaint
- Specified by:
getPaint
in classGraphics2D
-
getRenderingHint
- Specified by:
getRenderingHint
in classGraphics2D
-
getRenderingHints
- Specified by:
getRenderingHints
in classGraphics2D
-
getStroke
- Specified by:
getStroke
in classGraphics2D
-
getTransform
- Specified by:
getTransform
in classGraphics2D
-
hit
- Specified by:
hit
in classGraphics2D
-
rotate
public void rotate(double d) - Specified by:
rotate
in classGraphics2D
-
rotate
public void rotate(double d, double d1, double d2) - Specified by:
rotate
in classGraphics2D
-
scale
public void scale(double d, double d1) - Specified by:
scale
in classGraphics2D
-
setBackground
- Specified by:
setBackground
in classGraphics2D
-
setClip
public void setClip(int i, int j, int k, int l) -
setClip
-
setColor
-
setComposite
- Specified by:
setComposite
in classGraphics2D
-
setFont
-
setPaint
- Specified by:
setPaint
in classGraphics2D
-
setPaintMode
public void setPaintMode()- Specified by:
setPaintMode
in classGraphics
-
setRenderingHint
- Specified by:
setRenderingHint
in classGraphics2D
-
setRenderingHints
- Specified by:
setRenderingHints
in classGraphics2D
-
setStroke
- Specified by:
setStroke
in classGraphics2D
-
setTransform
- Specified by:
setTransform
in classGraphics2D
-
setXORMode
- Specified by:
setXORMode
in classGraphics
-
shear
public void shear(double d, double d1) - Specified by:
shear
in classGraphics2D
-
transform
- Specified by:
transform
in classGraphics2D
-
translate
public void translate(double d, double d1) - Specified by:
translate
in classGraphics2D
-
translate
public void translate(int i, int j) - Specified by:
translate
in classGraphics2D
-