From 494c7465654f37ff1c00cf51a7f6cf0826d58423 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Manuel=20Carrasco=20Mo=C3=B1ino?= Date: Mon, 4 Nov 2013 13:11:28 +0100 Subject: [PATCH] Remove usage of deprecated class --- .../gwt/query/client/plugins/effects/Fx.java | 25 ++++++------ .../plugins/effects/PropertiesAnimation.java | 40 +++++++++---------- 2 files changed, 30 insertions(+), 35 deletions(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Fx.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Fx.java index 408a993b..03ed86b0 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Fx.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Fx.java @@ -5,8 +5,8 @@ import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.css.BorderColorProperty; import com.google.gwt.query.client.css.RGBColor; import com.google.gwt.query.client.js.JsNamedArray; -import com.google.gwt.query.client.js.JsObjectArray; -import com.google.gwt.query.client.js.JsRegexp; +import com.google.gwt.regexp.shared.MatchResult; +import com.google.gwt.regexp.shared.RegExp; /** * A pojo to store effect values. @@ -60,14 +60,13 @@ public class Fx { } // hexadecimal regex - public static JsRegexp REGEX_HEX_COLOR_PATTERN = new JsRegexp( - "#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})"); + public static RegExp REGEX_HEX_COLOR_PATTERN = RegExp.compile("#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})"); private static JsNamedArray htmlColorToRgb; // rgb and rgba regex - public static JsRegexp REGEX_RGB_COLOR_PATTERN = new JsRegexp( - "rgba?\\(\\s*([0-9]{1,3}%?)\\s*,\\s*([0-9]{1,3}%?)\\s*,\\s*([0-9]{1,3}%?).*\\)$"); + public static RegExp REGEX_RGB_COLOR_PATTERN = + RegExp.compile("rgba?\\(\\s*([0-9]{1,3}%?)\\s*,\\s*([0-9]{1,3}%?)\\s*,\\s*([0-9]{1,3}%?).*\\)$"); static { htmlColorToRgb = JsNamedArray.create(); @@ -152,7 +151,7 @@ public class Fx { } protected int[] parseColor(String color) { - JsObjectArray matches = REGEX_RGB_COLOR_PATTERN.exec(color); + MatchResult matches = REGEX_RGB_COLOR_PATTERN.exec(color); if (matches != null) { return parseRGBColor(matches); } @@ -165,11 +164,11 @@ public class Fx { return parseLiteralColor(color); } - private int[] parseHexColor(JsObjectArray matches) { - assert matches.length() == 2; + private int[] parseHexColor(MatchResult matches) { + assert matches.getGroupCount() == 2; int[] result = new int[3]; - String hexCode = matches.get(1); + String hexCode = matches.getGroup(1); int step = (hexCode.length() == 3) ? 1 : 2; @@ -189,12 +188,12 @@ public class Fx { return htmlColorToRgb.get(color); } - private int[] parseRGBColor(JsObjectArray matches) { - assert matches.length() == 4; + private int[] parseRGBColor(MatchResult matches) { + assert matches.getGroupCount() == 4; int[] result = new int[3]; for (int i = 1; i < 4; i++) { - String valueString = matches.get(i); + String valueString = matches.getGroup(i); int value = -1; if (valueString.endsWith("%")) { int percentage = Integer.parseInt(valueString.substring(0, diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java index ba60a142..f91f0557 100755 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java @@ -20,11 +20,12 @@ import com.google.gwt.query.client.Function; import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.Properties; import com.google.gwt.query.client.js.JsObjectArray; -import com.google.gwt.query.client.js.JsRegexp; import com.google.gwt.query.client.plugins.Effects; import com.google.gwt.query.client.plugins.Effects.GQAnimation; import com.google.gwt.query.client.plugins.effects.Fx.ColorFx; import com.google.gwt.query.client.plugins.effects.Fx.ColorFx.BorderColorFx; +import com.google.gwt.regexp.shared.MatchResult; +import com.google.gwt.regexp.shared.RegExp; /** * Animation effects on any numeric CSS property. @@ -130,25 +131,20 @@ public class PropertiesAnimation extends GQAnimation { } } - private static final String[] ATTRS_TO_SAVE = new String[]{ - "overflow"}; - - private static final JsRegexp REGEX_NUMBER_UNIT = new JsRegexp( - "^([0-9+-.]+)(.*)?$"); - - private static final JsRegexp REGEX_SYMBOL_NUMBER_UNIT = new JsRegexp( - "^([+-]=)?([0-9+-.]+)(.*)?$"); - - private static final JsRegexp REGEX_NON_PIXEL_ATTRS = new JsRegexp( - "z-?index|font-?weight|opacity|zoom|line-?height|^\\$", "i"); + private static final String[] ATTRS_TO_SAVE = new String[]{"overflow"}; + + private static final RegExp REGEX_NUMBER_UNIT = RegExp.compile("^([0-9+-.]+)(.*)?$"); - private static final JsRegexp REGEX_COLOR_ATTR = new JsRegexp(".*color$", "i"); + private static final RegExp REGEX_SYMBOL_NUMBER_UNIT = RegExp.compile("^([+-]=)?([0-9+-.]+)(.*)?$"); - private static final JsRegexp REGEX_BORDERCOLOR = new JsRegexp("^bordercolor$", "i"); + private static final RegExp REGEX_NON_PIXEL_ATTRS = + RegExp.compile("z-?index|font-?weight|opacity|zoom|line-?height|^\\$", "i"); - private static final JsRegexp REGEX_BACKGROUNDCOLOR = new JsRegexp("^backgroundcolor$", "i"); + private static final RegExp REGEX_COLOR_ATTR = RegExp.compile(".*color$", "i"); + private static final RegExp REGEX_BORDERCOLOR = RegExp.compile("^bordercolor$", "i"); + private static final RegExp REGEX_BACKGROUNDCOLOR =RegExp.compile("^backgroundcolor$", "i"); public static Fx computeFxProp(Element e, String key, String val, boolean hidden) { @@ -212,10 +208,10 @@ public class PropertiesAnimation extends GQAnimation { if (key.startsWith("$")) { rkey = key.substring(1).toLowerCase(); String attr = g.attr(rkey); - JsObjectArray parts = REGEX_NUMBER_UNIT.match(attr); + MatchResult parts = REGEX_NUMBER_UNIT.exec(attr); if (parts != null) { - String $1 = parts.get(1); - String $2 = parts.get(2); + String $1 = parts.getGroup(1); + String $2 = parts.getGroup(2); cur = Double.parseDouble($1); unit = $2 == null ? "" : $2; } else { @@ -240,12 +236,12 @@ public class PropertiesAnimation extends GQAnimation { end = 0; unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : "px"; } else { - JsObjectArray parts = REGEX_SYMBOL_NUMBER_UNIT.match(val); + MatchResult parts = REGEX_SYMBOL_NUMBER_UNIT.exec(val); if (parts != null) { - String $1 = parts.get(1); - String $2 = parts.get(2); - String $3 = parts.get(3); + String $1 = parts.getGroup(1); + String $2 = parts.getGroup(2); + String $3 = parts.getGroup(3); end = Double.parseDouble($2); if (rkey == null) { -- 2.39.5