List of usage examples for com.google.gwt.core.client JavaScriptObject createArray
public static native JavaScriptObject createArray() ;
From source file:com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts.java
License:Apache License
private JsArray<GwtPlotLines> getPlotLines(UIDL plotLinesUIDL) { JsArray<GwtPlotLines> plotLinesArr = JavaScriptObject.createArray().cast(); for (int cnt = 0; cnt < plotLinesUIDL.getChildCount(); cnt++) { UIDL plotLineUIDL = plotLinesUIDL.getChildUIDL(cnt); if (plotLineUIDL.getAttributeNames().size() == 0 && plotLineUIDL.getChildCount() == 0) { continue; }/* w ww. j av a 2s.co m*/ GwtPlotLines plotLines = GwtPlotLines.create(); if (plotLineUIDL.hasAttribute("color")) { plotLines.setColor(plotLineUIDL.getStringAttribute("color")); } if (plotLineUIDL.hasAttribute("dashStyle")) { plotLines.setDashStyle(plotLineUIDL.getStringAttribute("dashStyle")); } if (plotLineUIDL.hasAttribute("id")) { plotLines.setId(plotLineUIDL.getStringAttribute("id")); } if (plotLineUIDL.hasAttribute("width")) { plotLines.setWidth(plotLineUIDL.getIntAttribute("width")); } if (plotLineUIDL.hasAttribute("zIndex")) { plotLines.setZIndex(plotLineUIDL.getIntAttribute("zIndex")); } // label GwtPlotLabel label = getPlotLabel(plotLineUIDL.getChildUIDL(0)); if (label != null) { plotLines.setLabel(label); } // line value UIDL lineValueUIDL = plotLineUIDL.getChildUIDL(1); if (lineValueUIDL.hasAttribute("valueType")) { String valueType = lineValueUIDL.getStringAttribute("valueType"); if (valueType.equals("number")) { if (lineValueUIDL.hasAttribute("value")) { plotLines.setValue(lineValueUIDL.getDoubleAttribute("value")); } } else { // date int year = lineValueUIDL.getIntAttribute("year"); int month = lineValueUIDL.getIntAttribute("month"); int day = lineValueUIDL.getIntAttribute("day"); plotLines.setValue("Date.UTC(" + year + ", " + month + "," + day + ")"); } } // plotLinesArr.push(plotLines); } return plotLinesArr; }
From source file:com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts.java
License:Apache License
private JsArray<GwtXAxisOptions> getXAxisOptions(UIDL uidl) { VConsole.log("Enter [getXAxisOptions]"); VConsole.log("Tag Name : " + uidl.getTag()); JsArray<GwtXAxisOptions> xAxes = JavaScriptObject.createArray().cast(); for (int cnt = 0; cnt < uidl.getChildCount(); cnt++) { GwtXAxisOptions xAxisOptions = GwtXAxisOptions.create(); UIDL axisUIDL = uidl.getChildUIDL(cnt); if (axisUIDL.getAttributeNames().size() == 0 && axisUIDL.getChildCount() == 0) { continue; }/*w ww .jav a2 s . c o m*/ updateBaseAxisOptions(axisUIDL, xAxisOptions); UIDL childUIDL = axisUIDL.getChildUIDL(4); if (childUIDL != null) { if (childUIDL.getTag().equals("categories") && childUIDL.getChildCount() > 0) { JsArrayString categories = JavaScriptObject.createArray().cast(); UIDL categoriesUIDL = childUIDL; for (int idx = 0; idx < categoriesUIDL.getChildCount(); idx++) { categories.push(categoriesUIDL.getChildUIDL(idx).getStringAttribute("name")); } xAxisOptions.setCategories(categories); } else if (childUIDL.getTag().equals("dateTimeLabelFormats") && childUIDL.getAttributeNames().size() > 0) { UIDL dateTimeLblFmtsUIDL = childUIDL; GwtDateTimeLabelFormats formats = GwtDateTimeLabelFormats.create(); if (dateTimeLblFmtsUIDL.hasAttribute("millisecond")) { formats.setMillisecond(dateTimeLblFmtsUIDL.getStringAttribute("millisecond")); } if (dateTimeLblFmtsUIDL.hasAttribute("second")) { formats.setSecond(dateTimeLblFmtsUIDL.getStringAttribute("second")); } if (dateTimeLblFmtsUIDL.hasAttribute("minute")) { formats.setMinute(dateTimeLblFmtsUIDL.getStringAttribute("minute")); } if (dateTimeLblFmtsUIDL.hasAttribute("hour")) { formats.setHour(dateTimeLblFmtsUIDL.getStringAttribute("hour")); } if (dateTimeLblFmtsUIDL.hasAttribute("day")) { formats.setDay(dateTimeLblFmtsUIDL.getStringAttribute("day")); } if (dateTimeLblFmtsUIDL.hasAttribute("week")) { formats.setWeek(dateTimeLblFmtsUIDL.getStringAttribute("week")); } if (dateTimeLblFmtsUIDL.hasAttribute("month")) { formats.setMonth(dateTimeLblFmtsUIDL.getStringAttribute("month")); } if (dateTimeLblFmtsUIDL.hasAttribute("year")) { formats.setYear(dateTimeLblFmtsUIDL.getStringAttribute("year")); } xAxisOptions.setDateTimeLabelFormats(formats); } } xAxes.push(xAxisOptions); } VConsole.log("Exit [getXAxisOptions]"); return xAxes; }
From source file:com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts.java
License:Apache License
private JsArray<GwtYAxisOptions> getYAxisOptions(UIDL uidl) { VConsole.log("Enter [getYAxisOptions]"); VConsole.log("Tag Name : " + uidl.getTag()); JsArray<GwtYAxisOptions> yAxes = JavaScriptObject.createArray().cast(); for (int cnt = 0; cnt < uidl.getChildCount(); cnt++) { GwtYAxisOptions yAxisOptions = GwtYAxisOptions.create(); UIDL axisUIDL = uidl.getChildUIDL(cnt); if (axisUIDL.getAttributeNames().size() == 0 && axisUIDL.getChildCount() == 0) { continue; }// w w w. j a v a 2 s . co m updateBaseAxisOptions(axisUIDL, yAxisOptions); yAxes.push(yAxisOptions); } VConsole.log("Exit [getYAxisOptions]"); return yAxes; }
From source file:com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts.java
License:Apache License
private void updatePieOptions(UIDL pieUIDL, GwtPieOptions pieOptions) { VConsole.log("Enter [updatePieOptions]"); VConsole.log("Tag Name : " + pieUIDL.getTag()); updateSeriesOptions(pieUIDL, pieOptions); Integer centerX = null;//from www.j a v a 2s. c o m Integer centerY = null; if (pieUIDL.hasAttribute("centerX")) { centerX = pieUIDL.getIntAttribute("centerX"); } if (pieUIDL.hasAttribute("centerY")) { centerY = pieUIDL.getIntAttribute("centerY"); } if (centerX != null || centerY != null) { JsArrayNumber center = JavaScriptObject.createArray().cast(); center.push((centerX == null ? 0 : centerX)); center.push((centerY == null ? 0 : centerY)); pieOptions.setCenter(center); } if (pieUIDL.hasAttribute("borderColor")) { pieOptions.setBorderColor(pieUIDL.getStringAttribute("borderColor")); } if (pieUIDL.hasAttribute("borderWidth")) { pieOptions.setBorderWidth(pieUIDL.getIntAttribute("borderWidth")); } if (pieUIDL.hasAttribute("innerSize")) { pieOptions.setInnerSize(pieUIDL.getIntAttribute("innerSize")); } if (pieUIDL.hasAttribute("size")) { pieOptions.setSize(pieUIDL.getIntAttribute("size")); } if (pieUIDL.hasAttribute("slicedOffset")) { pieOptions.setSlicedOffset(pieUIDL.getIntAttribute("slicedOffset")); } VConsole.log("Exit [updatePieOptions]"); }
From source file:com.kk_electronic.kkportal.core.util.JsListListInterator.java
License:Open Source License
private JsList<E> convert(List<E> target) { JsList<E> retval = JavaScriptObject.createArray().cast(); for (E element : target) { retval.add(element);/*from w ww .jav a 2 s. com*/ } return retval; }
From source file:com.objetdirect.tatami.client.data.AbstractDataStore.java
License:Open Source License
private JavaScriptObject dojoGetValues(Item item, String attribute) { Object value = item.getValues(attribute); JavaScriptObject valuesArray;//from w w w . j av a2 s. c o m if (value == null) { return JavaScriptObject.createArray(); } if (value instanceof Collection || value instanceof Object[]) { valuesArray = JSHelper.convertObjectToJSObject(value); } else { Object[] toConvert = { value }; valuesArray = JSHelper.convertObjectToJSObject(toConvert); } return valuesArray; }
From source file:com.objetdirect.tatami.client.DojoController.java
License:Open Source License
/** * Creates a JavaScrtip Array of String object from a Java String array. * @param array the Java array//from w w w .j av a2 s . c o m * @return the JavaScript array corresponding to the given Java array */ static public JavaScriptObject createArray(String[] array) { JavaScriptObject jsArray = JavaScriptObject.createArray(); for (int i = 0; i < array.length; i++) { jsArray = put(jsArray, i, array[i]); } return jsArray; }
From source file:com.objetdirect.tatami.client.gfx.Polyline.java
License:Open Source License
/** * Creates a JavaScript array of JavaScrtip Point, from a Java array of <code>Point</code>. * @param points the Java <code>Points</code> * @return a JavaScrtip array/*from w w w . j av a2s. co m*/ */ private JavaScriptObject createArray(Point[] points) { JavaScriptObject jsArray = JavaScriptObject.createArray(); for (int i = 0; i < points.length; i++) { jsArray = put(jsArray, points[i].getGFXPoint(), i); } return jsArray; }
From source file:com.objetdirect.tatami.client.grid.Grid.java
License:Open Source License
public void onComplete(FetchEventSource source, List<?> items, Request request) { JavaScriptObject itemArray = JavaScriptObject.createArray(); for (Iterator<?> iterator = items.iterator(); iterator.hasNext();) { Item item = (Item) iterator.next(); itemArray = addItemToJSArray(itemArray, item); }//from w w w. ja v a 2 s. c o m delegateProcessRows(itemArray, request.toJSObject()); }
From source file:com.parabay.client.gears.Utils.java
License:Apache License
/** * Converts a Java array of strings to a JavaScript array of strings. *///from ww w . j a v a2 s . c o m public static JsArrayString toJavaScriptArray(String[] elements) { JsArrayString array = JavaScriptObject.createArray().cast(); if (null != elements) { for (int i = 0; i < elements.length; ++i) { array.set(i, elements[i]); } } return array; }