1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-07-12 21:10:02 -04:00
commit 794b5a232f
3099 changed files with 238212 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class DirInt {
public int Val() {return val;} int val;
public DirInt Rev() {return this == Fwd ? Bwd : Fwd;}
public int CompareToRng(int v, int lo, int hi) {
if (v < lo) return -1 * val;
else if (v > hi) return 1 * val;
else return 0;
}
public int GetValByDir(int ifBwd, int ifFwd) {
return this == Bwd ? ifBwd : ifFwd;
}
public boolean BoundFail(int i, int bound) {return this == Bwd ? i < bound : i > bound;}
DirInt(int v) {this.val = v;}
public static final DirInt
Fwd = new DirInt(1)
, Bwd = new DirInt(-1);
}

View File

@@ -0,0 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiAlign {
public int Val() {return val;} int val;
public String Name() {return name;} private String name;
public GfuiAlign(int val, String name) {this.val = val; this.name = name;}
}

View File

@@ -0,0 +1,62 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiAlign_ implements ParseAble {
public static GfuiAlign as_(Object obj) {return obj instanceof GfuiAlign ? (GfuiAlign)obj : null;}
public static GfuiAlign cast_(Object obj) {try {return (GfuiAlign)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, GfuiAlign.class, obj);}}
public static final GfuiAlign
Null = new_(0, "nil")
, Lo = new_(1, "lo")
, Mid = new_(2, "mid")
, Hi = new_(3, "hi");
public static final GfuiAlign
Top = Lo
, Bot = Hi
, Left = Lo
, Right = Hi;
static GfuiAlign new_(int v, String s) {return new GfuiAlign(v, s);}
public static final GfuiAlign_ Parser = new GfuiAlign_();
public Object ParseAsObj(String raw) {return parse_(raw);}
public static GfuiAlign val_(int v) {
if (v == Lo.Val()) return Lo;
else if (v == Mid.Val()) return Mid;
else if (v == Hi.Val()) return Hi;
else return Null;
}
public static GfuiAlign parse_(String raw) {
if (String_.Eq(raw, "bot")) return Bot;
else if (String_.Eq(raw, "mid")) return Mid;
else if (String_.Eq(raw, "top")) return Top;
return Null;
}
public static PointAdp CalcInsideOf(GfuiAlign h, GfuiAlign v, SizeAdp inner, SizeAdp outer, PointAdp adjust) {
int x = CalcInsideOfAxis(h.Val(), inner.Width(), outer.Width());
int y = CalcInsideOfAxis(v.Val(), inner.Height(), outer.Height());
return PointAdp_.new_(x + adjust.X(), y + adjust.Y());
}
public static int CalcInsideOfAxis(int posEnm, int innerSize, int outerSize) {
int rv = 0;
if (posEnm == GfuiAlign_.Null.Val()) rv = Int_.MinValue;
else if (posEnm == GfuiAlign_.Lo.Val()) rv = 0;
else if (posEnm == GfuiAlign_.Mid.Val()) rv = (outerSize - innerSize) / 2;
else if (posEnm == GfuiAlign_.Hi.Val()) rv = outerSize - innerSize;
else throw Exc_.new_unhandled(posEnm);
if (rv < 0) rv = 0;
return rv;
}
}

View File

@@ -0,0 +1,25 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiAxisType {
public int Val() {return val;} int val;
public GfuiAxisType CrossAxis() {return val == GfuiAxisType.X.val ? GfuiAxisType.Y : GfuiAxisType.X;}
GfuiAxisType(int v) {this.val = v;}
public static final GfuiAxisType X = new GfuiAxisType(1);
public static final GfuiAxisType Y = new GfuiAxisType(2);
}

View File

@@ -0,0 +1,57 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiBorderEdge {
public int Val() {return val;} int val;
public boolean Has(GfuiBorderEdge comp) {return Enm_.HasInt(val, comp.val);}
public GfuiBorderEdge Add(GfuiBorderEdge comp) {
return new GfuiBorderEdge(comp.val + val);
}
@gplx.Internal protected GfuiBorderEdge(int v) {this.val = v;}
public static final GfuiBorderEdge Left = new GfuiBorderEdge(1);
public static final GfuiBorderEdge Right = new GfuiBorderEdge(2);
public static final GfuiBorderEdge Top = new GfuiBorderEdge(4);
public static final GfuiBorderEdge Bot = new GfuiBorderEdge(8);
public static final GfuiBorderEdge All = new GfuiBorderEdge(15);
}
class GfuiBorderEdge_ {
public static String XtoStr(GfuiBorderEdge edge) {
int val = edge.Val();
if (val == GfuiBorderEdge.Left.Val()) return Left_raw;
else if (val == GfuiBorderEdge.Right.Val()) return Right_raw;
else if (val == GfuiBorderEdge.Top.Val()) return Top_raw;
else if (val == GfuiBorderEdge.Bot.Val()) return Bot_raw;
else if (val == GfuiBorderEdge.All.Val()) return All_raw;
else throw Exc_.new_unhandled(edge);
}
public static GfuiBorderEdge parse_(String raw) {
if (String_.Eq(raw, Left_raw)) return GfuiBorderEdge.Left;
else if (String_.Eq(raw, Right_raw)) return GfuiBorderEdge.Right;
else if (String_.Eq(raw, Top_raw)) return GfuiBorderEdge.Top;
else if (String_.Eq(raw, Bot_raw)) return GfuiBorderEdge.Bot;
else if (String_.Eq(raw, All_raw)) return GfuiBorderEdge.All;
else throw Exc_.new_unhandled(raw);
}
public static final String
All_raw = "all"
, Top_raw = "top"
, Left_raw = "left"
, Right_raw = "right"
, Bot_raw = "bottom"
;
}

