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-19 23:16:49 -04:00
parent 794b5a232f
commit 8e041d6e06
834 changed files with 4749 additions and 4461 deletions

View File

@@ -37,7 +37,7 @@ public class ClipboardAdp_ {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
String rv = "";
try {rv = clipboard.getData(DataFlavor.stringFlavor).toString();}
catch (Exception e) {throw Exc_.new_exc(e, "ui", "clipboard get_data failed");}
catch (Exception e) {throw Err_.new_exc(e, "ui", "clipboard get_data failed");}
if (Op_sys.Cur().Tid_is_wnt()) { // WORKAROUND:JAVA: On Windows, Clipboard will have \r\n, but Java automatically converts to \n
String_bldr remake = String_bldr_.new_();
for (int i = 0; i < String_.Len(rv); i++) {

View File

@@ -27,7 +27,7 @@ public class CursorAdp {
else {
java.awt.Robot robot = null;
try {robot = new java.awt.Robot();}
catch (java.awt.AWTException e) {throw Exc_.new_exc(e, "ui", "cursor pos set failed");}
catch (java.awt.AWTException e) {throw Err_.new_exc(e, "ui", "cursor pos set failed");}
robot.mouseMove(p.X(), p.Y());
}
}

View File

@@ -38,7 +38,7 @@ public class IconAdp {
public static IconAdp regy_(String key) {
GfoRegyItm itm = GfoRegy._.FetchOrNull(key);
if (itm == null) {UsrDlg_._.Warn("missing icon; key={0}", key); return null;}
if (itm.ValType() != GfoRegyItm.ValType_Url) throw Exc_.new_("regyItm should be of type url", "key", key);
if (itm.ValType() != GfoRegyItm.ValType_Url) throw Err_.new_wo_type("regyItm should be of type url", "key", key);
return IconAdp.file_(itm.Url());
}
public static IconAdp as_(Object obj) {return obj instanceof IconAdp ? (IconAdp)obj : null;}

View File

@@ -31,7 +31,7 @@ import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
public class ImageAdp_ {
public static ImageAdp as_(Object obj) {return obj instanceof ImageAdp ? (ImageAdp)obj : null;}
public static ImageAdp cast_(Object obj) {try {return (ImageAdp)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, ImageAdp.class, obj);}}
public static ImageAdp cast_(Object obj) {try {return (ImageAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, ImageAdp.class, obj);}}
public static final ImageAdp Null = new_(10, 10);
public static ImageAdp new_(int width, int height) {
// BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // JAVA: must be TYPE_INT_RGB or else ImageIO.write("bmp") will fail
@@ -49,7 +49,7 @@ public class ImageAdp_ {
}
public static SizeAdp SizeOf_svg(Io_url url) {return Gfui_svg_util.QuerySize(url);}
public static ImageAdp file_(Io_url url) {
if (url.EqNull()) throw Exc_.new_("cannot load image from null url");
if (url.EqNull()) throw Err_.new_wo_type("cannot load image from null url");
if (String_.Eq(url.Info().Key(), IoUrlInfo_.Mem.Key())) return txt_fil_(url);
if (!Io_mgr.I.ExistsFil(url)) return Null;
@@ -58,7 +58,7 @@ public class ImageAdp_ {
File f = new File(url.Xto_api());
img = ImageIO.read(f);
}
catch (IOException e) {throw Exc_.new_exc(e, "ui", "image load failed", "url", url.Xto_api());}
catch (IOException e) {throw Err_.new_exc(e, "ui", "image load failed", "url", url.Xto_api());}
// FileInputStream istream = new FileInputStream(new File(url.Xto_api()));
// JPEGImageDecoder dec = JPEGCodec.createJPEGDecoder(istream);
// BufferedImage im = dec.decodeAsBufferedImage();
@@ -110,7 +110,7 @@ class Gfui_svg_util {
double w = ParseAtr(xml, pos_ref, "width");
double h = ParseAtr(xml, pos_ref, "height");
return SizeAdp_.new_((int)w, (int)h);
} catch (Exception e) {Exc_.Noop(e); return SizeAdp_.Null;}
} catch (Exception e) {Err_.Noop(e); return SizeAdp_.Null;}
}
static double ParseAtr(String xml, Int_obj_ref pos_ref, String atr) {
int pos = String_.FindFwd(xml, atr, pos_ref.Val()); if (pos == -1) return -1;

View File

@@ -52,7 +52,7 @@ public class ImageAdp_base implements ImageAdp, RlsAble {
boolean success = false;
try {success = ImageIO.write((BufferedImage)under, fmtStr, fil);}
catch (IOException e) {}
if (!success) throw Exc_.new_w_type("gplx.gfui.imgs.SaveImageFailed", "save image failed", "srcUrl", url.Xto_api(), "trgFil", fil, "fmt", fmtStr);
if (!success) throw Err_.new_("gplx.gfui.imgs.SaveImageFailed", "save image failed", "srcUrl", url.Xto_api(), "trgFil", fil, "fmt", fmtStr);
//#@endif
}
public ImageAdp Extract_image(RectAdp src_rect, SizeAdp trg_size) {return Extract_image(src_rect.X(), src_rect.Y(), src_rect.Width(), src_rect.Height(), trg_size.Width(), trg_size.Height());}

View File

@@ -23,13 +23,13 @@ import java.awt.Toolkit;
public class ScreenAdp_ {
public static final ScreenAdp Primary = screen_(0);
public static ScreenAdp as_(Object obj) {return obj instanceof ScreenAdp ? (ScreenAdp)obj : null;}
public static ScreenAdp cast_(Object obj) {try {return (ScreenAdp)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, ScreenAdp.class, obj);}}
public static ScreenAdp cast_(Object obj) {try {return (ScreenAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, ScreenAdp.class, obj);}}
public static ScreenAdp parse_(String raw) { // ex: {screen{1}
try {
raw = String_.Replace(raw, "{screen{", "");
raw = String_.Replace(raw, "}", "");
return ScreenAdp_.screen_(Int_.parse_(raw));
} catch(Exception exc) {throw Exc_.new_parse_exc(exc, ScreenAdp.class, 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
if (ScreenAdp_.Count() == 1) return Primary;
@@ -46,7 +46,7 @@ public class ScreenAdp_ {
// return 1;//Screen.AllScreens.Length;
}
public static ScreenAdp screen_(int index) {
if (index >= ScreenAdp_.Count()) throw Exc_.new_missing_idx(index, ScreenAdp_.Count());
if (index >= ScreenAdp_.Count()) throw Err_.new_missing_idx(index, ScreenAdp_.Count());
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devs = env.getScreenDevices();
GraphicsConfiguration conf = devs[index].getDefaultConfiguration();