public class EscherGraphics2d extends Graphics2D
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 and Description |
---|
EscherGraphics2d(EscherGraphics escherGraphics)
Constructs one escher graphics object from an escher graphics object.
|
Modifier and Type | Method and Description |
---|---|
void |
addRenderingHints(Map map) |
void |
clearRect(int i,
int j,
int k,
int l) |
void |
clip(Shape shape) |
void |
clipRect(int x,
int y,
int width,
int height) |
void |
copyArea(int x,
int y,
int width,
int height,
int dx,
int dy) |
Graphics |
create() |
void |
dispose() |
void |
draw(Shape shape) |
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,
AffineTransform affinetransform,
ImageObserver imageobserver) |
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,
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 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) |
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(AttributedCharacterIterator attributedcharacteriterator,
float x,
float y) |
void |
drawString(AttributedCharacterIterator attributedcharacteriterator,
int x,
int y) |
void |
drawString(String string,
float x,
float y) |
void |
drawString(String string,
int x,
int y) |
void |
fill(Shape shape) |
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) |
Color |
getBackground() |
Shape |
getClip() |
Rectangle |
getClipBounds() |
Color |
getColor() |
Composite |
getComposite() |
GraphicsConfiguration |
getDeviceConfiguration() |
Font |
getFont() |
FontMetrics |
getFontMetrics(Font font) |
FontRenderContext |
getFontRenderContext() |
Paint |
getPaint() |
Object |
getRenderingHint(RenderingHints.Key key) |
RenderingHints |
getRenderingHints() |
Stroke |
getStroke() |
AffineTransform |
getTransform() |
boolean |
hit(Rectangle rectangle,
Shape shape,
boolean flag) |
void |
rotate(double d) |
void |
rotate(double d,
double d1,
double d2) |
void |
scale(double d,
double d1) |
void |
setBackground(Color c) |
void |
setClip(int i,
int j,
int k,
int l) |
void |
setClip(Shape shape) |
void |
setColor(Color c) |
void |
setComposite(Composite composite) |
void |
setFont(Font font) |
void |
setPaint(Paint paint1) |
void |
setPaintMode() |
void |
setRenderingHint(RenderingHints.Key key,
Object obj) |
void |
setRenderingHints(Map map) |
void |
setStroke(Stroke s) |
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) |
draw3DRect, fill3DRect
create, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
public EscherGraphics2d(EscherGraphics escherGraphics)
escherGraphics
- the original EscherGraphics2d object to copypublic void addRenderingHints(Map map)
addRenderingHints
in class Graphics2D
public void clearRect(int i, int j, int k, int l)
public void clip(Shape shape)
clip
in class Graphics2D
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 void draw(Shape shape)
draw
in class Graphics2D
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
public void drawGlyphVector(GlyphVector g, float x, float y)
drawGlyphVector
in class Graphics2D
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 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, 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 x, int y, Color bgColor, ImageObserver imageobserver)
public boolean drawImage(Image image, int x, int y, ImageObserver imageobserver)
public boolean drawImage(Image image, AffineTransform affinetransform, ImageObserver imageobserver)
drawImage
in class Graphics2D
public void drawImage(BufferedImage bufferedimage, BufferedImageOp op, int x, int y)
drawImage
in class Graphics2D
public void drawLine(int x1, int y1, int x2, int y2, int width)
public void drawLine(int x1, int y1, int x2, int y2)
public void drawOval(int x, int y, int width, int height)
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
drawPolygon
in class Graphics
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
drawPolyline
in class Graphics
public void drawRect(int x, int y, int width, int height)
public void drawRenderableImage(RenderableImage renderableimage, AffineTransform affinetransform)
drawRenderableImage
in class Graphics2D
public void drawRenderedImage(RenderedImage renderedimage, AffineTransform affinetransform)
drawRenderedImage
in class Graphics2D
public void drawRoundRect(int i, int j, int k, int l, int i1, int j1)
drawRoundRect
in class Graphics
public void drawString(String string, float x, float y)
drawString
in class Graphics2D
public void drawString(String string, int x, int y)
drawString
in class Graphics2D
public void drawString(AttributedCharacterIterator attributedcharacteriterator, float x, float y)
drawString
in class Graphics2D
public void drawString(AttributedCharacterIterator attributedcharacteriterator, int x, int y)
drawString
in class Graphics2D
public void fill(Shape shape)
fill
in class Graphics2D
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)
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.
fillPolygon
in class Graphics
xPoints
- array of the x
coordinates.yPoints
- array of the y
coordinates.nPoints
- the total number of points in the polygon.Graphics.drawPolygon(int[], int[], int)
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)
fillRoundRect
in class Graphics
public Color getBackground()
getBackground
in class Graphics2D
public Rectangle getClipBounds()
getClipBounds
in class Graphics
public Composite getComposite()
getComposite
in class Graphics2D
public GraphicsConfiguration getDeviceConfiguration()
getDeviceConfiguration
in class Graphics2D
public FontMetrics getFontMetrics(Font font)
getFontMetrics
in class Graphics
public FontRenderContext getFontRenderContext()
getFontRenderContext
in class Graphics2D
public Paint getPaint()
getPaint
in class Graphics2D
public Object getRenderingHint(RenderingHints.Key key)
getRenderingHint
in class Graphics2D
public RenderingHints getRenderingHints()
getRenderingHints
in class Graphics2D
public Stroke getStroke()
getStroke
in class Graphics2D
public AffineTransform getTransform()
getTransform
in class Graphics2D
public boolean hit(Rectangle rectangle, Shape shape, boolean flag)
hit
in class Graphics2D
public void rotate(double d)
rotate
in class Graphics2D
public void rotate(double d, double d1, double d2)
rotate
in class Graphics2D
public void scale(double d, double d1)
scale
in class Graphics2D
public void setBackground(Color c)
setBackground
in class Graphics2D
public void setComposite(Composite composite)
setComposite
in class Graphics2D
public void setPaint(Paint paint1)
setPaint
in class Graphics2D
public void setPaintMode()
setPaintMode
in class Graphics
public void setRenderingHint(RenderingHints.Key key, Object obj)
setRenderingHint
in class Graphics2D
public void setRenderingHints(Map map)
setRenderingHints
in class Graphics2D
public void setStroke(Stroke s)
setStroke
in class Graphics2D
public void setTransform(AffineTransform affinetransform)
setTransform
in class Graphics2D
public void setXORMode(Color color1)
setXORMode
in class Graphics
public void shear(double d, double d1)
shear
in class Graphics2D
public void transform(AffineTransform affinetransform)
transform
in class Graphics2D
public void translate(double d, double d1)
translate
in class Graphics2D
public void translate(int i, int j)
translate
in class Graphics2D
Copyright © 2014 Open Microscopy Environment