Translates Graphics calls into escher calls. The translation is lossy so
many features are not supported and some just aren't implemented yet. If
in doubt test the specific calls you wish to make. Graphics calls are
always performed into an EscherGroup so one will need to be created.
| Method from org.apache.poi.hssf.usermodel.EscherGraphics Detail: |
public void clearRect(int x,
int y,
int width,
int height) {
Color color = foreground;
setColor(background);
fillRect(x,y,width,height);
setColor(color);
}
|
public void clipRect(int x,
int y,
int width,
int height) {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"clipRect not supported");
}
|
public void copyArea(int x,
int y,
int width,
int height,
int dx,
int dy) {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"copyArea not supported");
}
|
public Graphics create() {
EscherGraphics g = new EscherGraphics(escherGroup, workbook,
foreground, font, verticalPointsPerPixel );
return g;
}
|
public void dispose() {
}
|
public void drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle) {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"drawArc not supported");
}
|
public boolean drawImage(Image image,
int i,
int j,
ImageObserver imageobserver) {
return drawImage(image, i, j, image.getWidth(imageobserver), image.getHeight(imageobserver), imageobserver);
}
|
public boolean drawImage(Image image,
int i,
int j,
Color color,
ImageObserver imageobserver) {
return drawImage(image, i, j, image.getWidth(imageobserver), image.getHeight(imageobserver), color, imageobserver);
}
|
public boolean drawImage(Image image,
int i,
int j,
int k,
int l,
ImageObserver imageobserver) {
return drawImage(image, i, j, i + k, j + l, 0, 0, image.getWidth(imageobserver), image.getHeight(imageobserver), imageobserver);
}
|
public boolean drawImage(Image image,
int i,
int j,
int k,
int l,
Color color,
ImageObserver imageobserver) {
return drawImage(image, i, j, i + k, j + l, 0, 0, image.getWidth(imageobserver), image.getHeight(imageobserver), color, imageobserver);
}
|
public boolean drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
ImageObserver observer) {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"drawImage not supported");
return true;
}
|
public boolean drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
Color bgcolor,
ImageObserver observer) {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"drawImage not supported");
return true;
}
|
public void drawLine(int x1,
int y1,
int x2,
int y2) {
drawLine(x1,y1,x2,y2,0);
}
|
public void drawLine(int x1,
int y1,
int x2,
int y2,
int width) {
HSSFSimpleShape shape = escherGroup.createShape(new HSSFChildAnchor(x1, y1, x2, y2) );
shape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
shape.setLineWidth(width);
shape.setLineStyleColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());
}
|
public void drawOval(int x,
int y,
int width,
int height) {
HSSFSimpleShape shape = escherGroup.createShape(new HSSFChildAnchor(x,y,x+width,y+height) );
shape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_OVAL);
shape.setLineWidth(0);
shape.setLineStyleColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());
shape.setNoFill(true);
}
|
public void drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints) {
int right = findBiggest(xPoints);
int bottom = findBiggest(yPoints);
int left = findSmallest(xPoints);
int top = findSmallest(yPoints);
HSSFPolygon shape = escherGroup.createPolygon(new HSSFChildAnchor(left,top,right,bottom) );
shape.setPolygonDrawArea(right - left, bottom - top);
shape.setPoints(addToAll(xPoints, -left), addToAll(yPoints, -top));
shape.setLineStyleColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());
shape.setLineWidth(0);
shape.setNoFill(true);
}
|
public void drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints) {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"drawPolyline not supported");
}
|
public void drawRect(int x,
int y,
int width,
int height) {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"drawRect not supported");
}
|
public void drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight) {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"drawRoundRect not supported");
}
|
public void drawString(String str,
int x,
int y) {
if (str == null || str.equals(""))
return;
Font excelFont = font;
if ( font.getName().equals( "SansSerif" ) )
{
excelFont = new Font( "Arial", font.getStyle(), (int) ( font.getSize() / verticalPixelsPerPoint ) );
}
else
{
excelFont = new Font( font.getName(), font.getStyle(), (int) ( font.getSize() / verticalPixelsPerPoint ));
}
FontDetails d = StaticFontMetrics.getFontDetails( excelFont );
int width = (int) ( (d.getStringWidth( str ) * 8) + 12 );
int height = (int) ( ( font.getSize() / verticalPixelsPerPoint ) + 6 ) * 2;
y -= ( font.getSize() / verticalPixelsPerPoint ) + 2 * verticalPixelsPerPoint; // we want to draw the shape from the top-left
HSSFTextbox textbox = escherGroup.createTextbox( new HSSFChildAnchor( x, y, x + width, y + height ) );
textbox.setNoFill( true );
textbox.setLineStyle( HSSFShape.LINESTYLE_NONE );
HSSFRichTextString s = new HSSFRichTextString( str );
HSSFFont hssfFont = matchFont( excelFont );
s.applyFont( hssfFont );
textbox.setString( s );
}
|
public void drawString(AttributedCharacterIterator iterator,
int x,
int y) {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"drawString not supported");
}
|
public void fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle) {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"fillArc not supported");
}
|
public void fillOval(int x,
int y,
int width,
int height) {
HSSFSimpleShape shape = escherGroup.createShape(new HSSFChildAnchor( x, y, x + width, y + height ) );
shape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_OVAL);
shape.setLineStyle(HSSFShape.LINESTYLE_NONE);
shape.setFillColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());
shape.setLineStyleColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());
}
|
public void fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints) {
int right = findBiggest(xPoints);
int bottom = findBiggest(yPoints);
int left = findSmallest(xPoints);
int top = findSmallest(yPoints);
HSSFPolygon shape = escherGroup.createPolygon(new HSSFChildAnchor(left,top,right,bottom) );
shape.setPolygonDrawArea(right - left, bottom - top);
shape.setPoints(addToAll(xPoints, -left), addToAll(yPoints, -top));
shape.setLineStyleColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());
shape.setFillColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());
}
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 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. |
public void fillRect(int x,
int y,
int width,
int height) {
HSSFSimpleShape shape = escherGroup.createShape(new HSSFChildAnchor( x, y, x + width, y + height ) );
shape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE);
shape.setLineStyle(HSSFShape.LINESTYLE_NONE);
shape.setFillColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());
shape.setLineStyleColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());
}
|
public void fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight) {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"fillRoundRect not supported");
}
|
public Color getBackground() {
return background;
}
|
public Shape getClip() {
return getClipBounds();
}
|
public Rectangle getClipBounds() {
return null;
}
|
public Rectangle getClipRect() {
return getClipBounds();
}
|
public Color getColor() {
return foreground;
}
|
HSSFShapeGroup getEscherGraphics() {
return escherGroup;
}
|
public Font getFont() {
return font;
}
|
public FontMetrics getFontMetrics(Font f) {
return Toolkit.getDefaultToolkit().getFontMetrics(f);
}
|
public void setBackground(Color background) {
this.background = background;
}
|
public void setClip(Shape shape) {
// ignore... not implemented
}
|
public void setClip(int x,
int y,
int width,
int height) {
setClip(((Shape) (new Rectangle(x,y,width,height))));
}
|
public void setColor(Color color) {
foreground = color;
}
|
public void setFont(Font f) {
font = f;
}
|
public void setPaintMode() {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"setPaintMode not supported");
}
|
public void setXORMode(Color color) {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"setXORMode not supported");
}
|
public void translate(int x,
int y) {
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"translate not supported");
}
|