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-04-19 12:33:25 -04:00
parent 551120b906
commit 299e19d455
74 changed files with 1267 additions and 719 deletions

View File

@@ -19,50 +19,47 @@ package gplx.xowa; import gplx.*;
public class Xop_lnki_type {
public static final byte Id_null = 0, Id_none = 1, Id_frameless = 2, Id_frame = 4, Id_thumb = 8;
public static boolean Id_is_thumbable(byte id) {
switch (id) {
case Id_thumb: case Id_frame: // for purposes of displaying images on page, thumb and frame both create a thumb box
return true;
default:
return false;
}
return ( Enm_.HasInt(id, Id_thumb) // for purposes of displaying images on page, thumb and frame both create a thumb box
|| Enm_.HasInt(id, Id_frame)
);
}
public static boolean Id_defaults_to_thumb(byte id) {
switch (id) { // assuming original of 400,200
case Id_thumb: // [[File:A.png|thumb]] -> 220,-1
case Id_frameless: // [[File:A.png|frameless]] -> 220,-1
return true;
case Id_null: // [[File:A.png]] -> 400,200 (default to original size)
case Id_frame: // [[File:A.png|frame]] -> 400,200 (frame is always default size)
case Id_none: // TODO: deprecate
return false;
default: // TODO: deprecate
return Enm_.HasInt(id, Xop_lnki_type.Id_thumb) || Enm_.HasInt(id, Xop_lnki_type.Id_frameless);
}
public static boolean Id_defaults_to_thumb(byte id) { // assuming original of 400,200
if ( Enm_.HasInt(id, Id_thumb) // [[File:A.png|thumb]] -> 220,-1
|| Enm_.HasInt(id, Id_frameless) // [[File:A.png|frameless]] -> 220,-1
)
return true;
else if ( Enm_.HasInt(id, Id_frame) // [[File:A.png|frame]] -> 400,200 (frame is always default size)
|| id == Id_null // [[File:A.png]] -> 400,200 (default to original size)
|| Enm_.HasInt(id, Id_none) // TODO: deprecate
)
return false;
else // TODO: throw err; should not happen
return false;
}
public static boolean Id_limits_large_size(byte id) {// Linker.php|makeThumbLink2|Do not present an image bigger than the source, for bitmap-style images
switch (id) { // assuming original of 400,200
case Id_thumb: // [[File:A.png|600px|thumb]] -> 400,200
case Id_frameless: // [[File:A.png|600px|frameless]] -> 400,200
case Id_frame: // [[File:A.png|600px|frame]] -> 400,200 (frame is always default size)
return true;
case Id_null: // [[File:A.png|600px]] -> 600,400; uses orig file of 400,200, but <img> tag src_width / src_height set to 600,400
case Id_none: // TODO: deprecate
return false;
default: // TODO: deprecate
return !Enm_.HasInt(id, Xop_lnki_type.Id_none);
}
public static boolean Id_limits_large_size(byte id) {// Linker.php|makeThumbLink2|Do not present an image bigger than the source, for bitmap-style images; assuming original of 400,200
if ( Enm_.HasInt(id, Id_thumb) // [[File:A.png|600px|thumb]] -> 400,200
|| Enm_.HasInt(id, Id_frameless) // [[File:A.png|600px|frameless]] -> 400,200
|| Enm_.HasInt(id, Id_frame) // [[File:A.png|600px|frame]] -> 400,200 (frame is always default size)
)
return true;
else if ( id == Id_null // [[File:A.png|600px]] -> 600,400; uses orig file of 400,200, but <img> tag src_width / src_height set to 600,400
|| Enm_.HasInt(id, Id_none) // TODO: deprecate
)
return false;
else // TODO: throw err; should not happen;
return true;
}
public static boolean Id_supports_upright(byte id) {// REF:Linker.php|makeImageLink;if ( isset( $fp['thumbnail'] ) || isset( $fp['manualthumb'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) DATE:2014-05-22
switch (id) {
case Id_thumb:
case Id_frame:
case Id_frameless:
return true;
case Id_null:
case Id_none:
if ( Enm_.HasInt(id, Id_thumb)
|| Enm_.HasInt(id, Id_frameless)
|| Enm_.HasInt(id, Id_frame)
)
return true;
else if ( id == Id_null
|| Enm_.HasInt(id, Id_none)
)
return false;
default: // TODO: deprecate
return Enm_.HasInt(id, Xop_lnki_type.Id_thumb) || Enm_.HasInt(id, Xop_lnki_type.Id_frameless);
}
else // TODO: throw err; should not happen;
return true;
}
}