/hg/icedtea-web: refactoring AWTFramework - iconPosition is of t...

jfabriko at icedtea.classpath.org jfabriko at icedtea.classpath.org
Mon Apr 29 06:26:39 PDT 2013


changeset 105f8cb6d988 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=105f8cb6d988
author: Jana Fabrikova <jfabriko at redhat.com>
date: Mon Apr 29 15:29:46 2013 +0200

	refactoring AWTFramework - iconPosition is of type Point


diffstat:

 ChangeLog                                                                       |   9 +++++
 tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java                   |  18 +++++----
 tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java |  16 ++++----
 3 files changed, 27 insertions(+), 16 deletions(-)

diffs (153 lines):

diff -r fc98e8df7cee -r 105f8cb6d988 ChangeLog
--- a/ChangeLog	Mon Apr 29 15:05:14 2013 +0200
+++ b/ChangeLog	Mon Apr 29 15:29:46 2013 +0200
@@ -1,3 +1,12 @@
+2013-04-29  Jana Fabrikova  <jfabriko at redhat.com>
+
+	* tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java:
+	refactoring Point instead of Rectangle as icon position as
+	markerPosition
+	* tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java:
+	refactoring Point instead of Rectangle as icon position in several
+	search methods
+
 2013-04-29  Jana Fabrikova  <jfabriko at redhat.com>
 
 	* tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java:
diff -r fc98e8df7cee -r 105f8cb6d988 tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java
--- a/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java	Mon Apr 29 15:05:14 2013 +0200
+++ b/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java	Mon Apr 29 15:29:46 2013 +0200
@@ -38,6 +38,7 @@
 
 import java.awt.AWTException;
 import java.awt.Color;
+import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.Robot;
 import java.awt.Toolkit;
@@ -62,7 +63,7 @@
     private String initStr = "";        
     private Color appletColor;
     private BufferedImage marker;
-    private Rectangle markerPosition;
+    private Point markerPosition;
     private int appletHeight;
     private int appletWidth;
     private int tryKTimes = DEFAULT_K;
@@ -132,7 +133,7 @@
      * @param appletHeight
      */
    
-    public AWTHelper(BufferedImage icon, Rectangle iconPosition, int appletWidth, int appletHeight){
+    public AWTHelper(BufferedImage icon, Point iconPosition, int appletWidth, int appletHeight){
         this();
         this.marker = icon;
         this.markerPosition = iconPosition;
@@ -143,7 +144,7 @@
         this.appletDimensionGiven = true;
     }
     
-    public AWTHelper(String initString, BufferedImage icon, Rectangle iconPosition, int appletWidth, int appletHeight) throws AWTException{
+    public AWTHelper(String initString, BufferedImage icon, Point iconPosition, int appletWidth, int appletHeight) throws AWTException{
         this(icon, iconPosition, appletWidth, appletHeight);
         
         this.initStr = initString;
@@ -160,16 +161,17 @@
      */
     public AWTHelper(int appletWidth, int appletHeight){
         this();
+        
         String test_server_dir_path = System.getProperty("test.server.dir");
 
         try {
             this.marker = ImageIO.read(new File(test_server_dir_path + "/marker.png"));
-            this.markerPosition = new Rectangle(0,0,marker.getWidth(),marker.getHeight());
+            this.markerPosition = new Point(0,0);
             this.markerGiven = true;
         } catch (IOException e) {
             throw new RuntimeException("AWTHelper could not read marker.png.",e);
         }
-        
+                
         this.appletWidth = appletWidth;
         this.appletHeight = appletHeight;
         this.appletDimensionGiven = true;
@@ -297,7 +299,7 @@
         this.initStrGiven = true;
     }
        
-    public void setMarker(BufferedImage marker, Rectangle markerPosition) {
+    public void setMarker(BufferedImage marker, Point markerPosition) {
         this.marker = marker;
         this.markerPosition = markerPosition;
         this.markerGiven = true;
@@ -347,7 +349,7 @@
      * @param K
      * @throws ComponentNotFoundException
      */
-    public void captureScreenAndFindAppletByIconTryKTimes(BufferedImage icon, Rectangle iconPosition, int width, int height, int K) throws ComponentNotFoundException {
+    public void captureScreenAndFindAppletByIconTryKTimes(BufferedImage icon, Point iconPosition, int width, int height, int K) throws ComponentNotFoundException {
   
         int count = 0;
         appletFound = false;
@@ -551,4 +553,4 @@
     public void typeKey(int key) {
         KeyboardActions.typeKey(this.robot, key);
     }
-}
+ }
diff -r fc98e8df7cee -r 105f8cb6d988 tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java
--- a/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java	Mon Apr 29 15:05:14 2013 +0200
+++ b/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java	Mon Apr 29 15:29:46 2013 +0200
@@ -39,6 +39,7 @@
 package net.sourceforge.jnlp.awt.imagesearch;
 
 import java.awt.Color;
+import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.image.BufferedImage;
 
@@ -86,10 +87,9 @@
 
     
     /**
-     * method findWindowByIcon finds the application area assuming there is a
+     * Method findWindowByIcon finds the application area assuming there is a
      * given icon in given position on the application window 
-     * (the left upper corner by default) the dimension of the window has to 
-     * be given
+     * the dimension of the window has to be given.
      * 
      * @param icon
      * @param iconPosition
@@ -98,25 +98,25 @@
      * @param screenshot
      * @return Rectangle rectangle where the applet resides
      */
-    public static Rectangle findWindowByIcon(BufferedImage icon, Rectangle iconPosition, int windowWidth, int windowHeight, BufferedImage screenshot) {
+    public static Rectangle findWindowByIcon(BufferedImage icon, Point iconPosition, int windowWidth, int windowHeight, BufferedImage screenshot) {
         Rectangle r = ImageSeeker.findExactImage(icon, screenshot);
         if( ImageSeeker.isRectangleValid(r)){
-            return windowPositionFromIconPosition(r, iconPosition, windowWidth, windowHeight);
+            return windowPositionFromIconPosition(r.getLocation(), iconPosition, windowWidth, windowHeight);
         }else{
             return null;
         }
     }
 
-    public static Rectangle findWindowByIconBlurred(BufferedImage icon, Rectangle iconPosition, int windowWidth, int windowHeight, BufferedImage screenshot, double minCorrelation) {
+    public static Rectangle findWindowByIconBlurred(BufferedImage icon, Point iconPosition, int windowWidth, int windowHeight, BufferedImage screenshot, double minCorrelation) {
         Rectangle r = ImageSeeker.findBlurredImage(icon, screenshot, minCorrelation);
         if( ImageSeeker.isRectangleValid(r)){
-            return windowPositionFromIconPosition(r, iconPosition, windowWidth, windowHeight);
+            return windowPositionFromIconPosition(r.getLocation(), iconPosition, windowWidth, windowHeight);
         }else{
             return null;
         }    
     }
     
-    public static Rectangle windowPositionFromIconPosition(Rectangle iconAbsolute, Rectangle iconRelative, int windowWidth, int windowHeight){
+    public static Rectangle windowPositionFromIconPosition(Point iconAbsolute, Point iconRelative, int windowWidth, int windowHeight){
         return new Rectangle( iconAbsolute.x - iconRelative.x, iconAbsolute.y - iconRelative.y,
                             windowWidth, windowHeight);
     }



More information about the distro-pkg-dev mailing list