Tom Yeh avatar Tom Yeh committed 74b386d

ScreenPainter -> Canvas

Comments (0)

Files changed (1)

examples/src/main/java/org/sikuli/api/examples/OrderingExample.java

 import java.awt.Rectangle;
 import java.util.List;
 
-import org.sikuli.api.ImageTarget;
 import org.sikuli.api.DesktopScreenRegion;
+import org.sikuli.api.ImageTarget;
 import org.sikuli.api.Relative;
 import org.sikuli.api.ScreenRegion;
 import org.sikuli.api.StyledRectangleTarget;
 import org.sikuli.api.robot.Mouse;
 import org.sikuli.api.robot.desktop.DesktopKeyboard;
 import org.sikuli.api.robot.desktop.DesktopMouse;
-import org.sikuli.api.visual.ScreenPainter;
-
-import static org.sikuli.api.API.*;
+import org.sikuli.api.visual.Canvas;
+import org.sikuli.api.visual.DesktopCanvas;
 
 public class OrderingExample {
 
 	static Mouse mouse = new DesktopMouse();
 	static Keyboard keyboard = new DesktopKeyboard();
-	static ScreenPainter painter = new ScreenPainter();
+	static Canvas canvas = new DesktopCanvas();
 
 	static ScreenSimulator simulator = new ScreenSimulator(){
 		public void run(){
 			showImage(Images.OSXSharingPreferences);
-			wait(20000);
+			wait(12000);
 			close();
 		}
 	};
 		
 		rs = s.findAll(target);
 		
-		painter.label(s, "Unchecked checkboxes found in bottom-up ordering", 3000);
+		canvas.addLabel(Relative.to(s).topLeft().getScreenLocation(), "Unchecked checkboxes found in bottom-up ordering");
 		for (int i=0; i < rs.size(); ++i){
 			ScreenRegion r = rs.get(i);
-			painter.box(r, 3000);			
-			painter.label(Relative.to(r).topLeft().left(20).getScreenLocation(), ""+(i+1), 3000);
+			canvas.addBox(r);
+			canvas.addLabel(Relative.to(r).topLeft().left(20).getScreenLocation(), ""+(i+1));
 		}
-		
-		pause(5000);
-		
+		canvas.display(5);
+				
 		// find all styled rectangles (e.g., buttons) ordered from left to right
 	
 		target = new StyledRectangleTarget(Images.ButtonOptions);
 		
 		rs = s.findAll(target);
 		
-		painter.label(s, "Rectangles found in left-right ordering", 3000);
+		canvas.clear().addLabel(Relative.to(s).topLeft().getScreenLocation(), "Rectangles found in left-right ordering");
 		for (int i=0; i < rs.size(); ++i){
 			ScreenRegion r = rs.get(i);
-			painter.box(r,3000);
-			painter.label(Relative.to(r).topLeft().left(20).getScreenLocation(), ""+(i+1), 3000);
+			canvas.addBox(r);
+			canvas.addLabel(Relative.to(r).topLeft().left(20).getScreenLocation(), ""+(i+1));
 		}
+		canvas.display(5);
 
 	}
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.