View File

@@ -0,0 +1,35 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class PointAdp implements XtoStrAble {
public int X() {return x;} final int x;
public int Y() {return y;} final int y;
public PointAdp Op_add(PointAdp val) {return new PointAdp(x + val.x, y + val.y);}
@gplx.Internal protected PointAdp Op_add(int xv, int yv) {return new PointAdp(x + xv, y + yv);}
@gplx.Internal protected PointAdp Op_add(int i) {return new PointAdp(x + i, y + i);}
public PointAdp Op_subtract(PointAdp val) {return new PointAdp(x - val.x, y - val.y);}
public boolean Eq(Object compObj) {
PointAdp comp = PointAdp_.as_(compObj); if (comp == null) return false;
return x == comp.x && y == comp.y;
}
public String XtoStr() {return String_.Concat_any(x, ",", y);}
@Override public String toString() {return XtoStr();}
@Override public boolean equals(Object obj) {return Eq(obj);}
@Override public int hashCode() {return super.hashCode();}
@gplx.Internal protected PointAdp(int x, int y) {this.x = x; this.y = y;}
}

View File

@@ -0,0 +1,32 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class PointAdp_ {
public static final PointAdp Null = new PointAdp(Int_.MinValue, Int_.MinValue);
public static final PointAdp Zero = new PointAdp(0, 0);
public static PointAdp as_(Object obj) {return obj instanceof PointAdp ? (PointAdp)obj : null;}
public static PointAdp cast_(Object obj) {try {return (PointAdp)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, PointAdp.class, obj);}}
public static PointAdp new_(int x, int y) {return new PointAdp(x, y);}
public static PointAdp coerce_(Object o) {PointAdp rv = PointAdp_.as_(o); return (rv == null) ? parse_((String)o) : rv;}
public static PointAdp parse_(String raw) {
try {
String[] ary = String_.Split(raw, ",");
return new PointAdp(Int_.parse_(ary[0]), Int_.parse_(ary[1]));
} catch (Exception exc) {throw Exc_.new_parse_exc(exc, PointAdp.class, raw);}
}
}

View File

@@ -0,0 +1,44 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class RectAdp {
public SizeAdp Size() {return size;} SizeAdp size = SizeAdp_.Zero;
public PointAdp Pos() {return pos;} PointAdp pos = PointAdp_.Zero;
public int Width() {return size.Width();} public int Height() {return size.Height();}
public int X() {return pos.X();} public int Y() {return pos.Y();}
public PointAdp CornerTL() {return pos;}
public PointAdp CornerTR() {return PointAdp_.new_(pos.X() + size.Width(), pos.Y());}
public PointAdp CornerBL() {return PointAdp_.new_(pos.X(), pos.Y() + size.Height());}
public PointAdp CornerBR() {return PointAdp_.new_(pos.X() + size.Width(), pos.Y() + size.Height());}
@gplx.Internal protected boolean ContainsPoint(PointAdp point) {
return point.X() >= pos.X() && point.X() <= pos.X() + size.Width()
&& point.Y() >= pos.Y() && point.Y() <= pos.Y() + size.Height();
}
public RectAdp Op_add(RectAdp v) {
return new RectAdp(pos.Op_add(v.Pos()), size.Op_add(v.Size()));
}
@Override public String toString() {return String_.Concat_any(pos, ";", size);}
@Override public boolean equals(Object obj) {
RectAdp comp = (RectAdp)obj;
return size.Eq(comp.size) && pos.Eq(comp.pos);
}
@Override public int hashCode() {return super.hashCode();}
public String Xto_str() {return String_.Concat_any(pos, ",", size);}
@gplx.Internal protected RectAdp(PointAdp pos, SizeAdp size) {this.pos = pos; this.size = size;}
}

View File

@@ -0,0 +1,33 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class RectAdpF { //_20101206 // supports Graphics.MeasureString
public float X() {return x;} float x; public float Y() {return y;} float y;
public float Width() {return width;} float width; public float Height() {return height;} float height;
public SizeAdpF Size() {if (size == null) size = SizeAdpF_.new_(width, height); return size;} SizeAdpF size;
public boolean Eq(RectAdpF comp) {
return comp.x == x && comp.y == y && comp.width == width && comp.height == height;
}
public static final RectAdpF Null = new_(Int_.MinValue, Int_.MinValue, Int_.MinValue, Int_.MinValue);
public static RectAdpF new_(float x, float y, float width, float height) {
RectAdpF rv = new RectAdpF();
rv.x = x; rv.y = y; rv.width = width; rv.height = height;
return rv;
}
}

