This is an automated email from the git hooks/post-receive script. pini pushed a commit to tag upstream/1.1.0_beta1 in repository sikuli.
commit c73ad8886a7f20c7a4e5ca226ff41d5ab9cae0dc Author: Johan Sjöblom <[email protected]> Date: Sat Apr 5 13:44:50 2014 +0200 Added option to change highlight colour --- .../org/sikuli/script/OverlayCapturePrompt.java | 1 - API/src/main/java/org/sikuli/script/Region.java | 75 ++++++++++++++++------ API/src/main/java/org/sikuli/script/Screen.java | 2 +- .../java/org/sikuli/script/ScreenHighlighter.java | 17 ++++- 4 files changed, 71 insertions(+), 24 deletions(-) diff --git a/API/src/main/java/org/sikuli/script/OverlayCapturePrompt.java b/API/src/main/java/org/sikuli/script/OverlayCapturePrompt.java old mode 100755 new mode 100644 index 86c97e7..1de858d --- a/API/src/main/java/org/sikuli/script/OverlayCapturePrompt.java +++ b/API/src/main/java/org/sikuli/script/OverlayCapturePrompt.java @@ -19,7 +19,6 @@ import org.sikuli.natives.SysUtil; */ public class OverlayCapturePrompt extends OverlayTransparentWindow implements EventSubject { - static Color _overlayColor = new Color(0F, 0F, 0F, 0.6F); final static float MIN_DARKER_FACTOR = 0.6f; final static long MSG_DISPLAY_TIME = 2000; final static long WIN_FADE_IN_TIME = 200; diff --git a/API/src/main/java/org/sikuli/script/Region.java b/API/src/main/java/org/sikuli/script/Region.java old mode 100755 new mode 100644 index 3c64c4e..c236cc4 --- a/API/src/main/java/org/sikuli/script/Region.java +++ b/API/src/main/java/org/sikuli/script/Region.java @@ -1714,22 +1714,31 @@ public class Region { //<editor-fold defaultstate="collapsed" desc="highlight"> protected void updateSelf() { if (overlay != null) { - highlight(false); - highlight(true); + highlight(false, null); + highlight(true, null); } } /** - * Toggle the regions Highlight visibility (currently red frame) + * Toggle the regions Highlight visibility (red frame) * * @return the region itself */ public Region highlight() { - if (overlay == null) { - highlight(true); - } else { - highlight(false); - } + // Pass true if overlay is null, false otherwise + highlight(overlay == null, null); + return this; + } + + /** + * Toggle the regions Highlight visibility (frame of specified color) + * + * @param color Color of frame + * @return the region itself + */ + public Region highlight(String color) { + // Pass true if overlay is null, false otherwise + highlight(overlay == null, color); return this; } @@ -1737,14 +1746,16 @@ public class Region { * Sets the regions Highlighting border * * @param toEnable set overlay enabled or disabled + * @param color Color of frame */ - private Region highlight(boolean toEnable) { + private Region highlight(boolean toEnable, String color) { if (isOtherScreen()) { return this; } - Debug.action("toggle highlight " + toString() + ": " + toEnable); + Debug.action("toggle highlight " + toString() + ": " + toEnable + + (color != null ? " color: " + color : "")); if (toEnable) { - overlay = new ScreenHighlighter(getScreen()); + overlay = new ScreenHighlighter(getScreen(), color); overlay.highlight(this); } else { if (overlay != null) { @@ -1755,22 +1766,36 @@ public class Region { return this; } + /** - * show the regions Highlight for the given time in seconds (currently red frame) if 0 - use the global - * Settings.SlowMotionDelay + * show the regions Highlight for the given time in seconds (red frame) + * if 0 - use the global Settings.SlowMotionDelay * * @param secs time in seconds * @return the region itself */ public Region highlight(float secs) { + return highlight(secs, null); + } + + /** + * show the regions Highlight for the given time in seconds (frame of specified color) + * if 0 - use the global Settings.SlowMotionDelay + * + * @param secs time in seconds + * @param color Color of frame + * @return the region itself + */ + public Region highlight(float secs, String color) { if (isOtherScreen()) { return this; } if (secs < 0.1) { - return highlight((int) secs); + return highlight((int) secs, color); } - Debug.action("highlight " + toString() + " for " + secs + " secs"); - ScreenHighlighter _overlay = new ScreenHighlighter(getScreen()); + Debug.action("highlight " + toString() + " for " + secs + " secs" + + (color != null ? " color: " + color : "")); + ScreenHighlighter _overlay = new ScreenHighlighter(getScreen(), color); _overlay.highlight(this, secs); return this; } @@ -1783,17 +1808,29 @@ public class Region { * @return this region */ public Region highlight(int secs) { + return highlight(secs, null); + } + + + /** + * Show highlight in selected color + * + * @param secs time in seconds + * @param color Color of frame + * @return this region + */ + public Region highlight(int secs, String color) { if (isOtherScreen()) { return this; } if (secs > 0) { - return highlight((float) secs); + return highlight((float) secs, color); } if (lastMatch != null) { if (secs < 0) { - return lastMatch.highlight((float) -secs); + return lastMatch.highlight((float) -secs, color); } - return lastMatch.highlight(Settings.DefaultHighlightTime); + return lastMatch.highlight(Settings.DefaultHighlightTime, color); } return this; } diff --git a/API/src/main/java/org/sikuli/script/Screen.java b/API/src/main/java/org/sikuli/script/Screen.java old mode 100755 new mode 100644 index c65282b..54a26c3 --- a/API/src/main/java/org/sikuli/script/Screen.java +++ b/API/src/main/java/org/sikuli/script/Screen.java @@ -508,7 +508,7 @@ public class Screen extends Region implements EventObserver, IScreen { protected void showTarget(Location loc, double secs) { if (Settings.isShowActions()) { - ScreenHighlighter overlay = new ScreenHighlighter(this); + ScreenHighlighter overlay = new ScreenHighlighter(this, null); overlay.showTarget(loc, (float) secs); } } diff --git a/API/src/main/java/org/sikuli/script/ScreenHighlighter.java b/API/src/main/java/org/sikuli/script/ScreenHighlighter.java old mode 100755 new mode 100644 index 1faa7ca..5691e34 --- a/API/src/main/java/org/sikuli/script/ScreenHighlighter.java +++ b/API/src/main/java/org/sikuli/script/ScreenHighlighter.java @@ -13,6 +13,7 @@ import java.awt.event.*; import java.awt.image.*; import java.util.HashSet; import java.util.Set; +import java.lang.reflect.Field; /** * INTERNAL USE @@ -20,9 +21,8 @@ import java.util.Set; */ public class ScreenHighlighter extends OverlayTransparentWindow implements MouseListener { - static Color _overlayColor = new Color(0F, 0F, 0F, 0.6F); static Color _transparentColor = new Color(0F, 0F, 0F, 0.5F); - static Color _targetColor = new Color(1F, 0F, 0F, 0.7F); + Color _targetColor; final static int TARGET_SIZE = 50; final static int DRAGGING_TIME = 200; static int MARGIN = 20; @@ -42,11 +42,22 @@ public class ScreenHighlighter extends OverlayTransparentWindow implements Mouse BasicStroke _StrokeBorder = new BasicStroke(3); OverlayAnimator _aniX, _aniY; - public ScreenHighlighter(Screen scr) { + public ScreenHighlighter(Screen scr, String color) { _scr = scr; init(); setVisible(false); setAlwaysOnTop(true); + + // Attempt to set the color of the frame to what the user provided. + // If it fails, set to red. Valid colors are the ones defined in the Color class: + // http://docs.oracle.com/javase/7/docs/api/java/awt/Color.html#field_summary + try { + Field field = Class.forName("java.awt.Color").getField(color); + _targetColor = (Color)field.get(null); + } catch (Exception e) { + // Set to standard red color + _targetColor = new Color(1F, 0F, 0F, 0.7F); + } } private void init() { -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/sikuli.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

