Example usage for com.google.gwt.core.client JavaScriptObject createArray

List of usage examples for com.google.gwt.core.client JavaScriptObject createArray

Introduction

In this page you can find the example usage for com.google.gwt.core.client JavaScriptObject createArray.

Prototype

public static native JavaScriptObject createArray() ;

Source Link

Document

Returns a new array.

Usage

From source file:elemental.js.util.JsMapFromIntTo.java

License:Apache License

/**
 * Create a new empty map instance.
 */
public static <T> JsMapFromIntTo<T> create() {
    return JavaScriptObject.createArray().cast();
}

From source file:elemental.js.util.JsMapFromIntToString.java

License:Apache License

/**
 * Create a new empty map instance.
 */
public static JsMapFromIntToString create() {
    return JavaScriptObject.createArray().cast();
}

From source file:eu.riscoss.client.report.RiskAnalysisReport.java

License:Apache License

protected void createComparisonCharts() {
    for (int i = 0; i < panels.size(); ++i) {
        ArrayList<Double> compare = new ArrayList<>();
        for (int j = 0; j < dataList.size(); ++j) {
            compare.add(dataList.get(j).getValues().get(i));
        }/*from   www.  j  a  v a 2  s  .c o  m*/
        //Window.alert(String.valueOf(i));
        PlotModel model = new PlotModel();
        PlotOptions plotOptions = PlotOptions.create();
        plotOptions.setLegendOptions(LegendOptions.create().setShow(false));
        plotOptions.setGridOptions(GridOptions.create().setMargin(5));
        //plotOptions.addXAxisOptions( AxisOptions.create().setFont( FontOptions.create().setColor("black").setWeight( "bold" ).setStyle( "italic" ) ) );
        // plotOptions.addYAxisOptions( AxisOptions.create().setFont( FontOptions.create().setColor( "black" ).setWeight( "bold" ).setStyle( "italic" ) ) );
        plotOptions.addYAxisOptions(AxisOptions.create().setMaximum(1).setMinimum(0));
        plotOptions.addXAxisOptions(AxisOptions.create().setTicks(new AbstractAxisOptions.TickGenerator() {
            @Override
            public JsArray<Tick> generate(Axis axis) {
                JsArray<Tick> array = JsArray.createArray().cast();
                for (int i = 0; i < dataList.size(); i++) {
                    array.push(Tick.of(i, dataList.get(i).getStringDate()));
                }
                return array;
            }
        }));
        // create the plot
        SimplePlot plot = new SimplePlot(model, plotOptions);
        plot.getModel().addSeries(Series.of("Exposure"));
        for (int j = 0; j < compare.size(); j++) {
            for (SeriesHandler series : plot.getModel().getHandlers()) {
                series.add(DataPoint.of(j, compare.get(j)));
            }
        }
        JsArrayString colors = JavaScriptObject.createArray().cast();
        colors.push(colorsArray[i]);
        plotOptions.setDefaultColorTheme(colors);
        plot.setHeight("200px");
        panels.get(i).setWidget(plot);
    }
}

From source file:eu.riscoss.client.report.RiskAnalysisReport.java

License:Apache License

protected void drawCh() {
    int nbSeries = response.isArray().size();
    //Window.alert(String.valueOf(nbSeries));

    PlotModel model = new PlotModel();
    PlotOptions plotOptions = PlotOptions.create();

    GlobalSeriesOptions globalSeriesOptions = GlobalSeriesOptions.create();
    globalSeriesOptions.setBarsSeriesOptions(
            BarSeriesOptions.create().setShow(true).setBarWidth(0.2).setLineWidth(1).setFill(0.8));
    plotOptions.addXAxisOptions(AxisOptions.create().setTicks(new AbstractAxisOptions.TickGenerator() {

        @Override/* w  w  w.ja va2s  .co m*/
        public JsArray<Tick> generate(Axis axis) {
            JsArray<Tick> array = JsArray.createArray().cast();
            for (int i = 0; i < 1; i++) {
                array.push(Tick.of(i, "Exposure"));
            }
            return array;
        }
    }));
    plotOptions.addYAxisOptions(AxisOptions.create().setMaximum(1.0));
    plotOptions.addYAxisOptions(AxisOptions.create().setMinimum(0.0));

    plotOptions.setGlobalSeriesOptions(globalSeriesOptions);

    plotOptions.setLegendOptions(LegendOptions.create().setMargin(-150, 0));

    JsArrayString colors = JavaScriptObject.createArray().cast();
    colorsArray = getRandomColors(nbSeries);
    for (String s : colorsArray) {
        colors.push(s);
    }

    ArrayList<Double> values = new ArrayList<>();
    // create a series
    List<SeriesHandler> series = new ArrayList<SeriesHandler>();
    for (int i = 0; i < nbSeries; i++) {
        JSONObject v = response.isArray().get(i).isObject();
        JsonRiskResult result = new JsonRiskResult(v);
        String id = "";
        switch (result.getDataType()) {
        case EVIDENCE: {
            id = v.get("id").isString().stringValue();
            Double value = v.get("e").isObject().get("e").isNumber().doubleValue();
            series.add(
                    model.addSeries(Series.of(id).setBarsSeriesOptions(BarSeriesOptions.create().setOrder(i))));
            values.add(value);
            String s = "arg" + i;
            String c = "col" + i;
            HTMLPanel html = new HTMLPanel("<span id='" + c + "'></span>");
            JArgument arg = argumentation.arguments.get(result.getChunkId());
            SimplePanel p = new SimplePanel();
            p.setSize("20px", "20px");
            p.getElement().getStyle().setBackgroundColor(colorsArray[i]);
            p.setStyleName("colorBox");

            HorizontalPanel hp = new HorizontalPanel();
            hp.setStyleName("margin-bottom");
            hp.add(p);

            String htmlString = "<b>" + v.get("id").isString().stringValue() + "</b>";
            if (v.get("description") != null) {
                htmlString += ": " + v.get("description").isString().stringValue();
            }
            HTMLPanel htm = new HTMLPanel(htmlString);
            hp.add(htm);

            html.add(hp, c);

            html.setWidth("100%");
            html.setStyleName("descriptionPanel");
            descriptions.add(html);
            break;
        }
        default:
            break;
        }

    }

    // add data
    for (int i = 0; i < series.size(); i++) {
        series.get(i).add(DataPoint.of(0, values.get(i)));
    }

    plotOptions.setLegendOptions(LegendOptions.create().setShow(false));
    plotOptions.setDefaultColorTheme(colors);
    // create the plot
    SimplePlot plot2 = new SimplePlot(model, plotOptions);
    //HEIGHT value in % has problems, needs to be fixed
    //plot2.setHeight("100%");
    int size = nbSeries * 40;
    if (size < 350)
        size = 350;
    //plot2.setHeight(size + "px");
    mainChartPanel.add(plot2);
    mainChartPanel.add(descriptions);
}

