List of usage examples for com.google.gwt.core.client JavaScriptObject createArray
public static native JavaScriptObject createArray() ;
From source file:org.sigmah.offline.js.UpdateProjectJS.java
License:Open Source License
public void setValues(List<ValueEventWrapper> values, UpdateProject updateProject) { if (values != null) { final JsArray<ValueJS> array = (JsArray<ValueJS>) JavaScriptObject.createArray(); for (final ValueEventWrapper value : values) { array.push(ValueJS.toJavaScript(updateProject, value)); }// w w w .j a v a 2s . c o m setValues(array); } }
From source file:org.sigmah.offline.js.ValueHistoryJS.java
License:Open Source License
public void setTokens(List<HistoryTokenListDTO> tokens) { if (tokens != null) { final JsArray<HistoryTokenListJS> array = (JsArray<HistoryTokenListJS>) JavaScriptObject.createArray(); for (final HistoryTokenListDTO token : tokens) { array.push(HistoryTokenListJS.toJavaScript(token)); }/*from ww w . ja v a2 s. c o m*/ setTokens(array); } }
From source file:org.sigmah.offline.js.ValueJS.java
License:Open Source License
public void update(ValueEventWrapper valueEventWrapper) { setValue(valueEventWrapper.getSingleValue()); if (valueEventWrapper.getListValue() instanceof ListableValue) { JsArray<ListableValueJS> values = getValues(); if (values == null) { values = (JsArray<ListableValueJS>) JavaScriptObject.createArray(); setValues(values);/*w ww. ja v a 2 s . c om*/ } switch (valueEventWrapper.getChangeType()) { case ADD: values.push(ListableValueJS.toJavaScript(valueEventWrapper.getListValue())); break; case REMOVE: final JsArray<ListableValueJS> trimmedArray = (JsArray<ListableValueJS>) JavaScriptObject .createArray(); for (int index = 0; index < values.length(); index++) { final ListableValueJS entry = values.get(index); if (entry.getId() != valueEventWrapper.getListValue().getId()) { trimmedArray.push(entry); } else { Log.info("Removing entry " + entry.getId() + " from " + getId()); } } setValues(trimmedArray); break; default: break; } } }
From source file:org.talend.mdm.webapp.welcomeportal.client.widget.DataChart.java
License:Open Source License
@Override protected void furtherInitPlot() { PlotModel model = plot.getModel();//from ww w. ja v a 2 s. c om PlotOptions plotOptions = plot.getOptions(); plotOptions.setGlobalSeriesOptions(GlobalSeriesOptions.create() .setPieSeriesOptions(PieSeriesOptions.create().setShow(true).setRadius(1).setInnerRadius(0.2) .setHighlight(Highlight.create().setOpacity(0.3)) .setLabel(com.googlecode.gflot.client.options.PieSeriesOptions.Label.create().setShow(true) .setRadius(3d / 4d).setBackground(Background.create().setOpacity(0.8)) .setThreshold(0.05).setFormatter(new Formatter() { @Override public String format(String label, Series series) { return "<div class='welcomePieChartLabel'>" //$NON-NLS-1$ + label + "<br/>" + formatter.format(series.getData().getY(0)) //$NON-NLS-1$ + " / " //$NON-NLS-1$ + formatter.format(percentageValueMap.get(label)) + "%</div>"; //$NON-NLS-1$ } })))); plotOptions.setLegendOptions(LegendOptions.create().setShow(false)); plotOptions.setGridOptions(GridOptions.create().setHoverable(true)); JsArrayString colors = JavaScriptObject.createArray().cast(); colors.push(SERIES_1_COLOR); colors.push(SERIES_2_COLOR); colors.push(SERIES_3_COLOR); colors.push(SERIES_4_COLOR); plotOptions.setDefaultColorTheme(colors); // create series and add data for (String entityName : entityNamesSorted) { SeriesHandler seriesEntity = model.addSeries(Series.of(entityName)); seriesEntity.add(DataPoint.of(entityName, (Integer) chartData.get(entityName))); } plot.addDomHandler(new MouseOutHandler() { @Override public void onMouseOut(MouseOutEvent event) { hoveringTXT = ""; //$NON-NLS-1$ entityName = ""; //$NON-NLS-1$ portal.setStyleAttribute("cursor", "default"); //$NON-NLS-1$//$NON-NLS-2$ } }, MouseOutEvent.getType()); plot.addDomHandler(new MouseMoveHandler() { @Override public void onMouseMove(MouseMoveEvent event) { cursorX = event.getClientX() + 10; cursorY = event.getClientY() - 10; } }, MouseMoveEvent.getType()); plot.addLoadHandler(new PlotLoadEvent.Handler() { @Override public void onLoad(PlotLoadEvent event) { // Flot has limitations on the pie labels // If it cannot be drawn it creates a div of class error with message // "Could not draw pie with labels contained inside canvas" // Workaround the issue by redrawing but without the labels boolean errorOccurred = plot.getParent().getElement().getInnerHTML() .contains("Could not draw pie with labels contained inside canvas"); //$NON-NLS-1$ if (errorOccurred) {// don't show labels if error occurred plot.getOptions().getGlobalSeriesOptions().getPieSeriesOptions().getLabel().setShow(false); plot.redraw(); } else {// reset to true for next creation plot.getOptions().getGlobalSeriesOptions().getPieSeriesOptions().getLabel().setShow(true); } } }); }
From source file:org.talend.mdm.webapp.welcomeportal.client.widget.options.AxeTicks.java
License:Open Source License
public static final AxeTicks create() { return JavaScriptObject.createArray().cast(); }
From source file:org.thechiselgroup.biomixer.client.visualization_component.matrix.NeoD3MatrixWidget.java
License:Apache License
public void updateView(HashSet<VisualItem> concepts, UnionResourceSet mappingResources) { /*-//from w w w.j a va 2 s.c o m * (Trick: this dash prevents code formatting from clobbering my layout below!) * (The @ formatter stuff I tried malfunctioned...) * * We need to convert our Java structures to json. * The D3 will want the concepts as "nodes" and the mappings as "links". * The links will have numerically addressed "source" and "target" each, * relative to the index of the nodes in question. * The data format expected by D3 is like below: * * { * "nodes":[ * {"name":"CHEBI_48961","group":0}, * {"name":"GO_0009493","group":1}, * {"name":"CHEBI_38553","group":0}, * {"name":"GO_0005489","group":1}, * {"name":"D000456","group":2}, * {"name":"Alga","group":4} * ], * "links":[ * {"source":0, "target":1, "value": 1}, * {"source":2, "target":3, "value": 1}, * {"source":120, "target":119, "value": 1}, * {"source":126, "target":125, "value": 1}, * {"source":94, "target":118, "value": 1} * ] * } * */ // Converting this is horrible. Part of the problem is that the links // use array indices rather than the string reference. // The other problem is that the links are separated from their nodes. // In the original RESTreturn values, the links are embedded in the // nodes, essentially. HashMap<String, Integer> conceptIndices = new HashMap<String, Integer>(); // Start of json // StringBuilderImpl jsonStrBuilder = new StringBuilderImpl(); // jsonStrBuilder.append("{"); JSONObject jsonObj = new JSONObject(); MatrixJsonData matrixJsonData = MatrixJsonData.createMatrixJsonData(); // jsonStrBuilder.append("\"nodes\":["); JSONArray jsonNodeArray = new JSONArray(); jsonObj.put("nodes", jsonNodeArray); JsArray<JavaScriptObject> jsNodeArray = JavaScriptObject.createArray().cast(); for (VisualItem visItem : concepts) { if (!(visItem.getDisplayObject() instanceof ConceptMatrixItem)) { // Remove when concepts are the only things coming through, not mappings continue; } ConceptMatrixItem displayObject = visItem.getDisplayObject(); // jsonStrBuilder.append("{\"name\":"+displayObject.getConceptFullId()+","); // jsonStrBuilder.append("\"group\":"+getGroupForOntology(displayObject.getOntologyId())); // jsonStrBuilder.append("},"); JSONObject nodeObject = new JSONObject(); nodeObject.put("name", new JSONString(displayObject.getLabel())); nodeObject.put("uri", new JSONString(displayObject.getConceptFullId())); nodeObject.put("group", new JSONNumber(getGroupForOntology(displayObject.getOntologyId()))); int index = jsonNodeArray.size(); jsonNodeArray.set(index, nodeObject); int addedIndex = matrixJsonData.pushNode(displayObject.getLabel(), displayObject.getConceptFullId(), getGroupForOntology(displayObject.getOntologyId())); assert (addedIndex == index); conceptIndices.put(visItem.getResources().getFirstElement().getUri(), index); } // jsonStrBuilder.append("], "); // jsonStrBuilder.append("\"links\":["); JSONArray jsonLinkArray = new JSONArray(); jsonObj.put("links", jsonLinkArray); for (Resource mappingResource : mappingResources) { assert Mapping.isMapping(mappingResource); String sourceUri = (String) mappingResource.getValue(Mapping.SOURCE_CONCEPT_URI); String targetUri = (String) mappingResource.getValue(Mapping.TARGET_CONCEPT_URI); JSONObject linkObject = new JSONObject(); linkObject.put("source", new JSONNumber(conceptIndices.get(sourceUri))); // new JSONString(sourceUri)); linkObject.put("target", new JSONNumber(conceptIndices.get(targetUri))); // new JSONString(targetUri)); linkObject.put("target", new JSONNumber(1)); jsonLinkArray.set(jsonLinkArray.size(), linkObject); int addedIndex = matrixJsonData.pushLink(conceptIndices.get(sourceUri), conceptIndices.get(targetUri), 1); // jsonStrBuilder.append("{"); // jsonStrBuilder.append("\"source\":"+sourceUri+","); // jsonStrBuilder.append("\"target\":"+targetUri+","); // jsonStrBuilder.append("\"value\":1"); // jsonStrBuilder.append("},"); } // jsonStrBuilder.append("]"); // End of json // jsonStrBuilder.append("}"); // matrixJsonData is preferable to jsonObj and to using a string builder. jsInterface.applyD3Layout(this.getElement(), matrixJSONContextObject, matrixJsonData); // jsonObj.toString()); // Old way // jsonStrBuilder.toString()); // Yet older way }
From source file:org.turbogwt.core.collections.JsArray.java
License:Apache License
@SuppressWarnings("unchecked") public static <T> JsArray<T> create() { return (JsArray<T>) JavaScriptObject.createArray(); }
From source file:org.turbogwt.core.collections.JsArrayList.java
License:Apache License
@SuppressWarnings("unchecked") public JsArrayList() { this.jsArray = (JsArray<T>) JavaScriptObject.createArray(); }
From source file:org.turbogwt.core.collections.JsArrayList.java
License:Apache License
@SuppressWarnings("unchecked") public JsArrayList(JsArray<T> jsArray) { this.jsArray = (JsArray<T>) (jsArray != null ? jsArray : JavaScriptObject.createArray()); }
From source file:org.turbogwt.core.collections.JsArrays.java
License:Apache License
public static JsArrayString fromArray(String... values) { if (GWT.isScript()) { return reinterpretCast(values); } else {/*from ww w .j a va2s . c o m*/ JsArrayString ret = JavaScriptObject.createArray().cast(); for (int i = 0, l = values.length; i < l; i++) { ret.set(i, values[i]); } return ret; } }