本文整理汇总了Java中org.luaj.vm2.LuaTable.get方法的典型用法代码示例。如果您正苦于以下问题:Java LuaTable.get方法的具体用法?Java LuaTable.get怎么用?Java LuaTable.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.luaj.vm2.LuaTable
的用法示例。
在下文中一共展示了LuaTable.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawLines
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawLines(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
final float pts[] = new float[keys.length * 4];
LuaValue value = null;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 4) {
for (int j = 0; j < 4; j++) {
pts[i * 4 + j] = DimenUtil.dpiToPx(value.get(j + 1));
}
}
}
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
canvas.drawLines(pts, getDefaultPaint(config));
}
}
}
}
示例2: clipRects
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void clipRects(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
LuaValue value = null;
float x1, y1, dx, dy;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 4) {
x1 = DimenUtil.dpiToPx(value.get(1));
y1 = DimenUtil.dpiToPx(value.get(2));
dx = DimenUtil.dpiToPx(value.get(3));
dy = DimenUtil.dpiToPx(value.get(4));
canvas.clipRect(x1, y1, x1 + dx, y1 + dy);
}
}
}
}
}
}
示例3: drawRects
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawRects(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
LuaValue value = null;
float x1, y1, dx, dy;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 4) {
x1 = DimenUtil.dpiToPx(value.get(1));
y1 = DimenUtil.dpiToPx(value.get(2));
dx = DimenUtil.dpiToPx(value.get(3));
dy = DimenUtil.dpiToPx(value.get(4));
canvas.drawRect(x1, y1, x1 + dx, y1 + dy, getDefaultPaint(LuaUtil.isTable(value.get(5)) ? value.get(5) : config));
}
}
}
}
}
}
示例4: drawPoints
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawPoints(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
final float pts[] = new float[keys.length * 2];
LuaValue value = null;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 2) {
for (int j = 0; j < 2; j++) {
pts[i * 2 + j] = DimenUtil.dpiToPx(value.get(j + 1));
}
}
}
canvas.drawPoints(pts, getDefaultPaint(config));
}
}
}
}
示例5: drawCircles
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawCircles(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
LuaValue value = null;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 3) {
canvas.drawCircle(DimenUtil.dpiToPx(value.get(1)),
DimenUtil.dpiToPx(value.get(2)),
DimenUtil.dpiToPx(value.get(3)),
getDefaultPaint(LuaUtil.isTable(value.get(4)) ? value.get(4) : config));
}
}
}
}
}
}
示例6: complexToJava
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public static void complexToJava(LuaValue l, Object o) {
try {
Field[] fields = o.getClass().getFields();
LuaTable table = l.checktable();
for (Field field : fields) {
if (!(Modifier.isPublic(field.getModifiers()) || field.isAnnotationPresent(LuaInclude.class)) || field.isAnnotationPresent(LuaExclude.class))
continue;
if (Modifier.isFinal(field.getModifiers())) continue;
String name = field.getName();
Class<?> type = field.getType();
LuaValue v = table.get(name);
Object instance = convertToJava(type, v);
field.set(o, instance);
}
} catch (Exception e) {
Log.warning(e);
}
}
示例7: onDestroyTable
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public static void onDestroyTable(LuaTable table) {
if (table != null) {
LuaValue isDestroy = table.get(KEY_DESTROY);
if (isDestroy == null || !LuaBoolean.TRUE.eq_b(isDestroy)) {
table.set(KEY_DESTROY, LuaBoolean.TRUE);//标志位
LuaValue value = null;
View view = null;
for (LuaValue key : table.keys()) {
value = table.get(key);
if (value instanceof UDView) {
view = ((UDView) value).getView();
if (view instanceof ViewGroup) {
clearViews((ViewGroup) view);
} else {
((UDView) value).onDestroy();
}
} else if (value instanceof BaseUserdata) {
((BaseUserdata) value).onDestroy();
} else if (value instanceof LuaTable) {
onDestroyTable((LuaTable) value);
}
}
}
}
}
示例8: toJSONObject
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public static JSONObject toJSONObject(LuaTable table) {
JSONObject obj = new JSONObject();
if (table != null) {
LuaValue[] keys = table.keys();
if (keys != null && keys.length > 0) {
try {
for (int i = 0; i < keys.length; i++) {
String key = keys[i].optjstring("");
LuaValue value = table.get(keys[i]);
if (value instanceof LuaTable) {
obj.put(key, toJSONObject((LuaTable) value));
} else {
obj.put(key, value);
}
}
} catch (JSONException e) {
LogUtil.e("[LuaView Error-toJSONObject]-Json Parse Failed, Reason: Invalid Format!", e);
}
}
}
return obj;
}
示例9: luaTableToMap
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
static Map<String, String> luaTableToMap(LuaTable value) {
Map<String, String> params = new HashMap<>();
LuaValue[] keys = value.keys();
for (LuaValue k : keys) {
if (k.isstring()) {
LuaValue v = value.get(k);
if (v.isstring()) {
params.put(k.tojstring(), v.tojstring());
}
}
}
return params;
}
示例10: complexToJava
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public static void complexToJava(LuaValue l, Object o) {
try {
Field[] fields = o.getClass().getFields();
LuaTable table = l.checktable();
for (Field field : fields) {
if (!(Modifier.isPublic(field.getModifiers()) || field.isAnnotationPresent(LuaInclude.class))
|| field.isAnnotationPresent(LuaExclude.class))
continue;
if (Modifier.isFinal(field.getModifiers()))
continue;
String name = field.getName();
Class<?> type = field.getType();
LuaValue v = table.get(name);
Object instance = convertToJava(type, v);
field.set(o, instance);
}
} catch (Exception e) {
Log.warning(e);
}
}
示例11: drawRoundRects
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawRoundRects(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
LuaValue value = null;
float x1, y1, dx, dy, x3, y3;
Paint paint = null;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 6) {
x1 = DimenUtil.dpiToPx(value.get(1));
y1 = DimenUtil.dpiToPx(value.get(2));
dx = DimenUtil.dpiToPx(value.get(3));
dy = DimenUtil.dpiToPx(value.get(4));
x3 = DimenUtil.dpiToPx(value.get(5));
y3 = DimenUtil.dpiToPx(value.get(6));
paint = getDefaultPaint(LuaUtil.isTable(value.get(7)) ? value.get(7) : config);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
canvas.drawRoundRect(x1, y1, x1 + dx, y1 + dy, x3, y3, paint);
} else {
drawRoundRectPlain(x1, y1, x1 + dx, y1 + dy, x3, y3, paint, canvas);
}
}
}
}
}
}
}
示例12: drawArcs
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawArcs(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
LuaValue value = null;
float x1, y1, dx, dy, x3, y3;
boolean use = false;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 7) {
x1 = DimenUtil.dpiToPx(value.get(1));
y1 = DimenUtil.dpiToPx(value.get(2));
dx = DimenUtil.dpiToPx(value.get(3));
dy = DimenUtil.dpiToPx(value.get(4));
x3 = (float) value.get(5).optdouble(0);
y3 = (float) value.get(6).optdouble(0);
use = value.get(7).optboolean(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
canvas.drawArc(x1, y1, x1 + dx, y1 + dy, x3, y3, use,
getDefaultPaint(LuaUtil.isTable(value.get(8)) ? value.get(8) : config));
} else {
final RectF rectF = mRectF;
rectF.left = x1;
rectF.top = y1;
rectF.right = x1 + dx;
rectF.bottom = y1 + dy;
canvas.drawArc(rectF, x3, y3, use, getDefaultPaint(config));
}
}
}
}
}
}
}
示例13: drawOvals
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawOvals(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
LuaValue value = null;
float x1, y1, dx, dy;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 4) {
x1 = DimenUtil.dpiToPx(value.get(1));
y1 = DimenUtil.dpiToPx(value.get(2));
dx = DimenUtil.dpiToPx(value.get(3));
dy = DimenUtil.dpiToPx(value.get(4));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
canvas.drawOval(x1, y1, x1 + dx, y1 + dy, getDefaultPaint(LuaUtil.isTable(value.get(5)) ? value.get(5) : config));
} else {
final RectF rectF = mRectF;
rectF.left = x1;
rectF.top = y1;
rectF.right = x1 + dx;
rectF.bottom = y1 + dy;
canvas.drawOval(rectF, getDefaultPaint(config));
}
}
}
}
}
}
}
示例14: toMap
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
/**
* convert a table to map
*
* @param table
* @return
*/
public static Map<String, String> toMap(LuaTable table) {
if (table != null) {
final Map<String, String> result = new HashMap<String, String>();
final LuaValue[] keys = table.keys();
LuaValue value = null;
for (LuaValue key : keys) {
value = table.get(key);
result.put(key.optjstring(null), value.optjstring(null));
}
}
return null;
}
示例15: call
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public LuaValue call( LuaValue arg ) {
LuaString name = arg.checkstring();
LuaValue loaded = package_.get(_LOADED);
LuaValue result = loaded.get(name);
if ( result.toboolean() ) {
if ( result == _SENTINEL )
error("loop or previous error loading module '"+name+"'");
return result;
}
/* else must load it; iterate over available loaders */
LuaTable tbl = package_.get(_SEARCHERS).checktable();
StringBuffer sb = new StringBuffer();
Varargs loader = null;
for ( int i=1; true; i++ ) {
LuaValue searcher = tbl.get(i);
if ( searcher.isnil() ) {
error( "module '"+name+"' not found: "+name+sb );
}
/* call loader with module name as argument */
loader = searcher.invoke(name);
if ( loader.isfunction(1) )
break;
if ( loader.isstring(1) )
sb.append( loader.tojstring(1) );
}
// load the module using the loader
loaded.set(name, _SENTINEL);
result = loader.arg1().call(name, loader.arg(2));
if ( ! result.isnil() )
loaded.set( name, result );
else if ( (result = loaded.get(name)) == _SENTINEL )
loaded.set( name, result = LuaValue.TRUE );
return result;
}