View File

@@ -0,0 +1,34 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class RectAdp_ {
public static final RectAdp Zero = new RectAdp(PointAdp_.Zero, SizeAdp_.Zero);
public static RectAdp new_(int x, int y, int width, int height) {return new RectAdp(PointAdp_.new_(x, y), SizeAdp_.new_(width, height));}
public static RectAdp corners_(PointAdp upperLeft, PointAdp bottomRight) {return new RectAdp(upperLeft, SizeAdp_.corners_(upperLeft, bottomRight));}
public static RectAdp vector_(PointAdp pos, SizeAdp size) {return new RectAdp(pos, size);}
public static RectAdp size_(int w, int h) {return new_(0, 0, w, h);}
public static RectAdp size_(SizeAdp size) {return new RectAdp(PointAdp_.Zero, size);}
public static RectAdp parse_ws_(String raw) {return parse_(String_.Replace(raw, " ", ""));}
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]));
} catch(Exception exc) {throw Exc_.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

@@ -0,0 +1,36 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class SizeAdp {
public int Width() {return width;} int width;
public int Height() {return height;} int height;
public int AxisLength(GfuiAxisType axis) {return axis == GfuiAxisType.X ? width : height;}
public SizeAdp Op_add(int w, int h) {return SizeAdp_.new_(width + w, height + h);}
@gplx.Internal protected SizeAdp Op_add(SizeAdp s) {return SizeAdp_.new_(width + s.width, height + s.height);}
@gplx.Internal protected SizeAdp Op_subtract(int val) {return SizeAdp_.new_(width - val, height - val);}
@gplx.Internal protected SizeAdp Op_subtract(int w, int h) {return SizeAdp_.new_(width - w, height - h);}
public String XtoStr() {return String_.Concat_any(width, ",", height);}
public boolean Eq(Object o) {
SizeAdp comp = (SizeAdp)o; if (comp == null) return false;
return width == comp.width && height == comp.height;
}
@Override public String toString() {return XtoStr();}
@Override public boolean equals(Object obj) {return Eq(obj);}
@Override public int hashCode() {return super.hashCode();}
@gplx.Internal protected SizeAdp(int width, int height) {this.width = width; this.height = height;}
}

View File

@@ -0,0 +1,25 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class SizeAdpF implements ParseAble {
public float Width() {return width;} float width;
public float Height() {return height;} float height;
public Object ParseAsObj(String raw) {return SizeAdp_.parse_(raw);}
@Override public String toString() {return String_.Concat_any(width, ":", height);}
@gplx.Internal protected SizeAdpF(float width, float height) {this.width = width; this.height = height;}
}

View File

@@ -0,0 +1,34 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class SizeAdpF_ {
public static final SizeAdpF Null = new_(Int_.MinValue, Int_.MinValue);
public static final SizeAdpF Zero = new_(0, 0);
public static final SizeAdpF Parser = new SizeAdpF(0, 0);
public static SizeAdpF as_(Object obj) {return obj instanceof SizeAdpF ? (SizeAdpF)obj : null;}
public static SizeAdpF new_(float width, float height) {return new SizeAdpF(width, height);}
public static SizeAdpF coerce_(Object obj) {SizeAdpF rv = as_(obj); return rv == null ? parse_((String)obj) : rv;}
public static SizeAdpF parse_(String s) {
try {
String[] ary = String_.Split(s, ","); if (ary.length != 2) throw Exc_.new_("SizeAdf should only have 2 numbers separated by 1 comma");
float val1 = Float_.parse_(ary[0]);
float val2 = Float_.parse_(ary[1]);
return new_(val1, val2);
} catch (Exception e) {throw Exc_.new_parse_exc(e, SizeAdpF.class, s);}
}
}

View File

@@ -0,0 +1,42 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class SizeAdp_ {
public static final SizeAdp Null = new SizeAdp(Int_.MinValue, Int_.MinValue);
public static final SizeAdp Zero = new SizeAdp(0, 0);
public static final SizeAdp[] Ary_empty = new SizeAdp[0];
public static SizeAdp cast_(Object obj) {try {return (SizeAdp)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, SizeAdp.class, obj);}}
public static SizeAdp new_(int width, int height) {return new SizeAdp(width, height);}
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_.MinValue); if (w == Int_.MinValue) return or;
int h = Int_.parse_or_(ary[1], Int_.MinValue); if (h == Int_.MinValue) return or;
return new SizeAdp(w, h);
}
public static SizeAdp corners_(PointAdp topLeft, PointAdp bottomRight) {
int width = bottomRight.X() - topLeft.X();
int height = bottomRight.Y() - topLeft.Y();
return new_(width, height);
}
public static PointAdp center_(SizeAdp outer, SizeAdp inner) {
int x = (outer.Width() - inner.Width()) / 2; if (x < 0) x = 0;
int y = (outer.Height() - inner.Height()) / 2; if (y < 0) y = 0;
return PointAdp_.new_(x, y);
}
}