List of usage examples for com.google.gwt.core.client JsArray set
public final native void set(int index, T value) ;
From source file:com.emitrom.ti4j.mobile.client.ui.Gradient.java
License:Apache License
/** * Set the colors of this gradient using an array of colors with equal amount * offsets and colors.//from w w w .j a va 2 s. co m * @param colors The array of color strings * @param offsets The offsets */ public final void setColors(String[] colors, double[] offsets) { if (colors.length != offsets.length) { return; //Misfit between colors and offsets array length } @SuppressWarnings("unchecked") JsArray<JavaScriptObject> c = (JsArray<JavaScriptObject>) JavaScriptObject.createArray(); c.setLength(colors.length); for (int i = 0; i < colors.length; ++i) { JavaScriptObject newColor = createColorOffset(colors[i], offsets[i]); c.set(i, newColor); } setColors(c); }
From source file:com.google.gerrit.client.rpc.Natives.java
License:Apache License
public static <T extends JavaScriptObject> List<T> asList(final JsArray<T> arr) { if (arr == null) { return null; }//from ww w.j a v a 2s. c o m return new AbstractList<T>() { @Override public T set(int index, T element) { T old = arr.get(index); arr.set(index, element); return old; } @Override public T get(int index) { return arr.get(index); } @Override public int size() { return arr.length(); } }; }
From source file:com.googlecode.gwt.charts.client.ajaxloader.ArrayHelper.java
License:Apache License
public static <J extends JavaScriptObject> JsArray<J> toJsArray(J... objects) { JsArray<J> result = JsArray.createArray().cast(); for (int i = 0; i < objects.length; i++) { result.set(i, objects[i]); }// w w w.j a v a 2 s .co m nativePatchConstructorForSafari(result); return result; }
From source file:com.gwtmobile.persistence.client.Persistence.java
License:Apache License
@SuppressWarnings("unchecked") public static void dumpToJson(Transaction transaction, Entity<?>[] entities, ScalarCallback<String> callback) { JsArray<JavaScriptObject> entitiesArray = null; if (entities != null) { entitiesArray = (JsArray<JavaScriptObject>) JavaScriptObject.createArray(); for (int i = 0; i < entities.length; i++) { EntityInternal<?> entity = (EntityInternal<?>) entities[i]; entitiesArray.set(i, entity.getNativeObject()); }// ww w . j av a 2s. c o m } dumpToJsonNative(transaction, entitiesArray, callback); }
From source file:com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts.java
License:Apache License
private void updatePlotLines(GwtAxis chartAxis, GwtAxisBaseOptions chartAxisOptions, GwtAxisBaseOptions uidlAxisOptions) { VConsole.log("Enter [updatePlotLines]"); // Update chartAxisPlotBands whenever a plotline is added or removed as // the library // does not update chart options by itself. JsArray<GwtPlotLines> chartAxisPlotLines = chartAxisOptions.getPlotLines(); JsArray<GwtPlotLines> uidlAxisPlotLines = uidlAxisOptions.getPlotLines(); if (uidlAxisPlotLines == null && chartAxisPlotLines == null) { VConsole.log("No plotlines found."); VConsole.log("Exit [updatePlotLines]"); return;/* w ww.ja va 2s . c om*/ } if (uidlAxisPlotLines == null) { uidlAxisPlotLines = JavaScriptObject.createArray().cast(); } if (chartAxisPlotLines == null) { chartAxisPlotLines = JavaScriptObject.createArray().cast(); } JsArray<GwtPlotLines> updatedChartAxisPlotLines = JavaScriptObject.createArray().cast(); int numOfChartAxisPlotLines = chartAxisPlotLines.length(); int numOfUIDLAxisPlotLines = uidlAxisPlotLines.length(); boolean updatedAxisPlotLines = false; for (int indOuter = 0; indOuter < numOfChartAxisPlotLines; indOuter++) { GwtPlotLines chartPlotLine = chartAxisPlotLines.get(indOuter); String plotLineId = chartPlotLine.getId(); boolean found = false; for (int indInner = 0; indInner < numOfUIDLAxisPlotLines; indInner++) { GwtPlotLines uidlPlotLine = uidlAxisPlotLines.get(indInner); if (uidlPlotLine != null && uidlPlotLine.getId().equals(plotLineId)) { if (uidlPlotLine.getValue() == chartPlotLine.getValue()) { // PlotLine exists and value is same so no action should // be taken except marking UIDL PlotLine to null. // Setting UIDL PlotLine // to null ensures that remaining PlotLines in UIDL can // be added // safely to the chart. uidlAxisPlotLines.set(indInner, null); updatedChartAxisPlotLines.push(chartPlotLine); found = true; } break; } } if (!found) { // remove plot line as it is not found in UIDL received from the // server updatedAxisPlotLines = true; chartAxis.removePlotLine(plotLineId); } } // Add all remaining plot lines in UIDL to the chart for (int ind = 0; ind < numOfUIDLAxisPlotLines; ind++) { GwtPlotLines uidlPlotLine = uidlAxisPlotLines.get(ind); if (uidlPlotLine != null) { updatedAxisPlotLines = true; chartAxis.addPlotLine(uidlPlotLine); updatedChartAxisPlotLines.push(uidlPlotLine); } } // Update chart axis plotlines if (updatedAxisPlotLines) { setRedrawChart(); chartAxisOptions.setPlotLines(updatedChartAxisPlotLines); } VConsole.log("Exit [updatePlotLines]"); }
From source file:com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts.java
License:Apache License
private void updatePlotBands(GwtAxis chartAxis, GwtAxisBaseOptions chartAxisOptions, GwtAxisBaseOptions uidlAxisOptions) { VConsole.log("Enter [updatePlotBands]"); // Update chartAxisPlotBands whenever a plotband is added or removed as // the library // does not update chart options by itself. JsArray<GwtPlotBands> chartAxisPlotBands = chartAxisOptions.getPlotBands(); JsArray<GwtPlotBands> uidlAxisPlotBands = uidlAxisOptions.getPlotBands(); if (uidlAxisPlotBands == null && chartAxisPlotBands == null) { VConsole.log("No plotbands found."); VConsole.log("Exit [updatePlotBands]"); return;//from ww w.ja v a 2 s. c o m } if (uidlAxisPlotBands == null) { uidlAxisPlotBands = JavaScriptObject.createArray().cast(); } if (chartAxisPlotBands == null) { chartAxisPlotBands = JavaScriptObject.createArray().cast(); } JsArray<GwtPlotBands> updatedChartAxisPlotBands = JavaScriptObject.createArray().cast(); int numOfChartAxisPlotBands = chartAxisPlotBands.length(); int numOfUIDLAxisPlotBands = uidlAxisPlotBands.length(); boolean updatedAxisPlotBands = false; for (int indOuter = 0; indOuter < numOfChartAxisPlotBands; indOuter++) { GwtPlotBands chartPlotBand = chartAxisPlotBands.get(indOuter); String plotBandId = chartPlotBand.getId(); boolean found = false; for (int indInner = 0; indInner < numOfUIDLAxisPlotBands; indInner++) { GwtPlotBands uidlPlotBand = uidlAxisPlotBands.get(indInner); if (uidlPlotBand != null && uidlPlotBand.getId().equals(plotBandId)) { if (chartPlotBand.getFrom() == uidlPlotBand.getFrom() && chartPlotBand.getTo() == uidlPlotBand.getTo()) { VConsole.log("Plotband id " + plotBandId + " exists in chart as well as in UIDL from the server."); // PlotBand exists and from/to values are same so // nothing to be done. // The UIDL plotband is set to null so that remaining // plotbands // can be safely added to the chart uidlAxisPlotBands.set(indInner, null); updatedChartAxisPlotBands.push(chartPlotBand); VConsole.log("Plotband id " + plotBandId + " exists in both."); found = true; } break; } } if (!found) { // remove plot band as it is not found in UIDL received from the // server VConsole.log("Plotband id " + plotBandId + " removed."); updatedAxisPlotBands = true; chartAxis.removePlotBand(plotBandId); } } // Add all remaining plot bands in UIDL to the chart for (int ind = 0; ind < numOfUIDLAxisPlotBands; ind++) { GwtPlotBands uidlPlotBand = uidlAxisPlotBands.get(ind); if (uidlPlotBand != null) { updatedAxisPlotBands = true; VConsole.log("Plotband id " + uidlPlotBand.getId() + " added with from : " + uidlPlotBand.getFrom() + " and to: " + uidlPlotBand.getTo()); chartAxis.addPlotBand(uidlPlotBand); updatedChartAxisPlotBands.push(uidlPlotBand); } } // Update chart axis plotbands if (updatedAxisPlotBands) { setRedrawChart(); chartAxisOptions.setPlotBands(updatedChartAxisPlotBands); } VConsole.log("Exit [updatePlotBands]"); }
From source file:com.itgp.gwtviz.client.charts.nv.AbstractChartXYV1.java
License:Open Source License
public final void addXYSeries(XYSeriesV1 value) { if (value == null) { return;/*from w w w.j a v a 2s . c o m*/ } JsArray<XYSeriesV1> series = getXYSeries(); series.set(series.length(), value); }
From source file:com.itgp.gwtviz.client.charts.nv.PieChartV1.java
License:Open Source License
protected final void addLabelValueCoords(LabelValueCoordsV1 value) { if (value == null) { return;//from w w w.j a va 2 s. co m } JsArray<LabelValueCoordsV1> series = getLabelValueSeries(); series.set(series.length(), value); }
From source file:com.itgp.gwtviz.client.charts.nv.ScatterChartV1.java
License:Open Source License
public final void addSeries(ScatterSeriesV1 value) { if (value == null) { return;// ww w . j av a 2s .com } JsArray<ScatterSeriesV1> series = getScatterSeries(); series.set(series.length(), value); }
From source file:com.itgp.gwtviz.client.charts.nv.ScatterSeriesV1.java
License:Open Source License
public final void addPoint(Object x, double y, double size, Shape shape) { JsArray<ScatterCoordsV1> value = getValues(); ScatterCoordsV1 coords = null;/*from w w w. jav a 2 s. com*/ if (x instanceof Double) { coords = ScatterCoordsV1.create((Double) x, y, size, shape); } else { coords = ScatterCoordsV1.create(x.toString(), y, size, shape); } value.set(value.length(), coords); }