List of usage examples for com.google.gwt.json.client JSONNumber JSONNumber
public JSONNumber(double value)
From source file:com.github.gilbertotorrezan.gwtcloudinary.client.CloudinaryUploadWidget.java
License:Open Source License
/** * Initialize the size of the cropping selection box to a different value than the default (0.9). Relevant only if the cropping feature is enabled. * The cropping_default_selection_ratio value is calculated as a proportion of the image's size. * /*from w w w . j ava 2 s . c o m*/ * @param croppingDefaultSelectionRatio Decimal. Default: 0.9. Range: 0.1 to 1.0. Example: 0.75 */ public CloudinaryUploadWidget setCroppingDefaultSelectionRatio(Double croppingDefaultSelectionRatio) { options.put("cropping_default_selection_ratio", croppingDefaultSelectionRatio == null ? null : new JSONNumber(croppingDefaultSelectionRatio)); return this; }
From source file:com.github.gilbertotorrezan.gwtcloudinary.client.CloudinaryUploadWidget.java
License:Open Source License
/** * If specified, perform client side validation that prevents uploading files bigger than the given bytes size. * // w ww.j a v a 2 s . c o m * @param maxFileSize Integer. Number of bytes. Default: null. No size limit. Example: 130000 */ public CloudinaryUploadWidget setMaxFileSize(Integer maxFileSize) { options.put("max_file_size", maxFileSize == null ? null : new JSONNumber(maxFileSize)); return this; }
From source file:com.github.gilbertotorrezan.gwtcloudinary.client.CloudinaryUploadWidget.java
License:Open Source License
/** * If specified, client-side scale-down resizing takes place before uploading if the width of the selected file is bigger than the specified value. * //from w w w. ja va2 s.c om * @param maxImageWidth Integer. Number of pixels. Default: null. No resizing. Example: 2000 */ public CloudinaryUploadWidget setMaxImageWidth(Integer maxImageWidth) { options.put("max_image_width", maxImageWidth == null ? null : new JSONNumber(maxImageWidth)); return this; }
From source file:com.github.gilbertotorrezan.gwtcloudinary.client.CloudinaryUploadWidget.java
License:Open Source License
/** * If specified, client-side scale-down resizing takes place before uploading if the height of the selected file is bigger than the specified value. * /* ww w . j ava 2s. c o m*/ * @param maxImageHeight Integer. Number of pixels. Default: null. No resizing. Example: 2000 */ public CloudinaryUploadWidget setMaxImageHeight(Integer maxImageHeight) { options.put("max_image_height", maxImageHeight == null ? null : new JSONNumber(maxImageHeight)); return this; }
From source file:com.github.ligangty.common.highconvert.BaseChart.java
License:Apache License
/** * Convenience method for setting the 'margin' option of the chart. Equivalent to: * <pre><code>// ww w .j av a 2 s. c o m * chart.setOption("/chart/margin", 0, 10, 0, 15); * </code></pre> * The margin between the outer edge of the chart and the plot area. Use the options * {@link #setMarginTop(Number)}, {@link #setMarginRight(Number)}, {@link #setMarginBottom(Number)}, and * {@link #setMarginLeft(Number)} for shorthand setting of one option. * <p/> * Since version 2.1, the margin is 0 by default. The actual space is dynamically calculated from * the offset of axis labels, axis title, title, subtitle and legend in addition to the * {@link #setSpacingTop(Number)}, {@link #setSpacingRight(Number)}, {@link #setSpacingBottom(Number)}, * and {@link #setSpacingLeft(Number)} options. * * @param marginTop The margin between the top outer edge of the chart and the plot area. * @param marginRight The margin between the right outer edge of the chart and the plot area. * @param marginBottom The margin between the bottom outer edge of the chart and the plot area. * @param marginLeft The margin between the left outer edge of the chart and the plot area. * @return A reference to this {@link BaseChart} instance for convenient method chaining. */ public T setMargin(Number marginTop, Number marginRight, Number marginBottom, Number marginLeft) { JSONArray margins = new JSONArray(); margins.set(0, new JSONNumber(marginTop.doubleValue())); margins.set(1, new JSONNumber(marginRight.doubleValue())); margins.set(2, new JSONNumber(marginBottom.doubleValue())); margins.set(3, new JSONNumber(marginLeft.doubleValue())); return this.setOption("/chart/margin", margins); }
From source file:com.github.ligangty.common.highconvert.BaseChart.java
License:Apache License
static JSONValue convertNumberToJSONValue(Number number) { if (number != null) { return new JSONNumber(number.doubleValue()); } else {//from ww w . j av a2 s . c om return JSONNull.getInstance(); } }
From source file:com.github.ligangty.common.highconvert.Color.java
License:Apache License
/** * Sets up this color as a linear gradient from one location in space to another, specifying * the coordinates in pixels.//from w ww . j a v a 2 s . com * <p/> * Note that you can also use the {@link #setLinearGradient(double, double, double, double)} * version if you know you instead want to operate in percentages, or the * {@link #setLinearGradient(String, String, String, String)} version if you need to * operate in both percentages and pixels concurrently. * * @param x0 The x-coordinate of the start point of the gradient (in pixels). * @param y0 The y-coordinate of the start point of the gradient (in pixels). * @param x1 The x-coordinate of the end point of the gradient (in pixels). * @param y1 The y-coordinate of the end point of the gradient (in pixels). * @return A reference to this {@link Color} instance for convenient method chaining. */ public Color setLinearGradient(int x0, int y0, int x1, int y1) { value = null; JSONArray coordinates = new JSONArray(); coordinates.set(0, new JSONNumber(x0)); coordinates.set(1, new JSONNumber(y0)); coordinates.set(2, new JSONNumber(x1)); coordinates.set(3, new JSONNumber(y1)); return this.setOption("linearGradient", coordinates); }
From source file:com.github.ligangty.common.highconvert.Color.java
License:Apache License
private Color internalAddColorStop(double offset, String color) { value = null;// w w w. j av a 2 s .c om JSONArray colorStop = new JSONArray(); colorStop.set(0, new JSONNumber(offset)); colorStop.set(1, new JSONString(color)); colorStops.set(colorStops.size(), colorStop); return this.setOption("stops", colorStops); }
From source file:com.github.ligangty.common.highconvert.plotOptions.PiePlotOptions.java
License:Apache License
/** * Convenience method for setting the 'center' option of the pie plot options * to pixel values. Equivalent to://from w w w . j a va2 s .c o m * <pre><code> * piePlotOptions.setOption("center", new Number[] { 100, 120 }); * </code></pre> * The center of the pie chart relative to the plot area (in pixels). See the * {@link #setCenter(double, double)} method to set the center using percentages instead. * Defaults to 50%, 50%. * * @param x The horizontal center of the pie chart relative to the plot area (in pixels) * @param y The vertical center of the pie chart relative to the plot area (in pixels) * @return A reference to this {@link PiePlotOptions} instance for convenient method chaining. */ public PiePlotOptions setCenter(int x, int y) { JSONArray center = new JSONArray(); center.set(0, new JSONNumber(x)); center.set(1, new JSONNumber(y)); return this.setOption("center", center); }
From source file:com.github.ligangty.common.highconvert.Series.java
License:Apache License
/** * Apply a new set of data (Y values only) to the series and optionally redraw it. If you need * more control than just simply setting the y values of each data point, then use the * {@link #setPoints(com.github.ligangty.common.highconvert.Point[], boolean)} method instead. * * @param yValues The array of Y values to set on the data series (replacing any data already in place) * @param redraw Whether to redraw the chart after the series is altered. If doing more operations * on the chart, it is a good idea to set redraw to false and then call * {@link com.github.ligangty.common.highconvert.Chart#redraw()} after. * @return A reference to this {@link com.github.ligangty.common.highconvert.Series} instance for convenient method chaining. *///from w ww . j a v a 2s . com public Series setPoints(Number[] yValues, boolean redraw) { this.points.clear(); // If persistence is enabled than we need to store the point locally as well (so we have it if // the chart is dynamically moved to another panel). if (!isRendered() || chart.isPersistent()) { for (Number yValue : yValues) { this.addPoint(yValue); } } if (isRendered()) { final JavaScriptObject nativeSeries = chart.get(this.id); if (nativeSeries != null) { JSONArray jsonArray = new JSONArray(); for (int i = 0, pointsLength = yValues.length; i < pointsLength; i++) { if ((yValues[i] != null)) { jsonArray.set(i, new JSONNumber(yValues[i].doubleValue())); } else { jsonArray.set(i, JSONNull.getInstance()); } } nativeSetData(nativeSeries, jsonArray.getJavaScriptObject(), redraw); } } return this; }