From source file:gwt.dojo.core.client.JsArray.java

License:Apache License

public final static JsArray create() {
    return JavaScriptObject.createArray().cast();
}

From source file:gwt.dojo.core.client.MessageHub.java

License:Apache License

/**
 * Publishes a message to a topic on the pub/sub hub. All arguments after
 * the first will be passed to the subscribers, so any number of arguments
 * can be provided (not just event).// w  w w.j a  v  a 2  s  .  c om
 * 
 * @param topic
 *            The name of the topic to publish to.
 * @param message
 *            A message to distribute to the topic listeners.
 */
public static void publish(String topic, Object... message) {
    JsArray args = JavaScriptObject.createArray().cast();
    if (message != null) {
        for (int i = 0, n = message.length; i < n; i++) {
            args.push(message[i]);
        }
    }
    ref()._publish(topic, args);
}

From source file:gwt.dojo.showcase.client.controllers.FormsController.java

License:Apache License

@Override
public void callback(final JsObject source, NativeEvent event) {
    JsArray modules = JavaScriptObject.createArray().cast();
    modules.push("dojox/mobile/TextBox", "dojox/mobile/TextArea", "dojox/mobile/CheckBox",
            "dojox/mobile/RadioButton", "dojox/mobile/Slider");
    Dojo.require(modules, new DojoCallback<Object>() {
        @Override/*w  w w  .ja  v a  2 s  . co  m*/
        public void callback(Object context, JsArray arguments) {
            ListItem listItem = source.cast();
            listItem.set("controller", FormsController.this);
            showcase.showView(listItem);
        }
    });
}

From source file:gwt.dojo.showcase.client.Showcase.java

License:Apache License

/**
 * This is the entry point method./* w  ww  .j  a va2  s.  c o m*/
 */
public void onModuleLoad() {
    JsArray modules = JavaScriptObject.createArray().cast();
    modules.push("dojox/mobile/deviceTheme", "dojox/mobile", "dojox/mobile/parser", "dojox/mobile/compat",
            "dojox/mobile/Button", "dojox/mobile/ToolBarButton", "dojox/mobile/FixedSplitter",
            "dojox/mobile/ScrollableView", "dojox/mobile/ProgressIndicator", "dojox/mobile/FixedSplitterPane",
            "dojox/mobile/SwapView", "dojox/mobile/TabBar", "dojo/domReady!");
    Dojo.require(modules, new DojoCallback<Object>() {
        @Override
        public void callback(Object context, JsArray arguments) {
            startup(arguments);
        }
    });
}

From source file:gwtupload.client.Uploader.java

License:Apache License

/**
 * Returns a JavaScriptObject object with info of the uploaded files.
 * It's useful in the exported version of the library. 
 *//*from  w ww.j  av  a  2s .  c o  m*/
public JavaScriptObject getData() {
    if (multiple) {
        JsArray<JavaScriptObject> ret = JavaScriptObject.createArray().cast();
        for (UploadedInfo info : serverMessage.getUploadedInfos()) {
            ret.push(getDataInfo(info));
        }
        return ret;
    } else {
        return getDataInfo(getServerInfo());
    }
}

From source file:java.util.AbstractHashMap.java

License:Apache License

private void clearImpl() {
    hashCodeMap = JavaScriptObject.createArray();
    stringMap = JavaScriptObject.createObject();
    nullSlotLive = false;
    nullSlot = null;
    size = 0;
}