本文整理汇总了Java中com.eclipsesource.v8.V8Array类的典型用法代码示例。如果您正苦于以下问题:Java V8Array类的具体用法?Java V8Array怎么用?Java V8Array使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
V8Array类属于com.eclipsesource.v8包,在下文中一共展示了V8Array类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
@Override
public String execute(String dot) {
V8Array parameters = new V8Array(runtime).push(dot);
try {
runtime.executeVoidScript(JSMESSAGESARRAYSPLICE);
return (String) vizFunction.call(runtime, parameters);
} catch (Exception e) {
if (messages.length() > 0) {
// Now something really bad happened: viz.js tells us something
// with printing (e.g. Abort).
String summary = "";
for (int i = 0; i < messages.length(); i++) {
summary += V8ObjectUtils.getValue(messages, i) + "\n";
}
throw new VizJSException(summary, e);
}
throw new VizJSException("Problems executing function viz.js in engine: " + getVersion(), e);
} finally {
parameters.release();
}
}
示例2: arc
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
private void arc(V8Array parameter) {
float x = getFloat(parameter.getDouble(0)), y = getFloat(parameter.getDouble(1)),
r = getFloat(parameter.getDouble(2)), sAngle = getFloat(parameter.getDouble(3)),
eAngle = getFloat(parameter.getDouble(4));
boolean counterclockwise = parameter.getBoolean(5);
RectF rectF = new RectF(x - r, y - r, x + r, y + r);
//弧度与角度转换
sAngle = (float)(sAngle / Math.PI * 180);
eAngle = (float)(eAngle / Math.PI * 180);
if (counterclockwise) {
sAngle = -sAngle;
eAngle = -eAngle;
}
mPath.addArc(rectF, sAngle, eAngle - sAngle);
}
示例3: run
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
@Override
public void run() {
long start = System.currentTimeMillis();
V8 runtime = V8.createV8Runtime();
runtime.registerJavaMethod(new JavaVoidCallback() {
public void invoke(final V8Object receiver, final V8Array parameters) {
if (parameters.length() > 0) {
jcdemoString(parameters);
}
}
}, "call");
runtime.add("screenWidth", JustConfig.screenWidth);
runtime.add("screenHeight", JustConfig.screenHeight - JustConfig.navbarheight - JustConfig.statusbarheight);
runtime.executeScript(js);
long end = System.currentTimeMillis();
time = end - start;
handler.sendEmptyMessage(0);
}
示例4: getRuntime
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
public static V8 getRuntime() {
mRuntime = V8.createV8Runtime();
mRuntime.registerJavaMethod(new JavaVoidCallback() {
public void invoke(final V8Object receiver, final V8Array parameters) {
if (parameters.length() > 0) {
Object msg = parameters.get(0);
Log.d(LOG_TAG, msg.toString());
if (msg instanceof Releasable) {
((Releasable) msg).release();
}
}
}
}, "log");
mRuntime.add("screenWidth", JustConfig.screenWidth);
mRuntime.add("screenHeight", JustConfig.screenHeight - JustConfig.navbarheight - JustConfig.statusbarheight);
return mRuntime;
}
示例5: callMethod
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T> T callMethod(String name, Class<T> resultType, Object... args)
throws ScriptRunnerException {
Set<V8Value> newValues = new HashSet<>();
V8Array parameters = convertArguments(args, newValues);
try {
if (String.class.isAssignableFrom(resultType)) {
return (T)runtime.executeStringFunction(name, parameters);
}
return convert(runtime.executeObjectFunction(name, parameters), resultType);
} catch (V8RuntimeException e) {
throw new ScriptRunnerException("Could not call method", e);
} finally {
newValues.forEach(V8Value::release);
}
}
示例6: convertObject
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
/**
* Recursively convert a V8 object to a map and release it
* @param obj the object to convert
* @return the map
*/
private Map<String, Object> convertObject(V8Object obj) {
if (obj.isUndefined()) {
return null;
}
Map<String, Object> r = new LinkedHashMap<>();
for (String k : obj.getKeys()) {
Object o = obj.get(k);
if (o instanceof V8Array) {
o = convert((V8Array)o, List.class);
} else if (o instanceof V8Object) {
o = convert((V8Object)o, Map.class);
}
r.put(k, o);
}
return r;
}
示例7: invoke
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
public String invoke(Object... params) throws ScriptException, NoSuchMethodException, V8ScriptExecutionException {
V8Array transformParams = new V8Array(getInvocable());
for (Object param : params) {
transformParams.push(param);
}
return getInvocable().executeStringFunction(functionName(), transformParams);
}
示例8: jcdemo
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
private void jcdemo(V8Array parameters) {
V8Array calls = parameters.getArray(0);
int length = calls.length();
for (int i = 0; i < length; i++) {
jsdemo.call(calls.getObject(i));
}
justView.draw(jsdemo.getShapeList());
jsdemo.clearShapeList();
}
示例9: jcdemoString
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
private void jcdemoString(V8Array parameters) {
String[] calls = JCDemoString.splitBy(parameters.getString(0), parameters.getInteger(1), '&');
parameters.release();
for (String call: calls) {
jsdemoString.call(call);
}
justView.draw(jsdemoString.getShapeList());
jsdemoString.clearShapeList();
}
示例10: jcdemoJson
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
private void jcdemoJson(V8Array parameters) {
JustCall[] calls = JSON.parseObject(parameters.getString(0), JustCall[].class);
parameters.release();
for (JustCall call: calls) {
jsdemoJson.call(call);
}
justView.draw(jsdemoJson.getShapeList());
jsdemoJson.clearShapeList();
}
示例11: setLineDash
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
public void setLineDash(V8Array intervals) {
float[] floatIntervals = new float[intervals.length()];
for (int i = 0; i < intervals.length(); i++) {
floatIntervals[i] = (float)((double)intervals.getDouble(i));
}
PathEffect effects = new DashPathEffect(floatIntervals, 1);
mPaintStroke.setPathEffect(effects);
intervals.release();
}
示例12: initProcessExitCallback
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
private void initProcessExitCallback() {
JavaVoidCallback callbackProccessExit = new JavaVoidCallback() {
@Override
public void invoke(V8Object arg0, V8Array parameters) {
if (parameters.length() > 0) {
Object arg1 = parameters.get(0);
log.error("ProccessExit " + arg1);
// mV8rt.executeVoidScript("return \"\";");
}
}
};
mV8rt.registerJavaMethod(callbackProccessExit, "proccessExit");
mV8rt.executeVoidScript("var process = {\"exit\": function () { proccessExit(); } };");
}
示例13: initLogCallback
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
private void initLogCallback() {
JavaVoidCallback callbackLog = new JavaVoidCallback() {
@Override
public void invoke(V8Object arg0, V8Array parameters) {
if (parameters.length() > 0) {
Object arg1 = parameters.get(0);
log.debug("JSLOG " + arg1);
}
}
};
mV8rt.registerJavaMethod(callbackLog, "log");
mV8rt.executeVoidScript("var console = {\"log\":log, \"error\":log};");
}
示例14: getSanitizedHtml
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
/**
* Parses the supplied markdown into html.
* This calls the PageDown javascript library to do the work for us.
*/
public static String getSanitizedHtml(String markdown){
// System.out.println(new File(".").getAbsolutePath());
// for(String f : new File(".").list()){
// System.out.println("\t" + f);
// }
if(markdown == null){
return null;
}
try{
V8 runtime = V8.createV8Runtime();
runtime.executeScript( new String(Files.readAllBytes(Paths.get(PageDownUtils.class.getResource("Markdown.Converter.js").toURI()))));
runtime.executeScript( new String(Files.readAllBytes(Paths.get(PageDownUtils.class.getResource("Markdown.Sanitizer.js").toURI()))));
runtime.executeScript( new String(Files.readAllBytes(Paths.get(PageDownUtils.class.getResource("MarkdownParser.js").toURI()))));
V8Array args = new V8Array(runtime);
args.push(markdown);
String html = runtime.executeStringFunction("parseMarkdown", args);
args.release();
runtime.release();
return html;
}
catch(Exception e){
e.printStackTrace();
return "ERROR";
}
}
示例15: problems
import com.eclipsesource.v8.V8Array; //导入依赖的package包/类
private List<AssetProblem> problems(final Object value) {
if (value instanceof V8Array) {
return problems((V8Array) value);
}
V8Object hash = (V8Object) value;
if (hash.contains("errors")) {
return problems(register(hash.getArray("errors")));
}
if (hash.contains("message")) {
return ImmutableList.of(problem(hash));
}
return Collections.emptyList();
}