1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-09-29 06:50:50 +00:00
gnosygnu_xowa/150_gfui/src/gplx/gfui/DirInt.java

34 lines
1.2 KiB
Java
Raw Normal View History

/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
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);
}