AndroidGraphics2Dpublic class AndroidGraphics2D extends Graphics2D
Fields Summary |
---|
private int | displayWidth | private int | displayHeight | protected org.apache.harmony.awt.gl.Surface | dstSurf | protected org.apache.harmony.awt.gl.MultiRectArea | clip | protected Composite | composite | protected AffineTransform | transform | private static AndroidGraphics2D | mAg | private static android.graphics.Canvas | mC | public static android.graphics.Paint | mP | private static Font | mFnt | public static android.graphics.Matrix | mM | private static FontMetrics | mFm | private static RenderingHints | mRh | private static Color | mBc | private Area | mCurrClip | public static final double | RAD_360 | private AndroidJavaBlitter | blitter | private DirectColorModel | cm | private SinglePixelPackedSampleModel | sm | private WritableRaster | wr |
Constructors Summary |
---|
private AndroidGraphics2D(android.content.Context ctx, android.graphics.Canvas c, android.graphics.Paint p)
super();
mC = c;
mP = p;
mM = new Matrix();
mM.reset();
mM = mC.getMatrix();
Rect r = mC.getClipBounds();
int cl[] = {-1, r.top, r.left, -2, r.top, r.right, -2, r.bottom, r.right, -2, r.bottom, r.left};
mCurrClip = new Area(createShape(cl));
if(ctx != null) {
WindowManager wm = (WindowManager)ctx.getSystemService(Context.WINDOW_SERVICE);
Display d = wm.getDefaultDisplay();
displayWidth = d.getWidth();
displayHeight = d.getHeight();
}
blitter = new AndroidJavaBlitter(c);
cm = new DirectColorModel(32, 0xff0000, 0xff00, 0xff, 0xff000000);
sm = new SinglePixelPackedSampleModel(
DataBuffer.TYPE_INT, displayWidth, displayHeight, cm.getMasks());
wr = Raster.createWritableRaster(sm, null);
dstSurf = new ImageSurface(cm, wr);
|
Methods Summary |
---|
public void | addRenderingHints(java.util.Map hints)
if (mRh == null) {
mRh = (RenderingHints) hints;
}
mRh.add((RenderingHints) hints);
| private void | applyHints()
Object o;
// TODO do something like this:
/*
* Set s = mRh.keySet(); Iterator it = s.iterator(); while(it.hasNext()) {
* o = it.next(); }
*/
// /////////////////////////////////////////////////////////////////////
// not supported in skia
/*
* o = mRh.get(RenderingHints.KEY_ALPHA_INTERPOLATION); if
* (o.equals(RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT)) { } else
* if (o.equals(RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY)) { }
* else if (o.equals(RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED)) { }
*
* o = mRh.get(RenderingHints.KEY_COLOR_RENDERING); if
* (o.equals(RenderingHints.VALUE_COLOR_RENDER_DEFAULT)) { } else if
* (o.equals(RenderingHints.VALUE_COLOR_RENDER_QUALITY)) { } else if
* (o.equals(RenderingHints.VALUE_COLOR_RENDER_SPEED)) { }
*
* o = mRh.get(RenderingHints.KEY_DITHERING); if
* (o.equals(RenderingHints.VALUE_DITHER_DEFAULT)) { } else if
* (o.equals(RenderingHints.VALUE_DITHER_DISABLE)) { } else if
* (o.equals(RenderingHints.VALUE_DITHER_ENABLE)) { }
*
* o = mRh.get(RenderingHints.KEY_FRACTIONALMETRICS); if
* (o.equals(RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT)) { } else
* if (o.equals(RenderingHints.VALUE_FRACTIONALMETRICS_OFF)) { } else if
* (o.equals(RenderingHints.VALUE_FRACTIONALMETRICS_ON)) { }
*
* o = mRh.get(RenderingHints.KEY_INTERPOLATION); if
* (o.equals(RenderingHints.VALUE_INTERPOLATION_BICUBIC)) { } else if
* (o.equals(RenderingHints.VALUE_INTERPOLATION_BILINEAR)) { } else if
* (o .equals(RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR)) { }
*
* o = mRh.get(RenderingHints.KEY_RENDERING); if
* (o.equals(RenderingHints.VALUE_RENDER_DEFAULT)) { } else if
* (o.equals(RenderingHints.VALUE_RENDER_QUALITY)) { } else if
* (o.equals(RenderingHints.VALUE_RENDER_SPEED)) { }
*
* o = mRh.get(RenderingHints.KEY_STROKE_CONTROL); if
* (o.equals(RenderingHints.VALUE_STROKE_DEFAULT)) { } else if
* (o.equals(RenderingHints.VALUE_STROKE_NORMALIZE)) { } else if
* (o.equals(RenderingHints.VALUE_STROKE_PURE)) { }
*/
o = mRh.get(RenderingHints.KEY_ANTIALIASING);
if (o != null) {
if (o.equals(RenderingHints.VALUE_ANTIALIAS_DEFAULT)) {
mP.setAntiAlias(false);
} else if (o.equals(RenderingHints.VALUE_ANTIALIAS_OFF)) {
mP.setAntiAlias(false);
} else if (o.equals(RenderingHints.VALUE_ANTIALIAS_ON)) {
mP.setAntiAlias(true);
}
}
o = mRh.get(RenderingHints.KEY_TEXT_ANTIALIASING);
if (o != null) {
if (o.equals(RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT)) {
mP.setAntiAlias(false);
} else if (o.equals(RenderingHints.VALUE_TEXT_ANTIALIAS_OFF)) {
mP.setAntiAlias(false);
} else if (o.equals(RenderingHints.VALUE_TEXT_ANTIALIAS_ON)) {
mP.setAntiAlias(true);
}
}
| public void | clearRect(int x, int y, int width, int height)
mC.clipRect(x, y, x + width, y + height);
if (mBc != null) {
mC.drawARGB(mBc.getAlpha(), mBc.getBlue(), mBc.getGreen(), mBc
.getRed());
} else {
mC.drawARGB(0xff, 0xff, 0xff, 0xff);
}
| public void | clip(java.awt.Shape s)
mC.clipPath(getPath(s));
| public void | clipRect(int x, int y, int width, int height)
int cl[] = {-1, x, y, -2, x, y + width, -2, x + height, y + width, -2, x + height, y};
Shape shp = createShape(cl);
mCurrClip.intersect(new Area(shp));
mC.clipRect(new Rect(x, y, x + width, y + height), Region.Op.INTERSECT);
| public void | copyArea(android.graphics.Canvas canvas, int sx, int sy, int width, int height, int dx, int dy)
sx += getTransform().getTranslateX();
sy += getTransform().getTranslateY();
NativeUtils.nativeScrollRect(canvas,
new Rect(sx, sy, sx + width, sy + height),
dx, dy);
| public void | copyArea(int sx, int sy, int width, int height, int dx, int dy)
copyArea(mC, sx, sy, width + dx, height + dy, dx, dy);
| public java.awt.Graphics | create()
return this;
| private float[] | createAWTMatrix(float[] matrix)
float[] at = new float[9];
at[0] = matrix[0];
at[1] = matrix[3];
at[2] = matrix[1];
at[3] = matrix[4];
at[4] = matrix[2];
at[5] = matrix[5];
at[6] = 0;
at[7] = 0;
at[8] = 1;
return at;
| public static float[] | createMatrix(java.awt.geom.AffineTransform Tx)
double[] at = new double[9];
Tx.getMatrix(at);
float[] f = new float[at.length];
f[0] = (float) at[0];
f[1] = (float) at[2];
f[2] = (float) at[4];
f[3] = (float) at[1];
f[4] = (float) at[3];
f[5] = (float) at[5];
f[6] = 0;
f[7] = 0;
f[8] = 1;
return f;
| public static android.graphics.Matrix | createMatrixObj(java.awt.geom.AffineTransform Tx)
Matrix m = new Matrix();
m.reset();
m.setValues(createMatrix(Tx));
return m;
| private java.awt.Shape | createShape(int[] arr)
Shape s = new GeneralPath();
for(int i = 0; i < arr.length; i++) {
int type = arr[i];
switch (type) {
case -1:
//MOVETO
((GeneralPath)s).moveTo(arr[++i], arr[++i]);
break;
case -2:
//LINETO
((GeneralPath)s).lineTo(arr[++i], arr[++i]);
break;
case -3:
//QUADTO
((GeneralPath)s).quadTo(arr[++i], arr[++i], arr[++i],
arr[++i]);
break;
case -4:
//CUBICTO
((GeneralPath)s).curveTo(arr[++i], arr[++i], arr[++i],
arr[++i], arr[++i], arr[++i]);
break;
case -5:
//CLOSE
return s;
default:
break;
}
}
return s;
| public void | dispose()
mC = null;
mP = null;
| public void | draw(java.awt.Shape s)
if (mP == null) {
mP = new Paint();
}
Paint.Style tmp = mP.getStyle();
mP.setStyle(Paint.Style.STROKE);
mC.drawPath(getPath(s), mP);
mP.setStyle(tmp);
| public void | draw(android.graphics.Path s)
if (mP == null) {
mP = new Paint();
}
Paint.Style tmp = mP.getStyle();
mP.setStyle(Paint.Style.STROKE);
s.transform(mM);
mC.drawPath(s, mP);
mP.setStyle(tmp);
| public void | draw3DRect(int x, int y, int width, int height, boolean raised)
Color color = getColor();
Color colorUp, colorDown;
if (raised) {
colorUp = color.brighter();
colorDown = color.darker();
} else {
colorUp = color.darker();
colorDown = color.brighter();
}
setColor(colorUp);
fillRect(x, y, width, 1);
fillRect(x, y+1, 1, height);
setColor(colorDown);
fillRect(x+width, y, 1, height);
fillRect(x+1, y+height, width, 1);
| public void | drawArc(int x, int y, int width, int height, int sa, int ea)
if (mP == null) {
mP = new Paint();
}
mP.setStrokeWidth(0);
mC.drawArc(new RectF(x, y, x + width, y + height), 360 - (ea + sa),
ea, true, mP);
| public void | drawBitmap(android.graphics.Bitmap bm, float x, float y, android.graphics.Paint p)
mC.drawBitmap(bm, x, y, null);
| public void | drawBytes(byte[] data, int offset, int length, int x, int y)
drawString(new String(data, offset, length), x, y);
| public void | drawChars(char[] data, int offset, int length, int x, int y)
mC.drawText(data, offset, length, x, y, mP);
| public void | drawGlyphVector(java.awt.font.GlyphVector g, float x, float y)
// TODO draw at x, y
// draw(g.getOutline());
/*
Matrix matrix = new Matrix();
matrix.setTranslate(x, y);
Path pth = getPath(g.getOutline());
pth.transform(matrix);
draw(pth);
*/
Path path = new Path();
char[] c = ((AndroidGlyphVector)g).getGlyphs();
mP.getTextPath(c, 0, c.length, x, y, path);
mC.drawPath(path, mP);
| public boolean | drawImage(java.awt.Image image, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver imageObserver)
if(image == null) {
return true;
}
boolean done = false;
boolean somebits = false;
Surface srcSurf = null;
if(image instanceof OffscreenImage){
OffscreenImage oi = (OffscreenImage) image;
if((oi.getState() & ImageObserver.ERROR) != 0) {
return false;
}
done = oi.prepareImage(imageObserver);
somebits = (oi.getState() & ImageObserver.SOMEBITS) != 0;
srcSurf = oi.getImageSurface();
}else{
done = true;
srcSurf = Surface.getImageSurface(image);
}
if(done || somebits) {
int w = srcSurf.getWidth();
int h = srcSurf.getHeight();
blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h, (AffineTransform) transform.clone(),
composite, bgcolor, clip);
}
return done;
| public boolean | drawImage(java.awt.Image image, int x, int y, java.awt.image.ImageObserver imageObserver)
return drawImage(image, x, y, null, imageObserver);
| public boolean | drawImage(java.awt.Image image, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver imageObserver)
if(image == null) {
return true;
}
if(width == 0 || height == 0) {
return true;
}
boolean done = false;
boolean somebits = false;
Surface srcSurf = null;
if(image instanceof OffscreenImage){
OffscreenImage oi = (OffscreenImage) image;
if((oi.getState() & ImageObserver.ERROR) != 0) {
return false;
}
done = oi.prepareImage(imageObserver);
somebits = (oi.getState() & ImageObserver.SOMEBITS) != 0;
srcSurf = oi.getImageSurface();
}else{
done = true;
srcSurf = Surface.getImageSurface(image);
}
if(done || somebits) {
int w = srcSurf.getWidth();
int h = srcSurf.getHeight();
if(w == width && h == height){
blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h,
(AffineTransform) transform.clone(),
composite, bgcolor, clip);
}else{
AffineTransform xform = new AffineTransform();
xform.setToScale((float)width / w, (float)height / h);
blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h,
(AffineTransform) transform.clone(),
xform, composite, bgcolor, clip);
}
}
return done;
| public boolean | drawImage(java.awt.Image image, int x, int y, int width, int height, java.awt.image.ImageObserver imageObserver)
return drawImage(image, x, y, width, height, null, imageObserver);
| public boolean | drawImage(java.awt.Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver imageObserver)
if(image == null) {
return true;
}
if(dx1 == dx2 || dy1 == dy2 || sx1 == sx2 || sy1 == sy2) {
return true;
}
boolean done = false;
boolean somebits = false;
Surface srcSurf = null;
if(image instanceof OffscreenImage){
OffscreenImage oi = (OffscreenImage) image;
if((oi.getState() & ImageObserver.ERROR) != 0) {
return false;
}
done = oi.prepareImage(imageObserver);
somebits = (oi.getState() & ImageObserver.SOMEBITS) != 0;
srcSurf = oi.getImageSurface();
}else{
done = true;
srcSurf = Surface.getImageSurface(image);
}
if(done || somebits) {
int dstX = dx1;
int dstY = dy1;
int srcX = sx1;
int srcY = sy1;
int dstW = dx2 - dx1;
int dstH = dy2 - dy1;
int srcW = sx2 - sx1;
int srcH = sy2 - sy1;
if(srcW == dstW && srcH == dstH){
blitter.blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf, srcW, srcH,
(AffineTransform) transform.clone(),
composite, bgcolor, clip);
}else{
AffineTransform xform = new AffineTransform();
xform.setToScale((float)dstW / srcW, (float)dstH / srcH);
blitter.blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf, srcW, srcH,
(AffineTransform) transform.clone(),
xform, composite, bgcolor, clip);
}
}
return done;
| public boolean | drawImage(java.awt.Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver imageObserver)
return drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null,
imageObserver);
| public void | drawImage(java.awt.image.BufferedImage bufImage, java.awt.image.BufferedImageOp op, int x, int y)
if(bufImage == null) {
return;
}
if(op == null) {
drawImage(bufImage, x, y, null);
} else if(op instanceof AffineTransformOp){
AffineTransformOp atop = (AffineTransformOp) op;
AffineTransform xform = atop.getTransform();
Surface srcSurf = Surface.getImageSurface(bufImage);
int w = srcSurf.getWidth();
int h = srcSurf.getHeight();
blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h,
(AffineTransform) transform.clone(), xform,
composite, null, clip);
} else {
bufImage = op.filter(bufImage, null);
Surface srcSurf = Surface.getImageSurface(bufImage);
int w = srcSurf.getWidth();
int h = srcSurf.getHeight();
blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h,
(AffineTransform) transform.clone(),
composite, null, clip);
}
| public boolean | drawImage(java.awt.Image image, java.awt.geom.AffineTransform trans, java.awt.image.ImageObserver imageObserver)
if(image == null) {
return true;
}
if(trans == null || trans.isIdentity()) {
return drawImage(image, 0, 0, imageObserver);
}
boolean done = false;
boolean somebits = false;
Surface srcSurf = null;
if(image instanceof OffscreenImage){
OffscreenImage oi = (OffscreenImage) image;
if((oi.getState() & ImageObserver.ERROR) != 0) {
return false;
}
done = oi.prepareImage(imageObserver);
somebits = (oi.getState() & ImageObserver.SOMEBITS) != 0;
srcSurf = oi.getImageSurface();
}else{
done = true;
srcSurf = Surface.getImageSurface(image);
}
if(done || somebits) {
int w = srcSurf.getWidth();
int h = srcSurf.getHeight();
AffineTransform xform = (AffineTransform) transform.clone();
xform.concatenate(trans);
blitter.blit(0, 0, srcSurf, 0, 0, dstSurf, w, h, xform, composite,
null, clip);
}
return done;
| public void | drawLine(int x1, int y1, int x2, int y2)
if (mP == null) {
mP = new Paint();
}
mC.drawLine(x1, y1, x2, y2, mP);
| public void | drawOval(int x, int y, int width, int height)
if (mP == null) {
mP = new Paint();
}
mP.setStyle(Paint.Style.STROKE);
mC.drawOval(new RectF(x, y, x + width, y + height), mP);
| public void | drawPolygon(int[] xpoints, int[] ypoints, int npoints)
if (mP == null) {
mP = new Paint();
}
mC.drawLine(xpoints[npoints - 1], ypoints[npoints - 1], xpoints[0],
ypoints[0], mP);
for (int i = 0; i < npoints - 1; i++) {
mC.drawLine(xpoints[i], ypoints[i], xpoints[i + 1],
ypoints[i + 1], mP);
}
| public void | drawPolygon(java.awt.Polygon p)
drawPolygon(p.xpoints, p.ypoints, p.npoints);
| public void | drawPolyline(int[] xpoints, int[] ypoints, int npoints)
for (int i = 0; i < npoints - 1; i++) {
drawLine(xpoints[i], ypoints[i], xpoints[i + 1], ypoints[i + 1]);
}
| public void | drawRect(int x, int y, int width, int height)
int[] xpoints = { x, x, x + width, x + width };
int[] ypoints = { y, y + height, y + height, y };
drawPolygon(xpoints, ypoints, 4);
| public void | drawRenderableImage(java.awt.image.renderable.RenderableImage img, java.awt.geom.AffineTransform xform)
throw new RuntimeException("Not implemented!");
| public void | drawRenderedImage(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)
throw new RuntimeException("Not implemented!");
| public void | drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
if (mP == null) {
mP = new Paint();
}
mC.drawRoundRect(new RectF(x, y, width, height), arcWidth,
arcHeight, mP);
| public void | drawString(java.text.AttributedCharacterIterator iterator, float x, float y)
throw new RuntimeException("AttributedCharacterIterator not supported!");
| public void | drawString(java.text.AttributedCharacterIterator iterator, int x, int y)
throw new RuntimeException("AttributedCharacterIterator not supported!");
| public void | drawString(java.lang.String s, float x, float y)
if (mP == null) {
mP = new Paint();
}
Paint.Style tmp = mP.getStyle();
mP.setStyle(Paint.Style.FILL);
Path pth = new Path();
mP.getTextPath(s, 0, s.length(), x, y, pth);
mC.drawPath(pth, mP);
mP.setStyle(tmp);
| public void | drawString(java.lang.String str, int x, int y)
if (mP == null) {
mP = new Paint();
}
Paint.Style tmp = mP.getStyle();
mP.setStrokeWidth(0);
mC.drawText(str.toCharArray(), 0, str.toCharArray().length, x, y,
mP);
mP.setStyle(tmp);
| public void | fill(java.awt.Shape s)
if (mP == null) {
mP = new Paint();
}
Paint.Style tmp = mP.getStyle();
mP.setStyle(Paint.Style.FILL);
mC.drawPath(getPath(s), mP);
mP.setStyle(tmp);
| public void | fill3DRect(int x, int y, int width, int height, boolean raised)
Color color = getColor();
Color colorUp, colorDown;
if (raised) {
colorUp = color.brighter();
colorDown = color.darker();
setColor(color);
} else {
colorUp = color.darker();
colorDown = color.brighter();
setColor(colorUp);
}
width--;
height--;
fillRect(x+1, y+1, width-1, height-1);
setColor(colorUp);
fillRect(x, y, width, 1);
fillRect(x, y+1, 1, height);
setColor(colorDown);
fillRect(x+width, y, 1, height);
fillRect(x+1, y+height, width, 1);
| public void | fillArc(int x, int y, int width, int height, int sa, int ea)
if (mP == null) {
mP = new Paint();
}
Paint.Style tmp = mP.getStyle();
mP.setStyle(Paint.Style.FILL_AND_STROKE);
mC.drawArc(new RectF(x, y, x + width, y + height), 360 - (sa + ea),
ea, true, mP);
mP.setStyle(tmp);
| public void | fillOval(int x, int y, int width, int height)
if (mP == null) {
mP = new Paint();
}
Paint.Style tmp = mP.getStyle();
mP.setStyle(Paint.Style.FILL);
mC.drawOval(new RectF(x, y, x + width, y + height), mP);
mP.setStyle(tmp);
| public void | fillPolygon(int[] xpoints, int[] ypoints, int npoints)
if (mP == null) {
mP = new Paint();
}
Paint.Style tmp = mP.getStyle();
mC.save(Canvas.CLIP_SAVE_FLAG);
mP.setStyle(Paint.Style.FILL);
GeneralPath filledPolygon = new GeneralPath(
GeneralPath.WIND_EVEN_ODD, npoints);
filledPolygon.moveTo(xpoints[0], ypoints[0]);
for (int index = 1; index < xpoints.length; index++) {
filledPolygon.lineTo(xpoints[index], ypoints[index]);
}
filledPolygon.closePath();
Path path = getPath(filledPolygon);
mC.clipPath(path);
mC.drawPath(path, mP);
mP.setStyle(tmp);
mC.restore();
| public void | fillPolygon(java.awt.Polygon p)
fillPolygon(p.xpoints, p.ypoints, p.npoints);
| public void | fillRect(int x, int y, int width, int height)
if (mP == null) {
mP = new Paint();
}
Paint.Style tmp = mP.getStyle();
mP.setStyle(Paint.Style.FILL);
mC.drawRect(new Rect(x, y, x + width, y + height), mP);
mP.setStyle(tmp);
| public void | fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
if (mP == null) {
mP = new Paint();
}
mP.setStyle(Paint.Style.FILL);
mC.drawRoundRect(new RectF(x, y, x + width, y + height), arcWidth,
arcHeight, mP);
| public static android.graphics.Canvas | getAndroidCanvas()
return mC;
| public static android.graphics.Paint | getAndroidPaint()
return mP;
| public java.awt.Color | getBackground()
return mBc;
| public java.awt.Shape | getClip()
return mCurrClip;
| public java.awt.Rectangle | getClipBounds()
Rect r = mC.getClipBounds();
return new Rectangle(r.left, r.top, r.width(), r.height());
| public java.awt.Rectangle | getClipBounds(java.awt.Rectangle r)
Shape clip = getClip();
if (clip != null) {
Rectangle b = clip.getBounds();
r.x = b.x;
r.y = b.y;
r.width = b.width;
r.height = b.height;
}
return r;
| public java.awt.Color | getColor()
if (mP != null) {
return new Color(mP.getColor());
}
return null;
| public java.awt.Composite | getComposite()
throw new RuntimeException("Composite not implemented!");
| private void | getCurrentSegment(java.awt.geom.PathIterator pi, android.graphics.Path path)
float[] coordinates = new float[6];
int type = pi.currentSegment(coordinates);
switch (type) {
case PathIterator.SEG_MOVETO:
path.moveTo(coordinates[0], coordinates[1]);
break;
case PathIterator.SEG_LINETO:
path.lineTo(coordinates[0], coordinates[1]);
break;
case PathIterator.SEG_QUADTO:
path.quadTo(coordinates[0], coordinates[1], coordinates[2],
coordinates[3]);
break;
case PathIterator.SEG_CUBICTO:
path.cubicTo(coordinates[0], coordinates[1], coordinates[2],
coordinates[3], coordinates[4], coordinates[5]);
break;
case PathIterator.SEG_CLOSE:
path.close();
break;
default:
break;
}
| public static float | getDegree(float radian)
return (float) ((180 / Math.PI) * radian);
| public java.awt.GraphicsConfiguration | getDeviceConfiguration()
return new AndroidGraphicsConfiguration();
| public static float | getEllipsisX(float degree, float princAxis)
return (float) Math.cos(degree) * princAxis;
| public static float | getEllipsisY(float degree, float conAxis)
return (float) Math.sin(degree) * conAxis;
| public java.awt.Font | getFont()
return mFnt;
| public java.awt.FontMetrics | getFontMetrics(java.awt.Font font)
mFm = new FontMetricsImpl(font);
return mFm;
| public java.awt.font.FontRenderContext | getFontRenderContext()
return new FontRenderContext(getTransform(), mP.isAntiAlias(), true);
| public static com.android.internal.awt.AndroidGraphics2D | getInstance()
if (mAg == null) {
throw new RuntimeException("AndroidGraphics2D not instantiated!");
}
return mAg;
| public static com.android.internal.awt.AndroidGraphics2D | getInstance(android.content.Context ctx, android.graphics.Canvas c, android.graphics.Paint p)
if (c == null || ctx == null) {
throw new RuntimeException(
"Illegal argument, Canvas cannot be null!");
}
mAg = new AndroidGraphics2D(ctx, c, p);
return mAg;
| public float[] | getInverseMatrix()
AffineTransform af = new AffineTransform(createAWTMatrix(getMatrix()));
try {
af = af.createInverse();
} catch (NoninvertibleTransformException e) {
}
return createMatrix(af);
| public float[] | getMatrix()
float[] f = new float[9];
mC.getMatrix().getValues(f);
return f;
| public java.awt.Paint | getPaint()
throw new RuntimeException("AWT Paint not implemented in Android!");
| private android.graphics.Path | getPath(java.awt.Shape s)
Path path = new Path();
PathIterator pi = s.getPathIterator(null);
while (pi.isDone() == false) {
getCurrentSegment(pi, path);
pi.next();
}
return path;
| public static float | getRadian(float degree)
return (float) ((Math.PI / 180) * degree);
| public java.lang.Object | getRenderingHint(java.awt.RenderingHints$Key key)
if (mRh == null) {
return null;
}
return mRh.get(key);
| public java.awt.RenderingHints | getRenderingHints()
return mRh;
| private java.awt.Shape | getShape()
return null;
| public java.awt.Stroke | getStroke()
if (mP != null) {
return new BasicStroke(mP.getStrokeWidth(), mP.getStrokeCap()
.ordinal(), mP.getStrokeJoin().ordinal());
}
return null;
| public java.awt.geom.AffineTransform | getTransform()
return new AffineTransform(createAWTMatrix(getMatrix()));
| public boolean | hit(java.awt.Rectangle rect, java.awt.Shape s, boolean onStroke)
// ???AWT TODO check if on stroke
return s.intersects(rect.getX(), rect.getY(), rect.getWidth(), rect
.getHeight());
| public boolean | hitClip(int x, int y, int width, int height)
return getClipBounds().intersects(new Rectangle(x, y, width, height));
| public void | rotate(double theta)
mM.preRotate((float) AndroidGraphics2D
.getDegree((float) (RAD_360 - theta)));
mC.concat(mM);
| public void | rotate(double theta, double x, double y)
mM.preRotate((float) AndroidGraphics2D.getDegree((float) theta),
(float) x, (float) y);
mC.concat(mM);
| public void | scale(double sx, double sy)
mM.setScale((float) sx, (float) sy);
mC.concat(mM);
| public void | setBackground(java.awt.Color color)
mBc = color;
mC.clipRect(new Rect(0, 0, mC.getWidth(), mC.getHeight()));
// TODO don't limit to current clip
mC.drawARGB(color.getAlpha(), color.getRed(), color.getGreen(), color
.getBlue());
| public void | setCanvas(android.graphics.Canvas c)
mC = c;
| public void | setClip(int x, int y, int width, int height)
int cl[] = {-1, x, y, -2, x, y + width, -2, x + height, y + width, -2, x + height, y};
mCurrClip = new Area(createShape(cl));
mC.clipRect(x, y, x + width, y + height, Region.Op.REPLACE);
| public void | setClip(java.awt.Shape clip)
mCurrClip = new Area(clip);
mC.clipPath(getPath(clip), Region.Op.REPLACE);
| public void | setColor(java.awt.Color c)
if (mP == null) {
mP = new Paint();
}
mP.setColor(c.getRGB());
| public void | setComposite(java.awt.Composite comp)
throw new RuntimeException("Composite not implemented!");
| public void | setFont(java.awt.Font font)Font mapping:
Family:
Android AWT
-------------------------------------
serif Serif / TimesRoman
sans-serif SansSerif / Helvetica
monospace Monospaced / Courier
Style:
Android AWT
-------------------------------------
normal Plain
bold bold
italic italic
if (font == null) {
return;
}
if (mP == null) {
mP = new Paint();
}
mFnt = font;
Typeface tf = null;
int sty = font.getStyle();
String nam = font.getName();
String aF = "";
if (nam != null) {
if (nam.equalsIgnoreCase("Serif")
|| nam.equalsIgnoreCase("TimesRoman")) {
aF = "serif";
} else if (nam.equalsIgnoreCase("SansSerif")
|| nam.equalsIgnoreCase("Helvetica")) {
aF = "sans-serif";
} else if (nam.equalsIgnoreCase("Monospaced")
|| nam.equalsIgnoreCase("Courier")) {
aF = "monospace";
}
}
switch (sty) {
case Font.PLAIN:
tf = Typeface.create(aF, Typeface.NORMAL);
break;
case Font.BOLD:
tf = Typeface.create(aF, Typeface.BOLD);
break;
case Font.ITALIC:
tf = Typeface.create(aF, Typeface.ITALIC);
break;
case Font.BOLD | Font.ITALIC:
tf = Typeface.create(aF, Typeface.BOLD_ITALIC);
break;
default:
tf = Typeface.DEFAULT;
}
mP.setTextSize(font.getSize());
mP.setTypeface(tf);
| public void | setPaint(java.awt.Paint paint)
setColor((Color)paint);
| public void | setPaintMode()
if (mP == null) {
mP = new Paint();
}
mP.setXfermode(null);
| public void | setRenderingHint(java.awt.RenderingHints$Key hintKey, java.lang.Object hintValue)
if (mRh == null) {
mRh = new RenderingHints(hintKey, hintValue);
} else {
mRh.put(hintKey, hintValue);
}
applyHints();
| public void | setRenderingHints(java.util.Map hints)
mRh = (RenderingHints) hints;
applyHints();
| public void | setSpaint(android.graphics.Paint paint)
mP = paint;
| public void | setStroke(java.awt.Stroke s)
if (mP == null) {
mP = new Paint();
}
BasicStroke bs = (BasicStroke) s;
mP.setStyle(Paint.Style.STROKE);
mP.setStrokeWidth(bs.getLineWidth());
int cap = bs.getEndCap();
if (cap == 0) {
mP.setStrokeCap(Paint.Cap.BUTT);
} else if (cap == 1) {
mP.setStrokeCap(Paint.Cap.ROUND);
} else if (cap == 2) {
mP.setStrokeCap(Paint.Cap.SQUARE);
}
int join = bs.getLineJoin();
if (join == 0) {
mP.setStrokeJoin(Paint.Join.MITER);
} else if (join == 1) {
mP.setStrokeJoin(Paint.Join.ROUND);
} else if (join == 2) {
mP.setStrokeJoin(Paint.Join.BEVEL);
}
| public void | setTransform(java.awt.geom.AffineTransform Tx)
mM.reset();
/*
* if(Tx.isIdentity()) { mM = new Matrix(); }
*/
mM.setValues(createMatrix(Tx));
Matrix m = new Matrix();
m.setValues(getInverseMatrix());
mC.concat(m);
mC.concat(mM);
| public void | setXORMode(java.awt.Color color)
if (mP == null) {
mP = new Paint();
}
mP.setXfermode(new PixelXorXfermode(color.getRGB()));
| public void | shear(double shx, double shy)
mM.setSkew((float) shx, (float) shy);
mC.concat(mM);
| public void | transform(java.awt.geom.AffineTransform Tx)
Matrix m = new Matrix();
m.setValues(createMatrix(Tx));
mC.concat(m);
| public void | translate(double tx, double ty)
mM.setTranslate((float) tx, (float) ty);
mC.concat(mM);
| public void | translate(int x, int y)
mM.setTranslate((float) x, (float) y);
mC.concat(mM);
|
|