是否有方法或解决方法在KineticJs中返回文本形状中字符串的文本宽度?
我需要它在画布上准确定位TextShape.
使用Twitter4j提供的代码示例,我想在收集到1,000个状态列表后停止流,并返回此列表.我怎样才能做到这一点?
public class Stream {
public List<Status> execute throws TwitterException {
List<Status> statuses = new ArrayList();
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true);
cb.setOAuthConsumerKey("bbb");
cb.setOAuthConsumerSecret("bbb");
cb.setOAuthAccessToken("bbb");
cb.setOAuthAccessTokenSecret("bbb");
TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
StatusListener listener = new StatusListener() {
public void onStatus(Status status) {
statuses.add(status);
if (statuses.size>1000){
//return statuses. Obviously that's not the correct place for a return statement...
}
}
public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
System.out.println("Got a status deletion notice id:" + statusDeletionNotice.getStatusId());
}
public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
System.out.println("Got track …Run Code Online (Sandbox Code Playgroud) 真的卡在这里了。该代码是根据Google提供的示例构建的:
public static void main(String[] args) {
try {
HttpTransport httpTransport = new NetHttpTransport();
JsonFactory jsonFactory = new JacksonFactory();
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
httpTransport, jsonFactory, CLIENT_ID, CLIENT_SECRET, Arrays.asList(DriveScopes.DRIVE))
.setAccessType("online")
.setApprovalPrompt("auto")
.build();
String url = flow.newAuthorizationUrl().setRedirectUri(REDIRECT_URI).build();
System.out.println("Please open the following URL in your browser then type the authorization code:");
System.out.println(" " + url);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String code = br.readLine();
GoogleTokenResponse response = flow.newTokenRequest(code).setRedirectUri(REDIRECT_URI).execute();
GoogleCredential credential = new GoogleCredential().setFromTokenResponse(response);
//Create a new authorized API client
Drive service …Run Code Online (Sandbox Code Playgroud) 可能重复:
javax.servlet.ServletException:错误解析/page.xhtml:元素的内容必须包含格式良好的字符数据或标记
这是一个jsf 2.0项目.
xhtml文件:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Ring</title>
<h:outputScript library="js" name="jquery-1.8.1.min.js" />
<h:outputScript library="js" name="processing-1.4.1.js" />
<script type="text/javascript">
$(function(){
var pjs = Processing.getInstanceById("viz");
var json = #{TableMatchesBean.json};
var data = eval("("+json+")");
if(data) {
for(i=0; i<data.segments.length; i++) {
var segment = data.segments[i];
pjs.addSegment(segment.label, segment.count,segment.isMain);
}
}
}); //end ready
</script>
</h:head>
<h:body>
<canvas id ="viz" data-processing-sources="common.pde"></canvas>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
在javascript的for循环的第一行,
for(i=0; i<data.segments.length; i++) {
Run Code Online (Sandbox Code Playgroud)
Netbeans引发了这个错误:"致命错误:元素类型"data.segments.length"必须后跟属性规范,">"或"/>"."
此错误表明"<"被解释为某些xhtml,而不是js(我认为).这是Netbeans的错误还是js和xhtml之间确实存在混淆?
使用jsf 2和Primefaces 3.4
我知道有很多类似的问题,但没有一个在这个问题上有效.
当单击命令按钮后,panelGrid"inner"以固定值"true"(<h:panelGrid id="inner" rendered="true">)=> 呈现时,输入组件正确更新#{tableMatchesBean.mergedAuthorAjax}的值,
但是当此面板的呈现是有条件的时:<h:panelGrid rendered="#{spellCheckBean.renderInputMerge}">
=>然后输入组件是静默的(没有跟踪tableMatchesBean.mergedAuthorAjax已被调用).
注意:我使用嵌套的panelGrids将渲染条件放在需要有条件渲染的组件的父元素(输出和输入组件)中.任何帮助赞赏.
[评论后编辑:] xhtml页面的作用:
- 当用户点击selectOnebutton中的"merge"选项时,ajax更新会将"renderInputMerge"切换为true,从而导致显示"外部"组件.它工作正常.在此组件中,有一个输入字段,显示OK.
- 在用户单击commandLink按钮后,我需要检索此输入字段的值.如上所述,我有一个问题.
xhtml:
<h:body style ="width:100%">
<h:form id = "currMatch">
<h:panelGrid>
<p:selectOneButton id ="selection" value="#{spellCheckBean.optionChosen}">
<f:selectItem itemLabel="keep both" itemValue="1" />
<f:selectItem itemLabel="delete both" itemValue="2" />
<f:selectItem itemLabel="merge" itemValue="3" />
<p:ajax update="outer" />
</p:selectOneButton>
</h:panelGrid>
<h:panelGrid id="outer" >
<h:panelGrid id="inner" rendered="#{spellCheckBean.renderInputMerge}">
<!-- **the line above does not update**, this one does <h:panelGrid rendered="true">-->
<h:outputText …Run Code Online (Sandbox Code Playgroud) 我需要反复(成千上万次)从Collection包含数十万个对象的元素中检索一个元素(每次不同).
执行此检索操作的最快方法是什么?目前我Collection是一个List,我迭代它直到我找到了元素,但是有更快的方法吗?用一个Map?我在想:
Map,键是Object的id字段,Object本身是值.get(id)的Map应该比循环通过一个快得多List. HashMap或TreeMap? - 我的对象没有特别的顺序.任何有关此事的建议将不胜感激!
最后一点:如果外部库提供了一个工具来回答这个问题,我会很乐意接受它!
我想使用 Angular CLI 构建应用程序并通过 SSH 将其部署到我的远程服务器上。这个功能可用吗?
来自Java我非常喜欢Guava提供的丰富数据结构集合所提供的灵活性.在js或jquery中是否有"类似番石榴"的库?
注意:我听说关闭,看起来有点沉重 - 更简单?(或者真正关闭我需要的东西吗?)
注2:通过"丰富的数据结构集合",我的意思是排序的地图和集合,多图(允许重复的密钥)和多重集(允许多个条目的集合 - 看起来很奇怪,但实际上非常有用!)等.
在 Akka 2.2 中完成初学者,尝试修改版的Hello World。修改是我创建了 1000 个演员而不是一个。运行它,我没有得到所有的 1000 hello worlds 返回,这个错误跟踪,重复了几条消息:
[07/23/2013 22:22:45.924] [Main-akka.actor.default-dispatcher-2] [akka://Main/user/app/$Si] 消息 [net.clementlevallois.akkatest.Greeter$Msg ] 从 Actor[akka://Main/user/app#1478796310] 到 Actor[akka://Main/user/app/$Si#-1309206213] 未交付。1 死信遇到。可以使用配置设置“akka.log-dead-letters”和“akka.log-dead-letters-during-shutdown”关闭或调整此日志记录。
两个班级:
public class App extends UntypedActor {
@Override
public void preStart() {
// create the greeter actors
List<ActorRef> actorRefs = new ArrayList();
for (int i = 0; i < 1000; i++) {
final ActorRef greeter = getContext().actorOf(Props.create(Greeter.class, i));
this.getContext().watch(greeter);
actorRefs.add(greeter);
}
// tell it to perform the greeting
for (ActorRef actorRef : actorRefs) …Run Code Online (Sandbox Code Playgroud) Google Slides 的 GUI 提供将 GSlides 演示文稿下载为 Powerpoint (myFile.pptx)。我在 Google Apps Script 文档中找不到等效的东西 - 任何指针?
编辑
感谢评论和答案,我尝试了这个片段:
function testFileOps() {
// Converts the file named 'Synthese' (which happens to be a Google Slide doc) into a pptx
var files = DriveApp.getFilesByName('Synthese');
var rootFolder = DriveApp.getRootFolder();
while (files.hasNext()) {
var file = files.next();
var blobPptx = file.getBlob().getAs('application/vnd.openxmlformats-officedocument.presentationml.presentation');
var result = rootFolder.createFile(blobPptx);
}
}
Run Code Online (Sandbox Code Playgroud)
它返回一个错误:
不支持从 application/vnd.google-apps.presentation 转换为 application/vnd.openxmlformats-officedocument.presentationml.presentation。(第 7 行,文件“代码”)
第二次编辑
根据评论中的另一个建议,我尝试从 Google App Script 进行 http 调用,这会将幻灯片直接转换为 pptx,没有大小限制。它在 G Drive …
java ×4
javascript ×2
jsf ×2
akka ×1
angular ×1
canvas ×1
collections ×1
google-api ×1
guava ×1
jquery ×1
jsf-2 ×1
kineticjs ×1
netbeans ×1
optimization ×1
primefaces ×1
text-width ×1
twitter ×1
twitter4j ×1
xhtml ×1