Revision: 2469
http://sourceforge.net/p/swingme/code/2469
Author: yuranet
Date: 2021-06-23 11:41:23 +0000 (Wed, 23 Jun 2021)
Log Message:
-----------
slightly better clipping
Modified Paths:
--------------
iOSME/src/javax/microedition/lcdui/Graphics.java
Modified: iOSME/src/javax/microedition/lcdui/Graphics.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Graphics.java 2021-06-23 10:56:56 UTC (rev 2468)
+++ iOSME/src/javax/microedition/lcdui/Graphics.java 2021-06-23 11:41:23 UTC (rev 2469)
@@ -82,6 +82,17 @@
return ty;
}
+ public void setClip(int x, int y, int w, int h) {
+ CoreGraphics.CGContextResetClip(context);
+ CoreGraphics.CGContextClipToRect(context, getRect(x, y, w, h));
+ dirtyClip = true;
+ }
+
+ public void clipRect(int x, int y, int w, int h) {
+ CoreGraphics.CGContextClipToRect(context, getRect(x, y, w, h));
+ dirtyClip = true;
+ }
+
public int getClipX() {
return (int)getClipBounds().origin().x();
}
@@ -98,17 +109,41 @@
return (int)getClipBounds().size().height();
}
- public void clipRect(int x, int y, int w, int h) {
- CoreGraphics.CGContextClipToRect(context, new CGRect(new CGPoint(tx+x, ty+y), new CGSize(w, h)));
- dirtyClip = true;
+ private CGRect getClipBounds() {
+ if (dirtyClip) {
+ clipBounds = CoreGraphics.CGContextGetClipBoundingBox(context);
+ clipBounds.origin().setX(clipBounds.origin().x() - tx);
+ clipBounds.origin().setY(clipBounds.origin().y() - ty);
+ dirtyClip = false;
+ }
+ return clipBounds;
}
- public void setClip(int x, int y, int w, int h) {
- CoreGraphics.CGContextRestoreGState(context);
- CoreGraphics.CGContextSaveGState(context);
- clipRect(x, y, w, h);
+ public void setStrokeStyle(int stroke) {
+ this.stroke = stroke;
}
+ public int getStrokeStyle() {
+ return stroke;
+ }
+
+ public void setStrokeWidth(int i) {
+ CoreGraphics.CGContextSetLineWidth(context, i);
+ }
+
+ public int getStrokeWidth() {
+ // TODO keep local var for this
+ throw new UnsupportedOperationException();
+ //return (int) paint.getStrokeWidth();
+ }
+
+ public void setColor(int color) {
+ this.color = getColor(color);
+ CGColorRef cgColorRef = this.color.CGColor();
+ CoreGraphics.CGContextSetStrokeColorWithColor(context, cgColorRef);
+ CoreGraphics.CGContextSetFillColorWithColor(context, cgColorRef);
+ }
+
public int getColor() {
NFloatPtr alpha = PtrFactory.newNFloatReference();
NFloatPtr red = PtrFactory.newNFloatReference();
@@ -132,13 +167,19 @@
return UIColor.colorWithRedGreenBlueAlpha(red, green, blue, alpha);
}
- public void setColor(int color) {
- this.color = getColor(color);
- CGColorRef cgColorRef = this.color.CGColor();
- CoreGraphics.CGContextSetStrokeColorWithColor(context, cgColorRef);
- CoreGraphics.CGContextSetFillColorWithColor(context, cgColorRef);
+ public void scale(double sx, double sy) {
+ CoreGraphics.CGContextTranslateCTM(context, tx, ty);
+ CoreGraphics.CGContextScaleCTM(context, sx, sy);
+ CoreGraphics.CGContextTranslateCTM(context, - tx * sx, - ty * sy);
+
+ dirtyClip = true;
}
+ public void setColorMatrix(ColorMatrix cm) {
+ throw new UnsupportedOperationException();
+ //paint.setColorFilter( cm==null?null:new ColorMatrixColorFilter(cm) );
+ }
+
public void drawImage(javax.microedition.lcdui.Image image, int x, int y, int anchor) {
if (anchor == 0) {
@@ -175,17 +216,6 @@
}
public void drawLine(int x1, int y1, int x2, int y2) {
- if (x1 > x2) {
- x1++;
- } else {
- x2++;
- }
- if (y1 > y2) {
- y1++;
- } else {
- y2++;
- }
-
CoreGraphics.CGContextMoveToPoint(context, tx+x1, ty+y1); //start at this point
CoreGraphics.CGContextAddLineToPoint(context, tx+x2, ty+y2); //draw to this point
CoreGraphics.CGContextStrokePath(context); // and now draw the Path!
@@ -502,19 +532,7 @@
canvas.restore();
}
*/
- public void setColorMatrix(ColorMatrix cm) {
- throw new UnsupportedOperationException();
- //paint.setColorFilter( cm==null?null:new ColorMatrixColorFilter(cm) );
- }
- public void setStrokeStyle(int stroke) {
- this.stroke = stroke;
- }
-
- public int getStrokeStyle() {
- return stroke;
- }
-
public void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3) {
CoreGraphics.CGContextSetLineWidth(context, 1.0);
CoreGraphics.CGContextMoveToPoint(context, tx+x1, ty+y1);
@@ -556,32 +574,4 @@
//paint.setAlpha(a);
throw new UnsupportedOperationException();
}
-
- public void scale(double sx, double sy) {
- CoreGraphics.CGContextTranslateCTM(context, tx, ty);
- CoreGraphics.CGContextScaleCTM(context, sx, sy);
- CoreGraphics.CGContextTranslateCTM(context, - tx * sx, - ty * sy);
-
- dirtyClip = true;
- }
-
- private CGRect getClipBounds() {
- if (dirtyClip) {
- clipBounds = CoreGraphics.CGContextGetClipBoundingBox(context);
- clipBounds.origin().setX(clipBounds.origin().x() - tx);
- clipBounds.origin().setY(clipBounds.origin().y() - ty);
- dirtyClip = false;
- }
- return clipBounds;
- }
-
- public int getStrokeWidth() {
- // TODO keep local var for this
- throw new UnsupportedOperationException();
- //return (int) paint.getStrokeWidth();
- }
-
- public void setStrokeWidth(int i) {
- CoreGraphics.CGContextSetLineWidth(context, i);
- }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|