[libbluray-devel] BDGraphics: fix coordinates

Ian Curtis git at videolan.org
Tue Mar 18 23:36:35 CET 2014


libbluray | branch: master | Ian Curtis <i.curtis at gmail.com> | Wed Mar 19 00:36:07 2014 +0200| [26735fb7d2cde1a04a21225ee260f3a407ee9a99] | committer: hpi1

BDGraphics: fix coordinates

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=26735fb7d2cde1a04a21225ee260f3a407ee9a99
---

 .../bdj/java-j2me/java/awt/BDGraphics.java         |   22 ++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java b/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
index 0d678da..7831fd6 100644
--- a/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
+++ b/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
@@ -353,13 +353,16 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
     }
 
     public void drawRect(int x, int y, int w, int h) {
+        x += originX;
+        y += originY;
+
         drawLineN(x, y, x + w, y);
         drawLineN(x, y + h, x + w, y + h);
         drawLineN(x, y, x, y + h);
         drawLineN(x + w, y, x + w, y + h);
     }
 
-    public void drawLineN(int x1, int y1, int x2, int y2) {
+    private void drawLineN(int x1, int y1, int x2, int y2) {
         int rgb = foreground.getRGB();
         int dy = y2 - y1;
         int dx = x2 - x1;
@@ -408,6 +411,13 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
     }
 
     public void drawLine(int x1, int y1, int x2, int y2) {
+
+        x1 += originX;
+        y1 += originY;
+
+        x2 += originX;
+        y2 += originY;
+
         drawLineN(x1, y1, x2, y2);
     }
 
@@ -429,22 +439,22 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
     /** Draws lines defined by an array of x points and y points */
     public void drawPolyline(int xPoints[], int yPoints[], int nPoints) {
         if (nPoints == 1) {
-            drawPointN(xPoints[0], yPoints[0], foreground.getRGB());
+            drawPoint(xPoints[0], yPoints[0], foreground.getRGB());
         } else {
             for (int i = 0; i < (nPoints - 1); i++)
-                drawLineN(xPoints[i], xPoints[i], xPoints[i + 1], xPoints[i + 1]);
+                drawLine(xPoints[i], xPoints[i], xPoints[i + 1], xPoints[i + 1]);
         }
     }
 
     /** Draws a polygon defined by an array of x points and y points */
     public void drawPolygon(int xPoints[], int yPoints[], int nPoints) {
         if (nPoints == 1) {
-            drawPointN(xPoints[0], yPoints[0], foreground.getRGB());
+            drawPoint(xPoints[0], yPoints[0], foreground.getRGB());
         } else {
             for (int i = 0; i < (nPoints - 1); i++)
-                drawLineN(xPoints[i], xPoints[i], xPoints[i + 1], xPoints[i + 1]);
+                drawLine(xPoints[i], xPoints[i], xPoints[i + 1], xPoints[i + 1]);
             if (nPoints > 2)
-                drawLineN(xPoints[0], xPoints[0], xPoints[nPoints - 1], xPoints[nPoints - 1]);
+                drawLine(xPoints[0], xPoints[0], xPoints[nPoints - 1], xPoints[nPoints - 1]);
         }
     }
 



More information about the libbluray-devel mailing list