本文整理匯總了Java中org.luaj.vm2.LuaValue.optint方法的典型用法代碼示例。如果您正苦於以下問題:Java LuaValue.optint方法的具體用法?Java LuaValue.optint怎麽用?Java LuaValue.optint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.luaj.vm2.LuaValue
的用法示例。
在下文中一共展示了LuaValue.optint方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setPaintTextAlign
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* set Paint text Align
*
* @param value
*/
private void setPaintTextAlign(LuaValue value) {
Paint paint = getDefaultPaint(null);
if (paint != null) {
final int align = value.optint(1);
switch (align) {
case 0:
case UDTextAlign.LEFT:
paint.setTextAlign(Paint.Align.LEFT);
break;
case 2:
case UDTextAlign.RIGHT:
paint.setTextAlign(Paint.Align.RIGHT);
break;
case 1:
case UDTextAlign.CENTER:
default:
paint.setTextAlign(Paint.Align.CENTER);
break;
}
}
}
示例2: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue arg1, LuaValue arg2) {
throw new LuaError(arg1.isnil() ? null : arg1.tojstring(), arg2.optint(1));
}
示例3: initSpannableStringBuilder
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
private void initSpannableStringBuilder(LuaValue text, LuaValue config) {
SpannableStringBuilder spannableStringBuilder = getSpannableStringBuilder();
if (text != null && text.isstring()) {
spannableStringBuilder = spannableStringBuilder.append(text.tojstring());
}
if (spannableStringBuilder.length() > 0) {
if (config != null && config.istable()) {
final int end = spannableStringBuilder.length();
final int fontSize = DimenUtil.spToPx(config.get("fontSize").optint(-1));
final Integer fontColor = ColorUtil.parse(LuaUtil.getValue(config, "fontColor"));
final String fontName = config.get("fontName").optjstring(null);
final LuaValue weightValue = config.get("fontWeight");
final int fontWeight = LuaUtil.isNumber(weightValue) ? weightValue.optint(UDFontWeight.WEIGHT_NORMAL_INT) : UDFontWeight.getValue(weightValue.optjstring(UDFontWeight.WEIGHT_NORMAL));
final LuaValue styleValue = config.get("fontStyle");
final int fontStyle = LuaUtil.isNumber(styleValue) ? styleValue.optint(Typeface.NORMAL) : UDFontStyle.getValue(styleValue.optjstring(UDFontStyle.STYLE_NORMAL));
final Integer backgroundColor = ColorUtil.parse(LuaUtil.getValue(config, "backgroundColor"));
final boolean strikethrough = config.get("strikethrough").optboolean(false);
final boolean underline = config.get("underline").optboolean(false);
if (fontSize != -1) {//字體大小
spannableStringBuilder.setSpan(new AbsoluteSizeSpan(fontSize), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (fontColor != null) {//字體顏色
spannableStringBuilder.setSpan(new ForegroundColorSpan(fontColor), 0, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (fontName != null && getLuaResourceFinder() != null) {//字體
spannableStringBuilder.setSpan(new CustomTypefaceSpan(fontName, getLuaResourceFinder().findTypeface(fontName)), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (fontWeight != -1 && fontWeight > UDFontWeight.WEIGHT_NORMAL_INT) {//文字Weight
spannableStringBuilder.setSpan(new WeightStyleSpan(fontWeight), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (fontStyle != -1 && (fontStyle >= Typeface.NORMAL && fontStyle <= Typeface.BOLD_ITALIC)) {//文字樣式
spannableStringBuilder.setSpan(new StyleSpan(fontStyle), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (backgroundColor != null) {//背景色
spannableStringBuilder.setSpan(new BackgroundColorSpan(backgroundColor), 0, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (strikethrough) {//刪除線
spannableStringBuilder.setSpan(new StrikethroughSpan(), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (underline) {//下劃線
spannableStringBuilder.setSpan(new UnderlineSpan(), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
}
}
示例4: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue arg1, LuaValue arg2) {
throw arg1.isnil() ? new LuaError(null, arg2.optint(1)) : arg1.isstring() ? new
LuaError(arg1.tojstring(), arg2.optint(1)) : new LuaError(arg1);
}
示例5: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue arg1, LuaValue arg2) {
throw arg1.isnil()? new LuaError(null, arg2.optint(1)):
arg1.isstring()? new LuaError(arg1.tojstring(), arg2.optint(1)):
new LuaError(arg1);
}
示例6: toJavaInt
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* java 從 0 開始
*
* @param pos
* @return
*/
public static int toJavaInt(LuaValue pos) {
return pos.optint(1) - 1;
}