mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.6.3.1'
This commit is contained in:
47
400_xowa/src/gplx/xowa/xtns/imaps/Imap_base_fxt.java
Normal file
47
400_xowa/src/gplx/xowa/xtns/imaps/Imap_base_fxt.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.xtns.imaps.itms.*;
|
||||
public class Imap_base_fxt {
|
||||
protected Xoae_app app; protected Xowe_wiki wiki;
|
||||
@gplx.Virtual public void Reset() {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
wiki.Parser_mgr().Ctx().Para().Enabled_n_();
|
||||
}
|
||||
public Imap_part_shape itm_rect_(String link, double... pts_ary) {return itm_shape_(Imap_part_.Tid_shape_rect, link, pts_ary);}
|
||||
public Imap_part_shape itm_circle_(String link, double... pts_ary) {return itm_shape_(Imap_part_.Tid_shape_circle, link, pts_ary);}
|
||||
public Imap_part_shape itm_poly_(String link, double... pts_ary) {return itm_shape_(Imap_part_.Tid_shape_poly, link, pts_ary);}
|
||||
private Imap_part_shape itm_shape_(byte tid, String link, double... pts_ary) {
|
||||
int pts_len = pts_ary.length;
|
||||
Double_obj_val[] pts_doubles = new Double_obj_val[pts_len];
|
||||
for (int i = 0; i < pts_len; ++i)
|
||||
pts_doubles[i] = Double_obj_val.new_(pts_ary[i]);
|
||||
byte[] link_bry = Bry_.new_u8(link);
|
||||
Imap_part_shape rv = new Imap_part_shape(tid, pts_doubles);
|
||||
Imap_link_owner_.Init(rv, app, wiki, link_bry, Make_link_tkn(link_bry));
|
||||
return rv;
|
||||
}
|
||||
private Xop_tkn_itm Make_link_tkn(byte[] src) {
|
||||
Xop_root_tkn root_tkn = new Xop_root_tkn();
|
||||
wiki.Parser_mgr().Main().Parse_text_to_wdom(root_tkn, wiki.Parser_mgr().Ctx(), app.Parser_mgr().Tkn_mkr(), src, Xop_parser_.Doc_bgn_bos);
|
||||
return root_tkn.Subs_get(0);
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
|
||||
interface Imap_itm {
|
||||
byte Itm_tid();
|
||||
}
|
||||
class Imap_itm_ {
|
||||
public static final byte Tid_invalid = 0, Tid_img = 1, Tid_desc = 2, Tid_comment = 3, Tid_dflt = 4, Tid_shape_rect = 5, Tid_shape_circle = 6, Tid_shape_poly = 7;
|
||||
public static final byte[]
|
||||
Key_dflt = Bry_.new_a7("default")
|
||||
, Key_shape_rect = Bry_.new_a7("rect")
|
||||
, Key_shape_circle = Bry_.new_a7("circle")
|
||||
, Key_shape_poly = Bry_.new_a7("poly")
|
||||
;
|
||||
public static byte[] Xto_key(byte v) {
|
||||
switch (v) {
|
||||
case Tid_shape_rect : return Key_shape_rect;
|
||||
case Tid_shape_circle : return Key_shape_circle;
|
||||
case Tid_shape_poly : return Key_shape_poly;
|
||||
default : throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
class Imap_itm_img implements Imap_itm {
|
||||
public Imap_itm_img(Xop_lnki_tkn img_link) {this.img_link = img_link;}
|
||||
public byte Itm_tid() {return Imap_itm_.Tid_img;}
|
||||
public Xop_lnki_tkn Img_link() {return img_link;} private Xop_lnki_tkn img_link;
|
||||
}
|
||||
class Imap_itm_desc implements Imap_itm {
|
||||
public Imap_itm_desc(byte desc_tid) {this.desc_tid = desc_tid;}
|
||||
public byte Itm_tid() {return Imap_itm_.Tid_desc;}
|
||||
public byte Desc_tid() {return desc_tid;} private byte desc_tid;
|
||||
}
|
||||
class Imap_itm_dflt implements Imap_itm, Imap_link_owner {
|
||||
public byte Itm_tid() {return Imap_itm_.Tid_dflt;}
|
||||
public int Link_tid() {return link_tid;} private int link_tid;
|
||||
public Xop_tkn_itm Link_tkn() {return link_tkn;} private Xop_tkn_itm link_tkn;
|
||||
public void Link_tid_(int tid, Xop_tkn_itm tkn) {link_tid = tid; link_tkn = tkn;}
|
||||
public byte[] Link_href() {return link_href;} public void Link_href_(byte[] v) {this.link_href = v;} private byte[] link_href;
|
||||
public byte[] Link_text() {return link_text;} public void Link_text_(byte[] v) {this.link_text = v;} private byte[] link_text;
|
||||
}
|
||||
class Imap_err {
|
||||
public Imap_err(int itm_idx, String err_key) {this.itm_idx = itm_idx; this.err_key = err_key;}
|
||||
public int Itm_idx() {return itm_idx;} private int itm_idx;
|
||||
public String Err_key() {return err_key;} private String err_key;
|
||||
}
|
||||
@@ -16,60 +16,59 @@ 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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.files.gui.*; import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.htmls.core.makes.imgs.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.gui.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
|
||||
import gplx.xowa.xtns.imaps.itms.*; import gplx.xowa.xtns.imaps.htmls.*;
|
||||
public class Imap_map implements Xoh_file_img_wkr, Js_img_wkr {
|
||||
private static final Imap_map_fmtr map_fmtr_arg = new Imap_map_fmtr();
|
||||
private byte img_cls_tid; private Imap_xtn_mgr xtn_mgr;
|
||||
private byte[] a_href, img_alt, img_cls_other;
|
||||
public Imap_map(int id) {this.id = id;}
|
||||
public Imap_xtn_mgr Xtn_mgr() {return xtn_mgr;} private Imap_xtn_mgr xtn_mgr;
|
||||
@gplx.Internal protected void Init(Imap_xtn_mgr xtn_mgr, byte[] img_src, Imap_itm_img img, Imap_itm_dflt dflt, Imap_itm_desc desc, Imap_itm_shape[] shapes, Imap_err[] errs) {
|
||||
public void Init(Imap_xtn_mgr xtn_mgr, byte[] img_src, Imap_part_img img, Imap_part_dflt dflt, Imap_part_desc desc, Imap_part_shape[] shapes, Imap_err[] errs) {
|
||||
this.xtn_mgr = xtn_mgr; this.img_src = img_src; this.img = img; this.dflt = dflt; this.desc = desc; this.shapes = shapes; this.errs = errs;
|
||||
}
|
||||
public boolean Invalid() {return img == null;} // invalid if missing image; PAGE:en.w:Wikipedia:WikiProject_Games/Advert EX: <imagemap>|thumb;</imagemap>; DATE:2014-08-12
|
||||
public int Id() {return id;} private int id;
|
||||
public byte[] Img_src() {return img_src;} private byte[] img_src;
|
||||
@gplx.Internal protected Imap_itm_img Img() {return img;} private Imap_itm_img img;
|
||||
@gplx.Internal protected Imap_itm_dflt Dflt() {return dflt;} private Imap_itm_dflt dflt;
|
||||
@gplx.Internal protected Imap_itm_desc Desc() {return desc;} private Imap_itm_desc desc;
|
||||
@gplx.Internal protected Imap_itm_shape[] Shapes() {return shapes;} private Imap_itm_shape[] shapes;
|
||||
@gplx.Internal protected Imap_err[] Errs() {return errs;} private Imap_err[] errs;
|
||||
private byte img_cls_tid;
|
||||
private byte[] a_href, img_alt, img_cls_other;
|
||||
public int Id() {return id;} private final int id;
|
||||
public byte[] Img_src() {return img_src;} private byte[] img_src;
|
||||
public Imap_part_img Img() {return img;} private Imap_part_img img;
|
||||
public Imap_part_dflt Dflt() {return dflt;} private Imap_part_dflt dflt;
|
||||
public Imap_part_desc Desc() {return desc;} private Imap_part_desc desc;
|
||||
public Imap_part_shape[] Shapes() {return shapes;} private Imap_part_shape[] shapes;
|
||||
public Imap_err[] Errs() {return errs;} private Imap_err[] errs;
|
||||
public boolean Invalid() {return img == null;} // invalid if missing image; PAGE:en.w:Wikipedia:WikiProject_Games/Advert EX: <imagemap>|thumb;</imagemap>; DATE:2014-08-12
|
||||
|
||||
public void Html_full_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm, int uid
|
||||
, byte[] a_href, boolean a_href_is_file, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
|
||||
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other
|
||||
) {
|
||||
this.a_href = a_href; this.img_alt = img_alt; this.img_cls_tid = img_cls; this.img_cls_other = img_cls_other;
|
||||
xfer_itm.Html_img_wkr_(this);
|
||||
xfer_itm.Html_elem_tid_(Xof_html_elem.Tid_imap);
|
||||
this.a_href = a_href; this.img_alt = img_alt; this.img_cls_tid = img_cls; this.img_cls_other = img_cls_other;
|
||||
Write_imap_div(tmp_bfr, page.Wikie(), hctx, src, uid, img_w, img_h, img_src, xfer_itm.Orig_w(), xfer_itm.Orig_h(), a_xowa_title);
|
||||
if (hctx.Mode_is_hdump())
|
||||
page.Hdump_data().Imgs_add_img(new Xohd_img_itm__img(), xfer_itm, Xohd_img_itm__gallery_itm.Tid_basic);
|
||||
if (hctx.Mode_is_hdump()) {
|
||||
img_w = xfer_itm.Lnki_w(); // NOTE: hdump must dump lnki_w, not img_w; GUI will either (a) write -1 and update later thru js_wkr; (b) get correct img_w from cache; hdump can do neither (a) nor (b); DATE:2016-06-17
|
||||
img_h = xfer_itm.Lnki_h();
|
||||
page.Hdump_data().Imgs_add_img(new Xohd_img_itm__img(), xfer_itm, Xohd_img_itm__gallery_itm.Tid_basic); // DELETE: no need to add img to global collection during hdump; was here presumably to write entries to "imgs" table; DATE:2016-06-17
|
||||
}
|
||||
Write_imap_div(tmp_bfr, hctx, uid, img_w, img_h, img_src, xfer_itm.Orig_w(), xfer_itm.Orig_h(), a_xowa_title);
|
||||
}
|
||||
public void Html_update(Xoa_page page, Xog_js_wkr js_wkr, int html_uid, int html_w, int html_h, Io_url html_view_url, int orig_w, int orig_h, Io_url html_orig_url, byte[] lnki_ttl) {
|
||||
Xowe_wiki wiki = xtn_mgr.Wiki();
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_k004();
|
||||
Write_imap_div(tmp_bfr, (Xowe_wiki)page.Wiki(), Xoh_wtr_ctx.Basic, Bry_.Empty, html_uid, html_w, html_h, html_view_url.To_http_file_bry(), orig_w, orig_h, lnki_ttl);
|
||||
js_wkr.Html_elem_replace_html("imap_div_" + Int_.To_str(html_uid), tmp_bfr.To_str_and_rls());
|
||||
public void Js_wkr__update_hdoc(Xoa_page page, Xog_js_wkr js_wkr, int html_uid
|
||||
, int html_w, int html_h, Io_url html_view_url
|
||||
, int orig_w, int orig_h, Io_url html_orig_url, byte[] lnki_ttl) {
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.Get();
|
||||
try {
|
||||
Write_imap_div(tmp_bfr, Xoh_wtr_ctx.Basic, html_uid, html_w, html_h, html_view_url.To_http_file_bry(), orig_w, orig_h, lnki_ttl);
|
||||
js_wkr.Html_elem_replace_html("imap_div_" + Int_.To_str(html_uid), tmp_bfr.To_str_and_rls());
|
||||
} finally {tmp_bfr.Mkr_rls();}
|
||||
}
|
||||
private void Write_imap_div(Bry_bfr bfr, Xowe_wiki wiki, Xoh_wtr_ctx hctx, byte[] src, int html_uid, int html_w, int html_h, byte[] html_src, int orig_w, int orig_h, byte[] lnki_ttl) {
|
||||
byte[] desc_style = Calc_desc_style(html_w, html_h);
|
||||
// int shapes_len = shapes.length;
|
||||
// for (int i = 0; i < shapes_len; ++i) {
|
||||
// Imap_itm_shape shape = shapes[i];
|
||||
// Imap_link_owner_.Write(shape, wiki.Appe(), wiki, hctx, src);
|
||||
// }
|
||||
map_fmtr_arg.Init(id, shapes, Calc_scale(orig_w, orig_h, html_w, html_h));
|
||||
img_fmtr_arg.Init(hctx, xtn_mgr, this, src, html_uid, img_alt, html_src, html_w, html_h, Xoh_img_cls_.To_html(img_cls_tid, img_cls_other), a_href, lnki_ttl);
|
||||
Imap_html_fmtrs.All.Bld_bfr_many(bfr, html_uid, desc_style, map_fmtr_arg, img_fmtr_arg);
|
||||
private void Write_imap_div(Bry_bfr bfr, Xoh_wtr_ctx hctx, int html_uid, int html_w, int html_h, byte[] img_src, int orig_w, int orig_h, byte[] lnki_ttl) {
|
||||
Imap_map_arg map_arg = new Imap_map_arg(id, shapes, Calc_scale(orig_w, orig_h, html_w, html_h));
|
||||
Imap_img_arg img_arg = new Imap_img_arg(hctx, xtn_mgr, this, html_uid, img_alt, img_src, html_w, html_h, Xoh_img_cls_.To_html(img_cls_tid, img_cls_other), a_href, lnki_ttl);
|
||||
Imap_html_fmtrs.All.Bld_bfr_many(bfr, html_uid, Calc_desc_style(desc, html_w, html_h), map_arg, img_arg);
|
||||
}
|
||||
private byte[] Calc_desc_style(int html_w, int html_h) {
|
||||
private static byte[] Calc_desc_style(Imap_part_desc desc, int html_w, int html_h) {
|
||||
if (desc == null) return Bry_.Empty;
|
||||
Bry_bfr tmp_bfr = xtn_mgr.Wiki().Utl__bfr_mkr().Get_b128().Mkr_rls();
|
||||
return Imap_html_fmtrs.Desc_style.Bld_bry_many(tmp_bfr, html_w, html_h);
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.Get();
|
||||
try {return Imap_html_fmtrs.Desc_style.Bld_bry_many(tmp_bfr, html_w, html_h);}
|
||||
finally {tmp_bfr.Mkr_rls();}
|
||||
}
|
||||
private static final Imap_img_fmtr_arg img_fmtr_arg = new Imap_img_fmtr_arg();
|
||||
private static double Calc_scale(int orig_w, int orig_h, int html_w, int html_h) {
|
||||
int denominator = orig_w + orig_h;
|
||||
int numerator = html_w + html_h;
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
class Imap_map_fmtr implements gplx.core.brys.Bfr_arg {
|
||||
private int imap_id;
|
||||
public void Init(int imap_id, Imap_itm_shape[] shapes, double scale) {this.imap_id = imap_id; shapes_fmtr_arg.Init(shapes, scale);}
|
||||
public Imap_pts_fmtr_arg Pts_fmtr() {return shapes_fmtr_arg.Pts_fmtr();}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
Imap_html_fmtrs.Map.Bld_bfr_many(bfr, imap_id, shapes_fmtr_arg);
|
||||
}
|
||||
private static final Imap_shapes_fmtr shapes_fmtr_arg = new Imap_shapes_fmtr();
|
||||
}
|
||||
class Imap_shapes_fmtr implements gplx.core.brys.Bfr_arg {
|
||||
private Imap_itm_shape[] shapes;
|
||||
public void Init(Imap_itm_shape[] shapes, double scale) {this.shapes = shapes; pts_fmtr_arg.Scale_(scale);}
|
||||
public Imap_pts_fmtr_arg Pts_fmtr() {return pts_fmtr_arg;}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
int shapes_len = shapes.length;
|
||||
Bry_fmtr fmtr = Imap_html_fmtrs.Area;
|
||||
for (int i = 0; i < shapes_len; ++i) {
|
||||
Imap_itm_shape shape = shapes[i];
|
||||
Fmt_shape(bfr, fmtr, pts_fmtr_arg, shape);
|
||||
}
|
||||
}
|
||||
@gplx.Internal protected static void Fmt_shape(Bry_bfr bfr, Bry_fmtr fmtr, Imap_pts_fmtr_arg pts_fmtr, Imap_itm_shape shape) {
|
||||
pts_fmtr_arg.Pts_(shape.Shape_pts());
|
||||
fmtr.Bld_bfr_many(bfr
|
||||
, shape.Link_href()
|
||||
, Imap_itm_.Xto_key(shape.Itm_tid())
|
||||
, pts_fmtr_arg
|
||||
, shape.Link_text()
|
||||
);
|
||||
}
|
||||
private static final Imap_pts_fmtr_arg pts_fmtr_arg = new Imap_pts_fmtr_arg();
|
||||
}
|
||||
@@ -18,13 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.core.btries.*; import gplx.core.primitives.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.lnkis.files.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.tmpls.*;
|
||||
class Imap_parser {
|
||||
import gplx.xowa.xtns.imaps.itms.*;
|
||||
public class Imap_parser {
|
||||
private Imap_xtn_mgr xtn_mgr; private Xoa_url page_url; private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Instance;
|
||||
private byte[] imap_img_src;
|
||||
private Imap_itm_img imap_img;
|
||||
private Imap_itm_dflt imap_dflt;
|
||||
private Imap_itm_desc imap_desc;
|
||||
private List_adp shapes = List_adp_.new_(), pts = List_adp_.new_(), errs = List_adp_.new_();
|
||||
private Imap_part_img imap_img;
|
||||
private Imap_part_dflt imap_dflt;
|
||||
private Imap_part_desc imap_desc;
|
||||
private List_adp shapes = List_adp_.New(), pts = List_adp_.New(), errs = List_adp_.New();
|
||||
private byte[] src;
|
||||
private int itm_idx; private int itm_bgn, itm_end;
|
||||
private Xoae_app app; private Xowe_wiki wiki; private Xop_ctx wiki_ctx, imap_ctx; private Xop_root_tkn imap_root;
|
||||
@@ -68,43 +69,42 @@ class Imap_parser {
|
||||
itm_end = Parse_img(rv, itm_bgn, itm_end, src_end);
|
||||
else {
|
||||
Object tid_obj = tid_trie.Match_bgn_w_byte(b, src, itm_bgn, itm_end);
|
||||
byte tid_val = tid_obj == null ? Imap_itm_.Tid_invalid : ((Byte_obj_val)tid_obj).Val();
|
||||
byte tid_val = tid_obj == null ? Imap_part_.Tid_invalid : ((Byte_obj_val)tid_obj).Val();
|
||||
int tid_end_pos = tid_trie.Match_pos();
|
||||
switch (tid_val) {
|
||||
case Imap_itm_.Tid_desc: Parse_desc(tid_end_pos, itm_end); break;
|
||||
case Imap_itm_.Tid_dflt: Parse_dflt(tid_end_pos, itm_end); break;
|
||||
case Imap_itm_.Tid_shape_rect: Parse_shape(tid_val, tid_end_pos, itm_bgn, itm_end, 4); break;
|
||||
case Imap_itm_.Tid_shape_poly: Parse_shape(tid_val, tid_end_pos, itm_bgn, itm_end, Reqd_poly); break;
|
||||
case Imap_itm_.Tid_shape_circle: Parse_shape(tid_val, tid_end_pos, itm_bgn, itm_end, 3); break;
|
||||
case Imap_part_.Tid_desc: Parse_desc(tid_end_pos, itm_end); break;
|
||||
case Imap_part_.Tid_dflt: Parse_dflt(tid_end_pos, itm_end); break;
|
||||
case Imap_part_.Tid_shape_rect: Parse_shape(tid_val, tid_end_pos, itm_bgn, itm_end, 4); break;
|
||||
case Imap_part_.Tid_shape_poly: Parse_shape(tid_val, tid_end_pos, itm_bgn, itm_end, Reqd_poly); break;
|
||||
case Imap_part_.Tid_shape_circle: Parse_shape(tid_val, tid_end_pos, itm_bgn, itm_end, 3); break;
|
||||
default:
|
||||
case Imap_itm_.Tid_invalid: Parse_invalid(itm_bgn, itm_end); break;
|
||||
case Imap_part_.Tid_invalid: Parse_invalid(itm_bgn, itm_end); break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {usr_dlg.Warn_many("", "", "imap.parse:skipping line; page=~{0} line=~{1} err=~{2}", page_url.To_str(), Bry_.Mid_safe(src, itm_bgn, itm_end), Err_.Message_gplx_log(e));}
|
||||
++itm_idx;
|
||||
}
|
||||
rv.Init(xtn_mgr, imap_img_src, imap_img, imap_dflt, imap_desc, (Imap_itm_shape[])shapes.To_ary_and_clear(Imap_itm_shape.class), (Imap_err[])errs.To_ary_and_clear(Imap_err.class));
|
||||
rv.Init(xtn_mgr, imap_img_src, imap_img, imap_dflt, imap_desc, (Imap_part_shape[])shapes.To_ary_and_clear(Imap_part_shape.class), (Imap_err[])errs.To_ary_and_clear(Imap_err.class));
|
||||
}
|
||||
private void Parse_comment(int itm_bgn, int itm_end) {} // noop comments; EX: "# comment\n"
|
||||
private void Parse_invalid(int itm_bgn, int itm_end) {usr_dlg.Warn_many("", "", "imap has invalid line: page=~{0} line=~{1}", page_url.To_str(), String_.new_u8(src, itm_bgn, itm_end));}
|
||||
private boolean Parse_desc(int itm_bgn, int itm_end) {
|
||||
xtn_mgr.Desc_assert();
|
||||
Btrie_slim_mgr trie = xtn_mgr.Desc_trie();
|
||||
byte tid_desc = Imap_desc_tid.parse(trie, src, Bry_find_.Trim_fwd_space_tab(src, itm_bgn, itm_end), Bry_find_.Trim_bwd_space_tab(src, itm_end, itm_bgn));
|
||||
byte tid_desc = Imap_desc_tid.Parse_to_tid(trie, src, Bry_find_.Trim_fwd_space_tab(src, itm_bgn, itm_end), Bry_find_.Trim_bwd_space_tab(src, itm_end, itm_bgn));
|
||||
switch (tid_desc) {
|
||||
case Imap_desc_tid.Tid_null: return Add_err(Bool_.N, itm_bgn, itm_end, "imagemap_invalid_coord");
|
||||
case Imap_desc_tid.Tid_none: return true;
|
||||
}
|
||||
if (imap_img == null || imap_img.Img_link().Lnki_type() == Xop_lnki_type.Id_thumb) return true; // thumbs don't get desc
|
||||
imap_desc = new Imap_itm_desc(tid_desc);
|
||||
imap_desc = new Imap_part_desc(tid_desc);
|
||||
return true;
|
||||
}
|
||||
private void Parse_dflt(int itm_bgn, int itm_end) {
|
||||
imap_dflt = new Imap_itm_dflt();
|
||||
imap_dflt = new Imap_part_dflt();
|
||||
Init_link_owner(imap_dflt, src, itm_bgn, itm_end);
|
||||
}
|
||||
private boolean Parse_shape(byte shape_tid, int tid_end_pos, int itm_bgn, int itm_end, int reqd_pts) {
|
||||
boolean shape_is_poly = shape_tid == Imap_itm_.Tid_shape_poly;
|
||||
boolean shape_is_poly = shape_tid == Imap_part_.Tid_shape_poly;
|
||||
int pos = Bry_find_.Trim_fwd_space_tab(src, tid_end_pos, itm_end); // gobble any leading spaces
|
||||
int grp_end = Bry_find_.Find_fwd(src, Byte_ascii.Brack_bgn, pos, itm_end); // find first "["; note that this is a lazy way of detecting start of lnki / lnke; MW has complicated regex, but hopefully this will be enough; DATE:2014-10-22
|
||||
if (grp_end == -1) {return Add_err(Bool_.Y, itm_bgn, itm_end, "imap_No valid link was found");}
|
||||
@@ -149,7 +149,7 @@ class Imap_parser {
|
||||
if (pts_len < reqd_pts) return Add_err(Bool_.Y, itm_bgn, itm_end, "imagemap_missing_coord");
|
||||
}
|
||||
pos = Bry_find_.Trim_fwd_space_tab(src, pos, itm_end);
|
||||
Imap_itm_shape shape_itm = new Imap_itm_shape(shape_tid, (Double_obj_val[])pts.To_ary_and_clear(Double_obj_val.class));
|
||||
Imap_part_shape shape_itm = new Imap_part_shape(shape_tid, (Double_obj_val[])pts.To_ary_and_clear(Double_obj_val.class));
|
||||
Init_link_owner(shape_itm, src, pos, itm_end);
|
||||
shapes.Add(shape_itm);
|
||||
return true;
|
||||
@@ -194,7 +194,7 @@ class Imap_parser {
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "image_map failed to find lnki; page=~{0} imageMap=~{1}", page_url.To_str(), imap_img_src);
|
||||
else {
|
||||
Xop_lnki_tkn lnki_tkn = (Xop_lnki_tkn)tkn_itm;
|
||||
imap_img = new Imap_itm_img(lnki_tkn);
|
||||
imap_img = new Imap_part_img(lnki_tkn);
|
||||
lnki_tkn.Lnki_file_wkr_(imap);
|
||||
wiki_ctx.Page().Lnki_list().Add(lnki_tkn);
|
||||
wiki_ctx.Lnki().File_logger().Log_file(wiki_ctx, lnki_tkn, Xop_file_logger_.Tid__imap); // NOTE: do not do imap_ctx.Lnki(); imap_ctx is brand new
|
||||
@@ -226,12 +226,12 @@ class Imap_parser {
|
||||
return rv;
|
||||
}
|
||||
private static Btrie_slim_mgr tid_trie = Btrie_slim_mgr.ci_a7() // names are not i18n'd; // NOTE:ci.ascii:MW_const.en
|
||||
.Add_str_byte("desc" , Imap_itm_.Tid_desc)
|
||||
.Add_str_byte("#" , Imap_itm_.Tid_comment)
|
||||
.Add_bry_byte(Imap_itm_.Key_dflt , Imap_itm_.Tid_dflt)
|
||||
.Add_bry_byte(Imap_itm_.Key_shape_rect , Imap_itm_.Tid_shape_rect)
|
||||
.Add_bry_byte(Imap_itm_.Key_shape_circle , Imap_itm_.Tid_shape_circle)
|
||||
.Add_bry_byte(Imap_itm_.Key_shape_poly , Imap_itm_.Tid_shape_poly)
|
||||
.Add_str_byte("desc" , Imap_part_.Tid_desc)
|
||||
.Add_str_byte("#" , Imap_part_.Tid_comment)
|
||||
.Add_bry_byte(Imap_part_.Key_dflt , Imap_part_.Tid_dflt)
|
||||
.Add_bry_byte(Imap_part_.Key_shape_rect , Imap_part_.Tid_shape_rect)
|
||||
.Add_bry_byte(Imap_part_.Key_shape_circle , Imap_part_.Tid_shape_circle)
|
||||
.Add_bry_byte(Imap_part_.Key_shape_poly , Imap_part_.Tid_shape_poly)
|
||||
;
|
||||
private static final int Reqd_poly = -1;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ 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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import org.junit.*; import gplx.core.primitives.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*; import gplx.core.primitives.*; import gplx.xowa.parsers.*; import gplx.xowa.xtns.imaps.itms.*;
|
||||
public class Imap_parser_tst {
|
||||
@Before public void init() {fxt.Reset();} private Imap_parser_fxt fxt = new Imap_parser_fxt();
|
||||
@Test public void Rect_pass() {fxt.Test_shape("rect 1 2 3 4 [[A]]" , fxt.itm_rect_("[[A]]", 1, 2, 3, 4));}
|
||||
@@ -36,33 +36,7 @@ public class Imap_parser_tst {
|
||||
@Test public void Poly_fail_zero() {fxt.Test_shape_err("poly [[A]]" , "imagemap_missing_coord");}
|
||||
@Test public void Circle_fail_invalid() {fxt.Test_shape_err("rect 1 2..3 4 [[A]]" , "imagemap_invalid_coord");}
|
||||
}
|
||||
class Imap_fxt_base {
|
||||
protected Xoae_app app; protected Xowe_wiki wiki;
|
||||
@gplx.Virtual public void Reset() {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
wiki.Parser_mgr().Ctx().Para().Enabled_n_();
|
||||
}
|
||||
public Imap_itm_shape itm_rect_(String link, double... pts_ary) {return itm_shape_(Imap_itm_.Tid_shape_rect, link, pts_ary);}
|
||||
public Imap_itm_shape itm_circle_(String link, double... pts_ary) {return itm_shape_(Imap_itm_.Tid_shape_circle, link, pts_ary);}
|
||||
public Imap_itm_shape itm_poly_(String link, double... pts_ary) {return itm_shape_(Imap_itm_.Tid_shape_poly, link, pts_ary);}
|
||||
private Imap_itm_shape itm_shape_(byte tid, String link, double... pts_ary) {
|
||||
int pts_len = pts_ary.length;
|
||||
Double_obj_val[] pts_doubles = new Double_obj_val[pts_len];
|
||||
for (int i = 0; i < pts_len; ++i)
|
||||
pts_doubles[i] = Double_obj_val.new_(pts_ary[i]);
|
||||
byte[] link_bry = Bry_.new_u8(link);
|
||||
Imap_itm_shape rv = new Imap_itm_shape(tid, pts_doubles);
|
||||
Imap_link_owner_.Init(rv, app, wiki, link_bry, Make_link_tkn(link_bry));
|
||||
return rv;
|
||||
}
|
||||
private Xop_tkn_itm Make_link_tkn(byte[] src) {
|
||||
Xop_root_tkn root_tkn = new Xop_root_tkn();
|
||||
wiki.Parser_mgr().Main().Parse_text_to_wdom(root_tkn, wiki.Parser_mgr().Ctx(), app.Parser_mgr().Tkn_mkr(), src, Xop_parser_.Doc_bgn_bos);
|
||||
return root_tkn.Subs_get(0);
|
||||
}
|
||||
}
|
||||
class Imap_parser_fxt extends Imap_fxt_base {
|
||||
class Imap_parser_fxt extends Imap_base_fxt {
|
||||
private Imap_parser parser;
|
||||
private Imap_map imap;
|
||||
@Override public void Reset() {
|
||||
@@ -75,17 +49,17 @@ class Imap_parser_fxt extends Imap_fxt_base {
|
||||
parser.Clear();
|
||||
imap = new Imap_map(1);
|
||||
}
|
||||
public void Test_shape(String raw_str, Imap_itm_shape expd) {
|
||||
public void Test_shape(String raw_str, Imap_part_shape expd) {
|
||||
raw_str = "File:A.png\n" + raw_str;
|
||||
byte[] raw = Bry_.new_u8(raw_str);
|
||||
parser.Parse(imap, raw, 0, raw.length);
|
||||
Imap_itm_shape[] actl_ary = imap.Shapes();
|
||||
Imap_itm_shape actl = actl_ary == null | actl_ary.length != 1 ? null : (Imap_itm_shape)actl_ary[0];
|
||||
Imap_part_shape[] actl_ary = imap.Shapes();
|
||||
Imap_part_shape actl = actl_ary == null | actl_ary.length != 1 ? null : (Imap_part_shape)actl_ary[0];
|
||||
if (actl == null && expd == null) {} // noop; test passed
|
||||
else if (actl == null && expd != null) {Tfds.Fail("actl should not be null", raw);}
|
||||
else if (actl != null && expd == null) {Tfds.Fail("actl should be null", raw);}
|
||||
else {
|
||||
Tfds.Eq(expd.Itm_tid(), actl.Itm_tid(), "tid");
|
||||
Tfds.Eq(expd.Part_tid(), actl.Part_tid(), "tid");
|
||||
Tfds.Eq_ary(expd.Shape_pts(), actl.Shape_pts(), "pts");
|
||||
Tfds.Eq(String_.new_u8(expd.Link_href()), String_.new_u8(actl.Link_href()));
|
||||
Tfds.Eq(String_.new_u8(expd.Link_text()), String_.new_u8(actl.Link_text()));
|
||||
@@ -98,6 +72,6 @@ class Imap_parser_fxt extends Imap_fxt_base {
|
||||
parser.Parse(imap, raw, 0, raw.length);
|
||||
Imap_err[] err_ary = imap.Errs();
|
||||
Tfds.Eq(1, err_ary.length, "expd 1 err");
|
||||
Tfds.Eq(expd_err, err_ary[0].Err_key());
|
||||
Tfds.Eq(expd_err, err_ary[0].Err_msg());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,22 +16,25 @@ 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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.logs.*; import gplx.xowa.parsers.xndes.*;
|
||||
public class Imap_xnde implements Xox_xnde {
|
||||
private Imap_xtn_mgr xtn_mgr;
|
||||
private Imap_map imap_data;
|
||||
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
xtn_mgr = wiki.Xtn_mgr().Xtn_imap();
|
||||
xtn_mgr.Xtn_assert();
|
||||
// init
|
||||
xtn_mgr = wiki.Xtn_mgr().Xtn_imap().Xtn_assert();
|
||||
Xoae_page page = ctx.Page();
|
||||
page.Html_data().Head_mgr().Itm__popups().Bind_hover_area_(true);
|
||||
page.Html_data().Xtn_imap_exists_y_();
|
||||
page.Html_data().Head_mgr().Itm__popups().Bind_hover_area_(true);
|
||||
|
||||
// parse imap
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_end);
|
||||
imap_data = xtn_mgr.Parser().Parse(wiki, ctx, root, src, xnde);
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_end);
|
||||
boolean log_wkr_enabled = Log_wkr != Xop_log_basic_wkr.Null; if (log_wkr_enabled) Log_wkr.Log_end_xnde(ctx.Page(), Xop_log_basic_wkr.Tid_imageMap, src, xnde);
|
||||
} public static Xop_log_basic_wkr Log_wkr = Xop_log_basic_wkr.Null;
|
||||
|
||||
public void Xtn_write(Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_xnde_tkn xnde, byte[] src) {
|
||||
if (imap_data.Invalid()) return;
|
||||
html_wtr.Write_tkn(bfr, ctx, hctx, imap_data.Img_src(), xnde, Xoh_html_wtr.Sub_idx_null, imap_data.Img().Img_link());
|
||||
|
||||
@@ -16,35 +16,34 @@ 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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.wikis.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
|
||||
public class Imap_xtn_mgr extends Xox_mgr_base implements GfoInvkAble {
|
||||
import gplx.core.btries.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
|
||||
import gplx.xowa.xtns.imaps.itms.*;
|
||||
public class Imap_xtn_mgr extends Xox_mgr_base implements Gfo_invk {
|
||||
private boolean init;
|
||||
@Override public boolean Enabled_default() {return true;}
|
||||
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("imageMap");
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
@gplx.Internal protected Imap_parser Parser() {return parser;} private Imap_parser parser;
|
||||
public void Desc_assert() {
|
||||
if (desc_trie != null) return;
|
||||
desc_trie = Imap_desc_tid.trie_(wiki);
|
||||
desc_msg = wiki.Msg_mgr().Val_by_key_obj("imagemap_description");
|
||||
desc_icon_url = wiki.Appe().Fsys_mgr().Bin_xtns_dir().GenSubFil_nest("ImageMap", "imgs", "desc-20.png").To_http_file_bry();
|
||||
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("imageMap");
|
||||
@Override public boolean Enabled_default() {return true;}
|
||||
public Xoh_arg_img_core Img_core_arg() {return img_core_arg;} private final Xoh_arg_img_core__basic img_core_arg = new Xoh_arg_img_core__basic();
|
||||
public Imap_parser Parser() {return parser;} private Imap_parser parser;
|
||||
public byte[] Desc_msg() {return desc_msg;} private byte[] desc_msg;
|
||||
public byte[] Desc_icon_url() {return desc_icon_url;} private byte[] desc_icon_url;
|
||||
public Btrie_slim_mgr Desc_trie() {
|
||||
if (desc_trie == null) {
|
||||
this.desc_trie = Imap_desc_tid.New_trie(wiki);
|
||||
this.desc_msg = wiki.Msg_mgr().Val_by_key_obj("imagemap_description");
|
||||
this.desc_icon_url = wiki.Appe().Fsys_mgr().Bin_xtns_dir().GenSubFil_nest("ImageMap", "imgs", "desc-20.png").To_http_file_bry();
|
||||
}
|
||||
return desc_trie;
|
||||
} private Btrie_slim_mgr desc_trie;
|
||||
public Imap_xtn_mgr Xtn_assert() {
|
||||
if (init) return this;
|
||||
this.init = true;
|
||||
this.parser = new Imap_parser(this);
|
||||
return this;
|
||||
}
|
||||
public Btrie_slim_mgr Desc_trie() {return desc_trie;} private Btrie_slim_mgr desc_trie;
|
||||
public byte[] Desc_msg() {return desc_msg;} private byte[] desc_msg;
|
||||
public byte[] Desc_icon_url() {return desc_icon_url;} private byte[] desc_icon_url;
|
||||
public final Xoh_arg_img_core Img_core_fmtr = new Xoh_arg_img_core__basic();
|
||||
public final Xoh_file_html_fmtr__hdump Img_html_hdump_bldr = Xoh_file_html_fmtr__hdump.Hdump;
|
||||
public final Bry_bfr Tmp_bfr = Bry_bfr.new_(255);
|
||||
@Override public Xox_mgr Clone_new() {return new Imap_xtn_mgr();}
|
||||
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
}
|
||||
public void Xtn_assert() {
|
||||
if (init) return;
|
||||
parser = new Imap_parser(this);
|
||||
init = true;
|
||||
}
|
||||
public static final byte[]
|
||||
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {this.wiki = wiki;} private Xowe_wiki wiki;
|
||||
@Override public Xox_mgr Xtn_clone_new() {return new Imap_xtn_mgr();}
|
||||
|
||||
public static final byte[]
|
||||
Bry__usemap__html = Bry_.new_a7(" usemap=\"#imagemap_1_")
|
||||
, Bry__usemap__name = Bry_.new_a7("usemap")
|
||||
, Bry__usemap__prefix = Bry_.new_a7("#imagemap_1_")
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Imap_html__hdump__tst {
|
||||
@Before public void init() {fxt.Reset(); fxt.Fxt().Hctx_(Xoh_wtr_ctx.Hdump);} private final Imap_xnde_html_fxt fxt = new Imap_xnde_html_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|thumb|100x200px|a1"
|
||||
, "circle 0 0 5 [[B|b1]]"
|
||||
, "rect 0 0 4 8 [[C|c1]]"
|
||||
, "desc none"
|
||||
, "</imagemap>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div class=\"thumbinner\" style=\"width:100px;\">" // NOTE:220px is default w for "non-found" thumb; DATE:2014-09-24
|
||||
, " <div id='imap_div_0' class=\"noresize\">"
|
||||
, " <map name=\"imageMap_1_1\">"
|
||||
, " <area href=\"/wiki/B\" shape=\"circle\" coords=\"0,0,5\" alt=\"b1\" title=\"b1\"/>"
|
||||
, " <area href=\"/wiki/C\" shape=\"rect\" coords=\"0,0,4,8\" alt=\"c1\" title=\"c1\"/>"
|
||||
, " </map>"
|
||||
, " <img data-xowa-title=\"A.png\" data-xoimg=\"1|100|200|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" class=\"thumbimage\" alt=\"\" usemap=\"#imagemap_1_1\"/>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>a1"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,10 @@ 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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
package gplx.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import org.junit.*; import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
public class Imap_xnde_html_all_tst {
|
||||
@Before public void init() {fxt.Reset();} private final Imap_xnde_html_fxt fxt = new Imap_xnde_html_fxt();
|
||||
public class Imap_html__hview__tst {
|
||||
@Before public void init() {fxt.Reset();} private final Imap_xnde_html_fxt fxt = new Imap_xnde_html_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
@@ -193,7 +193,7 @@ class Imap_xnde_html_fxt {
|
||||
Xol_msg_itm msg = fxt.Wiki().Msg_mgr().Get_or_make(Bry_.new_a7("imagemap_description"));
|
||||
msg.Atrs_set(Bry_.new_a7("click here"), false, false);
|
||||
}
|
||||
public Xop_fxt Fxt() {return fxt;} private final Xop_fxt fxt = new Xop_fxt();
|
||||
public Xop_fxt Fxt() {return fxt;} private final Xop_fxt fxt = new Xop_fxt();
|
||||
public void Test_html_full_str(String raw, String expd) {fxt.Test_html_full_str(raw, expd);}
|
||||
public void Test_html_full_frag(String raw, String expd) {fxt.Test_html_full_frag(raw, expd);}
|
||||
public String Frag_html_full() {
|
||||
@@ -15,10 +15,10 @@ 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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
package gplx.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
class Imap_html_fmtrs {
|
||||
public static final Bry_fmtr
|
||||
public class Imap_html_fmtrs {
|
||||
public static final Bry_fmtr
|
||||
All = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "<div id='imap_div_~{imap_id}' class=\"noresize\"~{desc_style}>~{map}~{img}"
|
||||
, " </div>"
|
||||
@@ -15,18 +15,20 @@ 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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
package gplx.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*; import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
class Imap_img_fmtr_arg implements gplx.core.brys.Bfr_arg {
|
||||
private Xoh_wtr_ctx hctx; private Imap_map map; private Imap_xtn_mgr xtn_mgr; // private byte[] src;
|
||||
private int img_elem_id, img_w, img_h;
|
||||
private byte[] img_alt, img_src, img_cls, img_href, lnki_ttl;
|
||||
private Int_2_ref margin_calc = new Int_2_ref();
|
||||
public void Init(Xoh_wtr_ctx hctx, Imap_xtn_mgr xtn_mgr, Imap_map map, byte[] src, int img_elem_id, byte[] img_alt, byte[] img_src, int img_w, int img_h, byte[] img_cls, byte[] img_href, byte[] lnki_ttl) {
|
||||
this.hctx = hctx; this.map = map; this.xtn_mgr = xtn_mgr; // this.src = src;
|
||||
import gplx.xowa.xtns.imaps.itms.*;
|
||||
public class Imap_img_arg implements gplx.core.brys.Bfr_arg {
|
||||
private final Xoh_wtr_ctx hctx; private final Imap_map map; private final Imap_xtn_mgr xtn_mgr;
|
||||
private final int img_elem_id, img_w, img_h;
|
||||
private final byte[] img_alt, img_src, img_cls, img_href, lnki_ttl;
|
||||
private final Int_2_ref margin_calc = new Int_2_ref();
|
||||
public Imap_img_arg(Xoh_wtr_ctx hctx, Imap_xtn_mgr xtn_mgr, Imap_map map
|
||||
, int img_elem_id, byte[] img_alt, byte[] img_src, int img_w, int img_h, byte[] img_cls, byte[] img_href, byte[] lnki_ttl) {
|
||||
this.hctx = hctx; this.map = map; this.xtn_mgr = xtn_mgr;
|
||||
this.img_elem_id = img_elem_id; this.img_w = img_w; this.img_h = img_h;
|
||||
this.img_alt = img_alt; this.img_src = img_src; this.img_cls = img_cls; this.img_href = img_href;
|
||||
this.lnki_ttl = lnki_ttl;
|
||||
@@ -34,31 +36,31 @@ class Imap_img_fmtr_arg implements gplx.core.brys.Bfr_arg {
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
Bry_fmtr fmtr = Imap_html_fmtrs.Img_anchor_none;
|
||||
byte[] anchor_href = Bry_.Empty, anchor_text = Bry_.Empty;
|
||||
Imap_itm_dflt itm_dflt = map.Dflt();
|
||||
Imap_part_dflt itm_dflt = map.Dflt();
|
||||
if (hctx.Mode_is_hdump()) {
|
||||
Bry_bfr tmp_bfr = xtn_mgr.Tmp_bfr;
|
||||
byte[] data_xowa_image = Xoh_file_html_fmtr__hdump.Bld_xowa_image_data(tmp_bfr, Xop_lnki_type.Id_none, img_w, img_h, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null, Xof_lnki_page.Null);
|
||||
byte[] data_xowa_title = Gfh_atr_.Make(tmp_bfr, Xoh_img_xoimg_data.Bry__data_xowa_title, lnki_ttl);
|
||||
byte[] usemap = tmp_bfr.Add(Imap_xtn_mgr.Bry__usemap__html).Add_int_variable(map.Id()).Add_byte_quote().To_bry_and_clear();
|
||||
Xoh_file_html_fmtr__hdump.Bld_anch_n(tmp_bfr, data_xowa_title, data_xowa_image, Xoh_img_cls_.Tid__thumbimage, Bry_.Empty, Bry_.Empty, usemap);
|
||||
bfr.Add_bfr_and_clear(tmp_bfr);
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.Get();
|
||||
try {
|
||||
byte[] data_xowa_image = Xoh_file_html_fmtr__hdump.Bld_xowa_image_data(tmp_bfr, Xop_lnki_type.Id_none, img_w, img_h, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null, Xof_lnki_page.Null);
|
||||
byte[] data_xowa_title = Gfh_atr_.Make(tmp_bfr, Xoh_img_xoimg_data.Bry__data_xowa_title, lnki_ttl);
|
||||
byte[] usemap = tmp_bfr.Add(Imap_xtn_mgr.Bry__usemap__html).Add_int_variable(map.Id()).Add_byte_quote().To_bry_and_clear();
|
||||
Xoh_file_html_fmtr__hdump.Bld_anch_n(tmp_bfr, data_xowa_title, data_xowa_image, Xoh_img_cls_.Tid__thumbimage, Bry_.Empty, Bry_.Empty, usemap);
|
||||
bfr.Add_byte_nl().Add_byte_repeat(Byte_ascii.Space, 6);
|
||||
bfr.Add_bfr_and_clear(tmp_bfr);
|
||||
} finally {tmp_bfr.Mkr_rls();}
|
||||
}
|
||||
else {
|
||||
Xoh_arg_img_core img_core_fmtr = xtn_mgr.Img_core_fmtr;
|
||||
Xoh_arg_img_core img_core_fmtr = xtn_mgr.Img_core_arg();
|
||||
img_core_fmtr.Init(img_elem_id, img_src, img_w, img_h);
|
||||
if (itm_dflt != null) {
|
||||
// Xowe_wiki wiki = map.Xtn_mgr().Wiki();
|
||||
// if (src.length != 0) // imap update will pass 0 src
|
||||
// Imap_link_owner_.Write(itm_dflt, wiki.Appe(), wiki, hctx, src);
|
||||
fmtr = itm_dflt.Link_tid() == Xop_tkn_itm_.Tid_lnki ? Imap_html_fmtrs.Img_anchor_lnki : Imap_html_fmtrs.Img_anchor_lnke;
|
||||
anchor_href = itm_dflt.Link_href();
|
||||
anchor_text = itm_dflt.Link_text();
|
||||
}
|
||||
fmtr.Bld_bfr_many(bfr, map.Id(), img_elem_id, img_alt, img_core_fmtr, img_cls, anchor_href, anchor_text);
|
||||
}
|
||||
Imap_itm_desc itm_desc = map.Desc();
|
||||
Imap_part_desc itm_desc = map.Desc();
|
||||
if (itm_desc != null) {
|
||||
Imap_desc_tid.Calc_desc_margins(margin_calc, itm_desc.Desc_tid(), img_w, img_h);
|
||||
Imap_desc_tid.Calc_margins(margin_calc, itm_desc.Desc_tid(), img_w, img_h);
|
||||
Imap_html_fmtrs.Desc_main.Bld_bfr_many(bfr, margin_calc.Val_0(), margin_calc.Val_1(), img_href, xtn_mgr.Desc_msg(), xtn_mgr.Desc_icon_url());
|
||||
}
|
||||
}
|
||||
31
400_xowa/src/gplx/xowa/xtns/imaps/htmls/Imap_map_arg.java
Normal file
31
400_xowa/src/gplx/xowa/xtns/imaps/htmls/Imap_map_arg.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
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.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.xtns.imaps.itms.*;
|
||||
public class Imap_map_arg implements gplx.core.brys.Bfr_arg {
|
||||
private final int imap_id;
|
||||
private final Imap_shapes_arg shapes_arg;
|
||||
public Imap_map_arg(int imap_id, Imap_part_shape[] shapes, double scale) {
|
||||
this.imap_id = imap_id;
|
||||
this.shapes_arg = new Imap_shapes_arg(shapes, scale);
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
Imap_html_fmtrs.Map.Bld_bfr_many(bfr, imap_id, shapes_arg);
|
||||
}
|
||||
}
|
||||
@@ -15,19 +15,21 @@ 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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
package gplx.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.core.primitives.*;
|
||||
class Imap_pts_fmtr_arg implements gplx.core.brys.Bfr_arg {
|
||||
private double scale = 1; private Double_obj_val[] pts;
|
||||
public void Scale_(double v) {this.scale = v;}
|
||||
public class Imap_shape_pts_arg implements gplx.core.brys.Bfr_arg {
|
||||
private final double scale; private Double_obj_val[] pts;
|
||||
public Imap_shape_pts_arg(double scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
public void Pts_(Double_obj_val[] v) {this.pts = v;}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
int pts_len = pts.length;
|
||||
for (int i = 0; i < pts_len; ++i) {
|
||||
Double_obj_val pt = pts[i];
|
||||
if (i != 0) bfr.Add_byte_comma();
|
||||
int pt_int = (int)pt.Val();
|
||||
pt_int = (int)Math_.Round(scale * pt_int, 0);
|
||||
if (i != 0) bfr.Add_byte_comma();
|
||||
bfr.Add_int_variable(pt_int);
|
||||
}
|
||||
}
|
||||
42
400_xowa/src/gplx/xowa/xtns/imaps/htmls/Imap_shapes_arg.java
Normal file
42
400_xowa/src/gplx/xowa/xtns/imaps/htmls/Imap_shapes_arg.java
Normal 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.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.xowa.xtns.imaps.itms.*; import gplx.core.brys.fmtrs.*;
|
||||
public class Imap_shapes_arg implements gplx.core.brys.Bfr_arg {
|
||||
private final Imap_part_shape[] shapes;
|
||||
private final Imap_shape_pts_arg pts_arg;
|
||||
public Imap_shapes_arg(Imap_part_shape[] shapes, double scale) {
|
||||
this.shapes = shapes;
|
||||
this.pts_arg = new Imap_shape_pts_arg(scale);
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
Bry_fmtr fmtr = Imap_html_fmtrs.Area;
|
||||
int len = shapes.length;
|
||||
for (int i = 0; i < len; ++i)
|
||||
Fmt_shape(bfr, fmtr, pts_arg, shapes[i]);
|
||||
}
|
||||
public static void Fmt_shape(Bry_bfr bfr, Bry_fmtr fmtr, Imap_shape_pts_arg pts_arg, Imap_part_shape shape) {
|
||||
pts_arg.Pts_(shape.Shape_pts());
|
||||
fmtr.Bld_bfr_many(bfr
|
||||
, shape.Link_href()
|
||||
, Imap_part_.To_shape_key(shape.Part_tid())
|
||||
, pts_arg
|
||||
, shape.Link_text()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -15,19 +15,19 @@ 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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import org.junit.*;
|
||||
public class Imap_xnde_html_itm_tst {
|
||||
@Before public void init() {fxt.Reset();} private Imap_html_bldr_fxt fxt = new Imap_html_bldr_fxt();
|
||||
package gplx.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import org.junit.*; import gplx.xowa.xtns.imaps.itms.*;
|
||||
public class Imap_shapes_arg_tst {
|
||||
@Before public void init() {fxt.Reset();} private Imap_shapes_arg_fxt fxt = new Imap_shapes_arg_fxt();
|
||||
@Test public void Rect() {fxt.Test_shape_html(fxt.itm_rect_("[[A|b]]", 1, 2, 3, 4), "\n <area href=\"/wiki/A\" shape=\"rect\" coords=\"1,2,3,4\" alt=\"b\" title=\"b\"/>");}
|
||||
@Test public void Circle() {fxt.Test_shape_html(fxt.itm_circle_("[[A|b]]", 1, 2, 3 ), "\n <area href=\"/wiki/A\" shape=\"circle\" coords=\"1,2,3\" alt=\"b\" title=\"b\"/>");}
|
||||
@Test public void Poly() {fxt.Test_shape_html(fxt.itm_poly_("[[A|b]]", 1, 2, 3, 4), "\n <area href=\"/wiki/A\" shape=\"poly\" coords=\"1,2,3,4\" alt=\"b\" title=\"b\"/>");}
|
||||
}
|
||||
class Imap_html_bldr_fxt extends Imap_fxt_base {
|
||||
private Bry_bfr bfr = Bry_bfr.new_();
|
||||
private Imap_pts_fmtr_arg pts_fmtr_arg = new Imap_pts_fmtr_arg();
|
||||
public void Test_shape_html(Imap_itm_shape shape, String expd) {
|
||||
Imap_shapes_fmtr.Fmt_shape(bfr, Imap_html_fmtrs.Area, pts_fmtr_arg, shape);
|
||||
class Imap_shapes_arg_fxt extends Imap_base_fxt {
|
||||
public void Test_shape_html(Imap_part_shape shape, String expd) {
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Imap_shape_pts_arg pts_fmtr_arg = new Imap_shape_pts_arg(1);
|
||||
Imap_shapes_arg.Fmt_shape(bfr, Imap_html_fmtrs.Area, pts_fmtr_arg, shape);
|
||||
Tfds.Eq(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -15,26 +15,42 @@ 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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
package gplx.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
class Imap_desc_tid {
|
||||
public class Imap_desc_tid {
|
||||
public static final byte Tid_tr = 0, Tid_br = 1, Tid_bl = 2, Tid_tl = 3, Tid_none = 4, Tid_null = 5;
|
||||
public static final byte[]
|
||||
public static final byte[]
|
||||
Key_tr = Bry_.new_a7("top-right")
|
||||
, Key_br = Bry_.new_a7("bottom-right")
|
||||
, Key_bl = Bry_.new_a7("bottom-left")
|
||||
, Key_tl = Bry_.new_a7("top-left")
|
||||
, Key_none = Bry_.new_a7("none")
|
||||
;
|
||||
public static Btrie_slim_mgr trie_(Xowe_wiki wiki) {
|
||||
|
||||
public static byte Parse_to_tid(Btrie_slim_mgr trie, byte[] src, int bgn, int end) {
|
||||
Object rv = trie.Match_bgn(src, bgn, end);
|
||||
return rv == null ? Tid_null : ((Byte_obj_val)rv).Val();
|
||||
}
|
||||
public static void Calc_margins(Int_2_ref rv, byte tid, int html_w, int html_h) {
|
||||
int margin_l
|
||||
= tid == Tid_tl || tid == Tid_bl
|
||||
? 0
|
||||
: html_w - 20;
|
||||
int margin_t
|
||||
= tid == Tid_tl || tid == Tid_tr
|
||||
? -html_h + 1 // 1px hack for IE, to stop it poking out the top
|
||||
: -20;
|
||||
rv.Val_all_(margin_l, margin_t);
|
||||
}
|
||||
public static Btrie_slim_mgr New_trie(Xowe_wiki wiki) {
|
||||
Btrie_slim_mgr rv = Btrie_slim_mgr.ci_u8();
|
||||
trie_add(rv, Key_tr, Key_br, Key_bl, Key_tl, Key_none);
|
||||
Add_to_trie(rv, Key_tr, Key_br, Key_bl, Key_tl, Key_none);
|
||||
byte[][] lang_types = Parse_lang_types(wiki);
|
||||
if (lang_types != null)
|
||||
trie_add(rv, lang_types);
|
||||
Add_to_trie(rv, lang_types);
|
||||
return rv;
|
||||
}
|
||||
private static void trie_add(Btrie_slim_mgr trie, byte[]... ary) {
|
||||
private static void Add_to_trie(Btrie_slim_mgr trie, byte[]... ary) {
|
||||
trie.Add_bry_byte(ary[0] ,Tid_tr);
|
||||
trie.Add_bry_byte(ary[1] ,Tid_br);
|
||||
trie.Add_bry_byte(ary[2] ,Tid_bl);
|
||||
@@ -44,28 +60,11 @@ class Imap_desc_tid {
|
||||
private static byte[][] Parse_lang_types(Xowe_wiki wiki) {
|
||||
byte[] val = wiki.Msg_mgr().Val_by_key_obj("imagemap_desc_types");
|
||||
if (Bry_.Len_eq_0(val)) return null; // no msg in lang; return;
|
||||
byte[][] ary = Bry_split_.Split(val, Byte_ascii.Comma); // msg is 5 words concatenated by comma: EX:top-right,bottom-right-bottom-left,top-left,none
|
||||
byte[][] ary = Bry_split_.Split(val, Byte_ascii.Comma); // msg is 5 words concatenated by comma: EX:top-right,bottom-right-bottom-left,top-left,none
|
||||
int ary_len = ary.length;
|
||||
if (ary_len != 5) wiki.Appe().Usr_dlg().Warn_many("", "", "imap_desc does not have 5 items; wiki=~{0} val=~{1}", wiki.Domain_bry(), val);
|
||||
for (int i = 0; i < 5; ++i)
|
||||
ary[i] = Bry_.Trim(ary[i]); // note that items will have trailing ws; EX: "top-right, bottom-right, bottom-left, top-left, none"
|
||||
return ary;
|
||||
}
|
||||
public static byte parse(Btrie_slim_mgr trie, byte[] src, int bgn, int end) {
|
||||
Object rv = trie.Match_bgn(src, bgn, end);
|
||||
return rv == null ? Tid_null : ((Byte_obj_val)rv).Val();
|
||||
}
|
||||
public static void Calc_desc_margins(Int_2_ref rv, byte tid, int html_w, int html_h) {
|
||||
int margin_l
|
||||
= tid == Tid_tl || tid == Tid_bl
|
||||
? 0
|
||||
: html_w - 20
|
||||
;
|
||||
int margin_t
|
||||
= tid == Tid_tl || tid == Tid_tr
|
||||
? -html_h + 1 // 1px hack for IE, to stop it poking out the top
|
||||
: -20
|
||||
;
|
||||
rv.Val_all_(margin_l, margin_t);
|
||||
}
|
||||
}
|
||||
23
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_err.java
Normal file
23
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_err.java
Normal 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.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
public class Imap_err {
|
||||
public Imap_err(int itm_idx, String err_msg) {this.itm_idx = itm_idx; this.err_msg = err_msg;}
|
||||
public int Itm_idx() {return itm_idx;} private final int itm_idx;
|
||||
public String Err_msg() {return err_msg;} private final String err_msg;
|
||||
}
|
||||
25
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_link_owner.java
Normal file
25
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_link_owner.java
Normal 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.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
public interface Imap_link_owner {
|
||||
int Link_tid(); void Link_tid_(int v, Xop_tkn_itm tkn);
|
||||
Xop_tkn_itm Link_tkn();
|
||||
void Link_href_(byte[] v);
|
||||
void Link_text_(byte[] v);
|
||||
}
|
||||
@@ -15,18 +15,11 @@ 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.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
package gplx.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.lnkes.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.lnkes.*;
|
||||
interface Imap_link_owner {
|
||||
int Link_tid();
|
||||
Xop_tkn_itm Link_tkn();
|
||||
void Link_tid_(int v, Xop_tkn_itm tkn);
|
||||
void Link_href_(byte[] v);
|
||||
void Link_text_(byte[] v);
|
||||
}
|
||||
class Imap_link_owner_ {
|
||||
public class Imap_link_owner_ {
|
||||
public static void Init(Imap_link_owner link_owner, Xoae_app app, Xowe_wiki wiki, byte[] src, Xop_tkn_itm tkn) {
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
try {
|
||||
@@ -82,17 +75,3 @@ class Imap_link_owner_ {
|
||||
finally {bfr.Mkr_rls();} // release buffer in case of null error; PAGE:de.u:PPA/Raster/TK25/51/18/12/20; DATE:2015-02-02
|
||||
}
|
||||
}
|
||||
class Imap_itm_shape implements Imap_itm, Imap_link_owner {
|
||||
public Imap_itm_shape(byte shape_tid, Double_obj_val[] shape_pts) {
|
||||
this.shape_tid = shape_tid;
|
||||
this.shape_pts = shape_pts;
|
||||
}
|
||||
public byte Itm_tid() {return shape_tid;} private byte shape_tid;
|
||||
public Double_obj_val[] Shape_pts() {return shape_pts;} private Double_obj_val[] shape_pts;
|
||||
public int Link_tid() {return link_tid;} private int link_tid;
|
||||
public Xop_tkn_itm Link_tkn() {return link_tkn;} private Xop_tkn_itm link_tkn;
|
||||
public void Link_tid_(int tid, Xop_tkn_itm tkn) {link_tid = tid; link_tkn = tkn;}
|
||||
public byte[] Link_href() {return link_href;} public void Link_href_(byte[] v) {this.link_href = v;} private byte[] link_href;
|
||||
public byte[] Link_text() {return link_text;} public void Link_text_(byte[] v) {this.link_text = v;} private byte[] link_text;
|
||||
public static final byte Tid_default = 0, Tid_rect = 4, Tid_circle = 3, Tid_poly = 5;
|
||||
}
|
||||
21
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_part.java
Normal file
21
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_part.java
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
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.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
public interface Imap_part {
|
||||
byte Part_tid();
|
||||
}
|
||||
45
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_part_.java
Normal file
45
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_part_.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
public class Imap_part_ {
|
||||
public static final byte
|
||||
Tid_invalid = 0
|
||||
, Tid_img = 1
|
||||
, Tid_desc = 2
|
||||
, Tid_comment = 3
|
||||
, Tid_dflt = 4
|
||||
, Tid_shape_rect = 5
|
||||
, Tid_shape_circle = 6
|
||||
, Tid_shape_poly = 7
|
||||
;
|
||||
public static final byte[]
|
||||
Key_dflt = Bry_.new_a7("default")
|
||||
, Key_shape_rect = Bry_.new_a7("rect")
|
||||
, Key_shape_circle = Bry_.new_a7("circle")
|
||||
, Key_shape_poly = Bry_.new_a7("poly")
|
||||
;
|
||||
|
||||
public static byte[] To_shape_key(byte v) {
|
||||
switch (v) {
|
||||
case Tid_shape_rect : return Key_shape_rect;
|
||||
case Tid_shape_circle : return Key_shape_circle;
|
||||
case Tid_shape_poly : return Key_shape_poly;
|
||||
default : throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
23
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_part_desc.java
Normal file
23
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_part_desc.java
Normal 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.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
public class Imap_part_desc implements Imap_part {
|
||||
public Imap_part_desc(byte desc_tid) {this.desc_tid = desc_tid;}
|
||||
public byte Part_tid() {return Imap_part_.Tid_desc;}
|
||||
public byte Desc_tid() {return desc_tid;} private final byte desc_tid;
|
||||
}
|
||||
26
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_part_dflt.java
Normal file
26
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_part_dflt.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
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.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
public class Imap_part_dflt implements Imap_part, Imap_link_owner {
|
||||
public byte Part_tid() {return Imap_part_.Tid_dflt;}
|
||||
public Xop_tkn_itm Link_tkn() {return link_tkn;} private Xop_tkn_itm link_tkn;
|
||||
public int Link_tid() {return link_tid;} private int link_tid; public void Link_tid_(int tid, Xop_tkn_itm tkn) {link_tid = tid; link_tkn = tkn;}
|
||||
public byte[] Link_href() {return link_href;} private byte[] link_href; public void Link_href_(byte[] v) {this.link_href = v;}
|
||||
public byte[] Link_text() {return link_text;} private byte[] link_text; public void Link_text_(byte[] v) {this.link_text = v;}
|
||||
}
|
||||
24
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_part_img.java
Normal file
24
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_part_img.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
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.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.xowa.parsers.lnkis.*;
|
||||
public class Imap_part_img implements Imap_part {
|
||||
public Imap_part_img(Xop_lnki_tkn img_link) {this.img_link = img_link;}
|
||||
public byte Part_tid() {return Imap_part_.Tid_img;}
|
||||
public Xop_lnki_tkn Img_link() {return img_link;} private final Xop_lnki_tkn img_link;
|
||||
}
|
||||
34
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_part_shape.java
Normal file
34
400_xowa/src/gplx/xowa/xtns/imaps/itms/Imap_part_shape.java
Normal 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.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
public class Imap_part_shape implements Imap_part, Imap_link_owner {
|
||||
public Imap_part_shape(byte shape_tid, Double_obj_val[] shape_pts) {
|
||||
this.shape_tid = shape_tid;
|
||||
this.shape_pts = shape_pts;
|
||||
}
|
||||
public byte Part_tid() {return shape_tid;} private final byte shape_tid;
|
||||
public Double_obj_val[] Shape_pts() {return shape_pts;} private final Double_obj_val[] shape_pts;
|
||||
public int Link_tid() {return link_tid;} private int link_tid;
|
||||
public Xop_tkn_itm Link_tkn() {return link_tkn;} private Xop_tkn_itm link_tkn; public void Link_tid_(int tid, Xop_tkn_itm tkn) {link_tid = tid; link_tkn = tkn;}
|
||||
public byte[] Link_href() {return link_href;} private byte[] link_href; public void Link_href_(byte[] v) {this.link_href = v;}
|
||||
public byte[] Link_text() {return link_text;} private byte[] link_text; public void Link_text_(byte[] v) {this.link_text = v;}
|
||||
|
||||
public static final byte Tid_default = 0, Tid_rect = 4, Tid_circle = 3, Tid_poly = 5;
|
||||
}
|
||||
Reference in New Issue
Block a user