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 its 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().
| Modifier and Type | Field and Description |
|---|---|
| private Shape | |
| private final EscherGraphics | |
| private BufferedImage | |
| private Paint | |
| private Stroke | |
| private AffineTransform | |
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| public | EscherGraphics2d(EscherGraphics
the original EscherGraphics2d object to copy escherGraphics)Constructs one escher graphics object from an escher graphics object. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addRenderingHints(Map<?, ?>
the rendering hints to be set map)Implements abstract java. Sets the values of an arbitrary number of preferences for the rendering algorithms. |
| public void | clearRect(int
the x coordinate of the rectangle to clear. i, int the y coordinate of the rectangle to clear. j, int the width of the rectangle to clear. k, int the height of the rectangle to clear. l)Implements abstract java. Clears the specified rectangle by filling it with the background color of the current drawing surface. |
| public void | clip(Shape
the shape)Shape to be intersected with the current
Clip. This method updates the current Clip.Implements abstract java. Intersects the current |
| public void | clipRect(int
the x coordinate of the rectangle to intersect the clip with x, int the y coordinate of the rectangle to intersect the clip with y, int the width of the rectangle to intersect the clip with width, int the height of the rectangle to intersect the clip with height)Implements abstract java. Intersects the current clip with the specified rectangle. |
| public void | copyArea(int
the x coordinate of the source rectangle. x, int the y coordinate of the source rectangle. y, int the width of the source rectangle. width, int the height of the source rectangle. height, int the horizontal distance to copy the pixels. dx, int the vertical distance to copy the pixels. dy)Implements abstract java. Copies an area of the component by a distance specified by
|
| public Graphics | create()
Implements abstract java. Creates a new |
| public void | dispose()
Implements abstract java. Disposes of this graphics context and releases any system resources that it is using. |
| public void | draw(Shape
the shape)Shape to be renderedImplements abstract java. Strokes the outline of a |
| public void | drawArc(int
the x coordinate of the
upper-left corner of the arc to be drawn. x, int the y coordinate of the
upper-left corner of the arc to be drawn. y, int the width of the arc to be drawn. width, int the height of the arc to be drawn. height, int the beginning angle. startAngle, int the angular extent of the arc,
relative to the start angle. arcAngle)Implements abstract java. Draws the outline of a circular or elliptical arc covering the specified rectangle. |
| public void | drawGlyphVector(GlyphVector
the g, float GlyphVector to be renderedthe x position in User Space where the glyphs should
be rendered x, float the y position in User Space where the glyphs should
be rendered y)Implements abstract java. Renders the text of the specified
|
| public boolean | drawImage(Image
the specified image to be drawn. This method does
nothing if image, int img is null.the x coordinate of the first corner of the
destination rectangle. dx1, int the y coordinate of the first corner of the
destination rectangle. dy1, int the x coordinate of the second corner of the
destination rectangle. dx2, int the y coordinate of the second corner of the
destination rectangle. dy2, int the x coordinate of the first corner of the
source rectangle. sx1, int the y coordinate of the first corner of the
source rectangle. sy1, int the x coordinate of the second corner of the
source rectangle. sx2, int the y coordinate of the second corner of the
source rectangle. sy2, Color the background color to paint under the
non-opaque portions of the image. bgColor, ImageObserver object to be notified as more of the image is
scaled and converted. imageobserver)Implements abstract java. Draws as much of the specified area of the specified image as is currently available, scaling it on the fly to fit inside the specified area of the destination drawable surface. |
| public boolean | drawImage(Image
the specified image to be drawn. This method does
nothing if image, int img is null.the x coordinate of the first corner of the
destination rectangle. dx1, int the y coordinate of the first corner of the
destination rectangle. dy1, int the x coordinate of the second corner of the
destination rectangle. dx2, int the y coordinate of the second corner of the
destination rectangle. dy2, int the x coordinate of the first corner of the
source rectangle. sx1, int the y coordinate of the first corner of the
source rectangle. sy1, int the x coordinate of the second corner of the
source rectangle. sx2, int the y coordinate of the second corner of the
source rectangle. sy2, ImageObserver object to be notified as more of the image is
scaled and converted. imageobserver)Implements abstract java. Draws as much of the specified area of the specified image as is currently available, scaling it on the fly to fit inside the specified area of the destination drawable surface. |
| public boolean | drawImage(Image
the specified image to be drawn. This method does
nothing if image, int img is null.the x coordinate. dx1, int the y coordinate. dy1, int the width of the rectangle. dx2, int the height of the rectangle. dy2, Color the background color to paint under the
non-opaque portions of the image. bgColor, ImageObserver object to be notified as more of
the image is converted. imageobserver)Implements abstract java. Draws as much of the specified image as has already been scaled to fit inside the specified rectangle. |
| public boolean | drawImage(Image
the specified image to be drawn. This method does
nothing if img, int img is null.the x coordinate. x, int the y coordinate. y, int the width of the rectangle. width, int the height of the rectangle. height, ImageObserver object to be notified as more of
the image is converted. observer)Implements abstract java. Draws as much of the specified image as has already been scaled to fit inside the specified rectangle. |
| public boolean | drawImage(Image
the specified image to be drawn. This method does
nothing if image, int img is null.the x coordinate. x, int the y coordinate. y, Color the background color to paint under the
non-opaque portions of the image. bgColor, ImageObserver object to be notified as more of
the image is converted. imageobserver)Implements abstract java. Draws as much of the specified image as is currently available. |
| public boolean | drawImage(Image
the specified image to be drawn. This method does
nothing if image, int img is null.the x coordinate. x, int the y coordinate. y, ImageObserver object to be notified as more of
the image is converted. imageobserver)Implements abstract java. Draws as much of the specified image as is currently available. |
| public boolean | drawImage(Image
the specified image to be rendered.
This method does nothing if image, AffineTransform img is null.the transformation from image space into user space affinetransform, ImageObserver the imageobserver)ImageObserver
to be notified as more of the Image
is convertedImplements abstract java. Renders an image, applying a transform from image space into user space before drawing. |
| public void | drawImage(BufferedImage
the specified bufferedimage, BufferedImageOp BufferedImage to be rendered.
This method does nothing if img is null.the filter to be applied to the image before rendering op, int the x coordinate of the location in user space where
the upper left corner of the image is rendered x, int the y coordinate of the location in user space where
the upper left corner of the image is rendered y)Implements abstract java. Renders a |
| public void | |
| public void | drawLine(int
the first point's x coordinate. x1, int the first point's y coordinate. y1, int the second point's x coordinate. x2, int the second point's y coordinate. y2)Implements abstract java. Draws a line, using the current color, between the points
|
| public void | drawOval(int
the x coordinate of the upper left
corner of the oval to be drawn. x, int the y coordinate of the upper left
corner of the oval to be drawn. y, int the width of the oval to be drawn. width, int the height of the oval to be drawn. height)Implements abstract java. Draws the outline of an oval. |
| public void | drawPolygon(int[]
an array of xPoints, int[] x coordinates.an array of yPoints, int y coordinates.the total number of points. nPoints)Implements abstract java. Draws a closed polygon defined by arrays of x and y coordinates. |
| public void | drawPolyline(int[]
an array of x points xPoints, int[] an array of y points yPoints, int the total number of points nPoints)Implements abstract java. Draws a sequence of connected lines defined by arrays of x and y coordinates. |
| public void | drawRect(int
the x coordinate
of the rectangle to be drawn. x, int the y coordinate
of the rectangle to be drawn. y, int the width of the rectangle to be drawn. width, int the height of the rectangle to be drawn. height)Overrides java. Draws the outline of the specified rectangle. |
| public void | drawRenderableImage(RenderableImage
the image to be rendered. This method does
nothing if renderableimage, AffineTransform img is null.the transformation from image space into user space affinetransform)Implements abstract java. Renders a
|
| public void | drawRenderedImage(RenderedImage
the image to be rendered. This method does
nothing if renderedimage, AffineTransform img is null.the transformation from image space into user space affinetransform)Implements abstract java. Renders a |
| public void | drawRoundRect(int
the x coordinate of the rectangle to be drawn. i, int the y coordinate of the rectangle to be drawn. j, int the width of the rectangle to be drawn. k, int the height of the rectangle to be drawn. l, int the horizontal diameter of the arc
at the four corners. i1, int the vertical diameter of the arc
at the four corners. j1)Implements abstract java. Draws an outlined round-cornered rectangle using this graphics context's current color. |
| public void | drawString(String
the string, float String to be renderedthe x coordinate of the location where the
x, float String should be renderedthe y coordinate of the location where the
y)String should be renderedImplements abstract java. Renders the text specified by the specified |
| public void | drawString(String
the string to be rendered string, int the x coordinate of the location where the
x, int String should be renderedthe y coordinate of the location where the
y)String should be renderedImplements abstract java. Renders the text of the specified |
| public void | drawString(AttributedCharacterIterator
the iterator whose text is to be rendered attributedcharacteriterator, float the x coordinate where the iterator's text is to be
rendered x, float the y coordinate where the iterator's text is to be
rendered y)Implements abstract java. Renders the text of the specified iterator applying its attributes
in accordance with the specification of the |
| public void | drawString(AttributedCharacterIterator
the iterator whose text is to be rendered attributedcharacteriterator, int the x coordinate where the iterator's text is to be
rendered x, int the y coordinate where the iterator's text is to be
rendered y)Implements abstract java. Renders the text of the specified iterator applying its attributes
in accordance with the specification of the |
| public void | fill(Shape
the shape)Shape to be filledImplements abstract java. Fills the interior of a |
| public void | fillArc(int
the x coordinate of the
upper-left corner of the arc to be filled. i, int the y coordinate of the
upper-left corner of the arc to be filled. j, int the width of the arc to be filled. k, int the height of the arc to be filled. l, int the beginning angle. i1, int the angular extent of the arc,
relative to the start angle. j1)Implements abstract java. Fills a circular or elliptical arc covering the specified rectangle. |
| public void | fillOval(int
the x coordinate of the upper left corner
of the oval to be filled. x, int the y coordinate of the upper left corner
of the oval to be filled. y, int the width of the oval to be filled. width, int the height of the oval to be filled. height)Implements abstract java. Fills an oval bounded by the specified rectangle with the current color. |
| public void | fillPolygon(int[]
array of the xPoints, int[] x coordinates.array of the yPoints, int y coordinates.the total number of points in the polygon. nPoints)Implements abstract java. Fills a (closed) polygon, as defined by a pair of arrays, which hold the x and y coordinates. |
| public void | fillRect(int
the x coordinate
of the rectangle to be filled. x, int the y coordinate
of the rectangle to be filled. y, int the width of the rectangle to be filled. width, int the height of the rectangle to be filled. height)Implements abstract java. Fills the specified rectangle. |
| public void | fillRoundRect(int
the x coordinate of the rectangle to be filled. x, int the y coordinate of the rectangle to be filled. y, int the width of the rectangle to be filled. width, int the height of the rectangle to be filled. height, int the horizontal diameter
of the arc at the four corners. arcWidth, int the vertical diameter
of the arc at the four corners. arcHeight)Implements abstract java. Fills the specified rounded corner rectangle with the current color. |
| public Color | getBackground()
Implements abstract java. Returns the background color used for clearing a region. |
| public Shape | |
| public Rectangle | getClipBounds()
Implements abstract java. Returns the bounding rectangle of the current clipping area. |
| public Color | getColor()
Implements abstract java. Gets this graphics context's current color. |
| public Composite | getComposite()
Implements abstract java. Returns the current |
| private Shape | |
| public GraphicsConfiguration | getDeviceConfiguration()
Implements abstract java. Returns the device configuration associated with this
|
| private EscherGraphics | |
| public Font | |
| public FontMetrics | getFontMetrics(Font
the specified font font)Implements abstract java. Gets the font metrics for the specified font. |
| public FontRenderContext | getFontRenderContext()
Implements abstract java. Get the rendering context of the |
| private Graphics2D | |
| private BufferedImage | |
| public Paint | getPaint()
Implements abstract java. Returns the current |
| public Object | getRenderingHint(RenderingHints.
the key corresponding to the hint to get. keyImplements abstract java. Returns the value of a single preference for the rendering algorithms. |
| public RenderingHints | getRenderingHints()
Implements abstract java. Gets the preferences for the rendering algorithms. |
| public Stroke | getStroke()
Implements abstract java. Returns the current |
| private AffineTransform | |
| public AffineTransform | getTransform()
Implements abstract java. Returns a copy of the current |
| public boolean | hit(Rectangle
the area in device space to check for a hit rectangle, Shape the shape, boolean Shape to check for a hitflag used to choose between testing the
stroked or the filled shape. If the flag is flag)true, the
Stroke outline is tested. If the flag is
false, the filled Shape is tested.Implements abstract java. Checks whether or not the specified |
| public void | rotate(double
the angle of rotation in radians d)Implements abstract java. Concatenates the current |
| public void | rotate(double
the angle of rotation in radians d, double the x coordinate of the origin of the rotation d1, double the y coordinate of the origin of the rotation d2)Implements abstract java. Concatenates the current |
| public void | scale(double
the amount by which X coordinates in subsequent
rendering operations are multiplied relative to previous
rendering operations. d, double the amount by which Y coordinates in subsequent
rendering operations are multiplied relative to previous
rendering operations. d1)Implements abstract java. Concatenates the current |
| public void | setBackground(Color
the background color that is used in
subsequent calls to c)clearRectImplements abstract java. Sets the background color for the |
| public void | setClip(int
the x coordinate of the new clip rectangle. i, int the y coordinate of the new clip rectangle. j, int the width of the new clip rectangle. k, int the height of the new clip rectangle. l)Implements abstract java. Sets the current clip to the rectangle specified by the given coordinates. |
| public void | setClip(Shape
the shape)Shape to use to set the clip.
Passing null clears the current clip.Implements abstract java. Sets the current clipping area to an arbitrary clip shape. |
| public void | setColor(Color
the new rendering color. c)Implements abstract java. Sets this graphics context's current color to the specified color. |
| public void | setComposite(Composite
the composite)Composite object to be used for renderingImplements abstract java. Sets the |
| private void | |
| public void | setFont(Font
the font. font)Implements abstract java. Sets this graphics context's font to the specified font. |
| private void | |
| public void | setPaint(Paint
the paint1)Paint object to be used to generate
color during the rendering process, or nullImplements abstract java. Sets the |
| public void | setPaintMode()
Implements abstract java. Sets the paint mode of this graphics context to overwrite the destination with this graphics context's current color. |
| public void | setRenderingHint(RenderingHints.
the key of the hint to be set. key,the value indicating preferences for the specified
hint category. obj)Implements abstract java. Sets the value of a single preference for the rendering algorithms. |
| public void | setRenderingHints(Map<?, ?>
the rendering hints to be set map)Implements abstract java. Replaces the values of all preferences for the rendering
algorithms with the specified |
| public void | setStroke(Stroke
the s)Stroke object to be used to stroke a
Shape during the rendering processImplements abstract java. Sets the |
| private void | |
| public void | setTransform(AffineTransform
the affinetransform)AffineTransform that was retrieved
from the getTransform methodImplements abstract java. Overwrites the Transform in the |
| public void | setXORMode(Color
the XOR alternation color color1)Implements abstract java. Sets the paint mode of this graphics context to alternate between this graphics context's current color and the new specified color. |
| public void | shear(double
the multiplier by which coordinates are shifted in
the positive X axis direction as a function of their Y coordinate d, double the multiplier by which coordinates are shifted in
the positive Y axis direction as a function of their X coordinate d1)Implements abstract java. Concatenates the current |
| public void | transform(AffineTransform
the affinetransform)AffineTransform object to be composed with
the current TransformImplements abstract java. Composes an |
| public void | translate(double
the distance to translate along the x-axis d, double the distance to translate along the y-axis d1)Implements abstract java. Concatenates the current
|
| public void | translate(int
the specified x coordinate i, int the specified y coordinate j)Implements abstract java. Translates the origin of the |