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().
| Modifier and Type | Field and Description |
|---|---|
private Shape |
deviceclip |
private EscherGraphics |
escherGraphics |
private BufferedImage |
img |
private POILogger |
logger |
private Paint |
paint |
private Stroke |
stroke |
private AffineTransform |
trans |
| 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() |
private Shape |
getDeviceclip() |
GraphicsConfiguration |
getDeviceConfiguration() |
private EscherGraphics |
getEscherGraphics() |
Font |
getFont() |
FontMetrics |
getFontMetrics(Font font) |
FontRenderContext |
getFontRenderContext() |
private Graphics2D |
getG2D() |
private BufferedImage |
getImg() |
Paint |
getPaint() |
Object |
getRenderingHint(RenderingHints.Key key) |
RenderingHints |
getRenderingHints() |
Stroke |
getStroke() |
private AffineTransform |
getTrans() |
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) |
private void |
setDeviceclip(Shape deviceclip) |
void |
setFont(Font font) |
private void |
setImg(BufferedImage img) |
void |
setPaint(Paint paint1) |
void |
setPaintMode() |
void |
setRenderingHint(RenderingHints.Key key,
Object obj) |
void |
setRenderingHints(Map map) |
void |
setStroke(Stroke s) |
private void |
setTrans(AffineTransform trans) |
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, fill3DRectcreate, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toStringprivate EscherGraphics escherGraphics
private BufferedImage img
private AffineTransform trans
private Stroke stroke
private Paint paint
private Shape deviceclip
private POILogger logger
public EscherGraphics2d(EscherGraphics escherGraphics)
escherGraphics - the original EscherGraphics2d object to copypublic void addRenderingHints(Map map)
addRenderingHints in class Graphics2Dpublic void clearRect(int i,
int j,
int k,
int l)
public void clip(Shape shape)
clip in class Graphics2Dpublic 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 Graphics2Dpublic 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 Graphics2Dpublic 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 Graphics2Dpublic void drawImage(BufferedImage bufferedimage, BufferedImageOp op, int x, int y)
drawImage in class Graphics2Dpublic 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 Graphicspublic void drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
drawPolyline in class Graphicspublic void drawRect(int x,
int y,
int width,
int height)
public void drawRenderableImage(RenderableImage renderableimage, AffineTransform affinetransform)
drawRenderableImage in class Graphics2Dpublic void drawRenderedImage(RenderedImage renderedimage, AffineTransform affinetransform)
drawRenderedImage in class Graphics2Dpublic void drawRoundRect(int i,
int j,
int k,
int l,
int i1,
int j1)
drawRoundRect in class Graphicspublic void drawString(String string, float x, float y)
drawString in class Graphics2Dpublic void drawString(String string, int x, int y)
drawString in class Graphics2Dpublic void drawString(AttributedCharacterIterator attributedcharacteriterator, float x, float y)
drawString in class Graphics2Dpublic void drawString(AttributedCharacterIterator attributedcharacteriterator, int x, int y)
drawString in class Graphics2Dpublic void fill(Shape shape)
fill in class Graphics2Dpublic 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 GraphicsxPoints - 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 Graphicspublic Color getBackground()
getBackground in class Graphics2Dpublic Rectangle getClipBounds()
getClipBounds in class Graphicspublic Composite getComposite()
getComposite in class Graphics2Dpublic GraphicsConfiguration getDeviceConfiguration()
getDeviceConfiguration in class Graphics2Dpublic FontMetrics getFontMetrics(Font font)
getFontMetrics in class Graphicspublic FontRenderContext getFontRenderContext()
getFontRenderContext in class Graphics2Dpublic Paint getPaint()
getPaint in class Graphics2Dpublic Object getRenderingHint(RenderingHints.Key key)
getRenderingHint in class Graphics2Dpublic RenderingHints getRenderingHints()
getRenderingHints in class Graphics2Dpublic Stroke getStroke()
getStroke in class Graphics2Dpublic AffineTransform getTransform()
getTransform in class Graphics2Dpublic boolean hit(Rectangle rectangle, Shape shape, boolean flag)
hit in class Graphics2Dpublic void rotate(double d)
rotate in class Graphics2Dpublic void rotate(double d,
double d1,
double d2)
rotate in class Graphics2Dpublic void scale(double d,
double d1)
scale in class Graphics2Dpublic void setBackground(Color c)
setBackground in class Graphics2Dpublic void setComposite(Composite composite)
setComposite in class Graphics2Dpublic void setPaint(Paint paint1)
setPaint in class Graphics2Dpublic void setPaintMode()
setPaintMode in class Graphicspublic void setRenderingHint(RenderingHints.Key key, Object obj)
setRenderingHint in class Graphics2Dpublic void setRenderingHints(Map map)
setRenderingHints in class Graphics2Dpublic void setStroke(Stroke s)
setStroke in class Graphics2Dpublic void setTransform(AffineTransform affinetransform)
setTransform in class Graphics2Dpublic void setXORMode(Color color1)
setXORMode in class Graphicspublic void shear(double d,
double d1)
shear in class Graphics2Dpublic void transform(AffineTransform affinetransform)
transform in class Graphics2Dpublic void translate(double d,
double d1)
translate in class Graphics2Dpublic void translate(int i,
int j)
translate in class Graphics2Dprivate EscherGraphics getEscherGraphics()
private BufferedImage getImg()
private void setImg(BufferedImage img)
private Graphics2D getG2D()
private AffineTransform getTrans()
private void setTrans(AffineTransform trans)
private Shape getDeviceclip()
private void setDeviceclip(Shape deviceclip)
Copyright © 2016 Open Microscopy Environment