1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Refactor: Clean up Int_ classes

This commit is contained in:
gnosygnu
2017-10-22 08:07:00 -04:00
parent d270cce881
commit 3157551d1d
154 changed files with 609 additions and 577 deletions

View File

@@ -24,7 +24,7 @@ public class PointAdp_ {
public static PointAdp parse(String raw) {
try {
String[] ary = String_.Split(raw, ",");
return new PointAdp(Int_.parse(ary[0]), Int_.parse(ary[1]));
return new PointAdp(Int_.Parse(ary[0]), Int_.Parse(ary[1]));
} catch (Exception exc) {throw Err_.new_parse_exc(exc, PointAdp.class, raw);}
}
}

View File

@@ -25,7 +25,7 @@ public class RectAdp_ {
public static RectAdp parse(String raw) {
try {
String[] ary = String_.Split(raw, ",");
return RectAdp_.new_(Int_.parse(ary[0]), Int_.parse(ary[1]), Int_.parse(ary[2]), Int_.parse(ary[3]));
return RectAdp_.new_(Int_.Parse(ary[0]), Int_.Parse(ary[1]), Int_.Parse(ary[2]), Int_.Parse(ary[3]));
} catch(Exception exc) {throw Err_.new_parse_exc(exc, RectAdp.class, raw);}
}
public static String Xto_str(RectAdp rect) {return String_.Format("{0},{1},{2},{3}", rect.X(), rect.Y(), rect.Width(), rect.Height());}

View File

@@ -23,8 +23,8 @@ public class SizeAdp_ {
public static SizeAdp parse(String raw) {return parse_or(raw, SizeAdp_.Null);}
public static SizeAdp parse_or(String raw, SizeAdp or) {
String[] ary = String_.Split(raw, ","); if (ary.length != 2) return or;
int w = Int_.parse_or(ary[0], Int_.Min_value); if (w == Int_.Min_value) return or;
int h = Int_.parse_or(ary[1], Int_.Min_value); if (h == Int_.Min_value) return or;
int w = Int_.Parse_or(ary[0], Int_.Min_value); if (w == Int_.Min_value) return or;
int h = Int_.Parse_or(ary[1], Int_.Min_value); if (h == Int_.Min_value) return or;
return new SizeAdp(w, h);
}
public static SizeAdp corners_(PointAdp topLeft, PointAdp bottomRight) {

View File

@@ -69,7 +69,7 @@ public class ColorAdp_ implements ParseAble {
@gplx.Internal protected static ColorAdp parse_int_(String v) {
String[] ary = String_.Split(v, ",");
switch (ary.length) {
case 1: return new_int_(Int_.parse(ary[0]));
case 1: return new_int_(Int_.Parse(ary[0]));
case 3:
case 4: return parse_int_ary_(ary);
default: throw Err_.new_wo_type("invalid array", "len", ary.length);
@@ -79,10 +79,10 @@ public class ColorAdp_ implements ParseAble {
int a;
int idx = 0;
if (ary.length == 3) {idx = 0; a = 255;}
else {idx = 1; a = Int_.parse(ary[0]);}
int r = Int_.parse(ary[idx++]);
int g = Int_.parse(ary[idx++]);
int b = Int_.parse(ary[idx++]);
else {idx = 1; a = Int_.Parse(ary[0]);}
int r = Int_.Parse(ary[idx++]);
int g = Int_.Parse(ary[idx++]);
int b = Int_.Parse(ary[idx++]);
return ColorAdp_.new_(a, r, g, b);
}
public static ColorAdp new_int_(int val) {

View File

@@ -27,7 +27,7 @@ public class ScreenAdp_ {
try {
raw = String_.Replace(raw, "{screen{", "");
raw = String_.Replace(raw, "}", "");
return ScreenAdp_.screen_(Int_.parse(raw));
return ScreenAdp_.screen_(Int_.Parse(raw));
} catch(Exception exc) {throw Err_.new_parse_exc(exc, ScreenAdp.class, raw);}
}
public static ScreenAdp from_point_(PointAdp pos) {// NOTE: not using FromPoint b/c of plat_wce

View File

@@ -58,7 +58,7 @@ public class IptBnd_txt_range implements InjectAble, Gfo_invk, Gfo_evt_itm {
if (String_.Eq(find, (String)list[i].Val())) idx = i;
}
if (idx == Int_.Min_value) { // try to find .Text in list.Keys
int key = Int_.parse_or(txtBox.Text(), Int_.Min_value); if (key == Int_.Min_value) return Gfo_invk_.Rv_unhandled;
int key = Int_.Parse_or(txtBox.Text(), Int_.Min_value); if (key == Int_.Min_value) return Gfo_invk_.Rv_unhandled;
idx = GetByKey(key); if (idx == Int_.Min_value) return Gfo_invk_.Rv_unhandled;
}
ExecCmd(setCmd, idx);

View File

@@ -32,7 +32,7 @@ public class IptBnd_upDownRange implements InjectAble, Gfo_invk, Gfo_evt_itm {
else if (ctx.Match(k, Invk_TxtBox_inc)) ExecCmd(cmd, curVal + 1);
else if (ctx.Match(k, Invk_TxtBox_exec)) {
Object valObj = IntClassXtn.Instance.ParseOrNull(txtBox.Text()); if (valObj == null) throw Err_.new_wo_type("invalid int", "text", txtBox.Text());
ExecCmd(doIt, Int_.cast(valObj));
ExecCmd(doIt, Int_.Cast(valObj));
}
else if (ctx.Match(k, evt)) WhenEvt(ctx, m);
else return Gfo_invk_.Rv_unhandled;

View File

@@ -26,7 +26,7 @@ public class IptMouseWheel_ {
else throw Err_.new_parse_type(IptMouseWheel.class, raw);
}
public static IptMouseWheel api_(Object obj) {
int delta = Int_.cast(obj);
int delta = Int_.Cast(obj);
if (delta > 0) return Up;
else if (delta < 0) return Down;
else return None;

View File

@@ -53,7 +53,7 @@ public class Swt_html implements Gxw_html, Swt_control, FocusListener, Gfo_evt_m
lnr_location = new Swt_html_lnr_location(this);
lnr_status = new Swt_html_lnr_status(this);
Object browser_tid_obj = ctorArgs.Get_val_or(Swt_kit.Cfg_Html_BrowserType, null);
this.browser_tid = browser_tid_obj == null ? Browser_tid_none : Int_.cast(browser_tid_obj);
this.browser_tid = browser_tid_obj == null ? Browser_tid_none : Int_.Cast(browser_tid_obj);
browser = new Browser(owner_control.Under_composite(), browser_tid);
core = new Swt_core_cmds_html(this, browser);
browser.addKeyListener(new Swt_lnr_key(this));