[libbluray-devel] BDGraphics: fix coordinates

Ian Curtis git at videolan.org
Tue Mar 18 23:32:52 CET 2014


libbluray | branch: master | Ian Curtis <i.curtis at gmail.com> | Tue Mar 18 23:53:13 2014 +0200| [fc910936fc943aeeb65b21fa0f051f03578a0a3b] | committer: hpi1

BDGraphics: fix coordinates

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

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

diff --git a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
index 6399da6..a7203aa 100644
--- a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
+++ b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
@@ -435,13 +435,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;
@@ -490,6 +493,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);
     }
 
@@ -511,22 +521,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