List of usage examples for org.apache.wicket.model ComponentModel ComponentModel
ComponentModel
From source file:com.doculibre.constellio.wicket.links.AdminLinkHolder.java
License:Open Source License
public AdminLinkHolder(String id) { super(id, new ComponentModel() { @Override// ww w . j a v a 2s. c o m protected Object getObject(Component component) { return component.getLocalizer().getString("admin", component); } }); }
From source file:com.doculibre.constellio.wicket.links.SearchLinkHolder.java
License:Open Source License
public SearchLinkHolder(String id) { super(id, new ComponentModel() { @Override/*from ww w . j av a 2 s .co m*/ protected Object getObject(Component component) { return component.getLocalizer().getString("search", component); } }); }
From source file:com.doculibre.constellio.wicket.links.SignInLinkHolder.java
License:Open Source License
public SignInLinkHolder(String id) { super(id, new ComponentModel() { @Override/*w w w.j av a 2 s .c om*/ protected Object getObject(Component component) { return component.getLocalizer().getString("signIn", component); } }); }
From source file:com.doculibre.constellio.wicket.links.SignOutLinkHolder.java
License:Open Source License
public SignOutLinkHolder(String id) { super(id, new ComponentModel() { @Override// w ww. j a va 2 s .c om protected Object getObject(Component component) { return component.getLocalizer().getString("signOut", component); } }); }
From source file:de.codepitbull.imodel.HomePage2.java
License:Apache License
public HomePage2(final PageParameters parameters) { ComponentModel componentModel = new ComponentModel(); add(new Form<Void>("testForm").add(new Label("testText", new ResourceModel("beispielText"))) .add(new TextField<String>("testInput", new PropertyModel<String>(this, "textField"))) .add(new AjaxSubmitLink("submit") { @Override//from ww w .j a v a 2 s . c o m protected void onSubmit(AjaxRequestTarget target, Form<?> form) { System.out.println("Value: " + HomePage2.this.textField); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { } })); }
From source file:org.wicketstuff.gchart.examples.HomePage.java
License:Apache License
/** * More complicated example: Line chart with three series and two axes. Make * use of OptionHelper and use labels from i18n resources. Make use of * explicit formatting of cell values and axis labels Simple * AbstractReadonlyModel could be used if no i18n from Resources is needed. * Shows use of {@link OptionModifier} to demonstrate axis and series * configuring. Resulting options:/*from ww w. j av a 2 s. c o m*/ * {@code var options = {"pointSize":5,"hAxis":{"format":"hh:mm a","title":"Ortszeit 19.07.2017","viewWindow":{"min":new Date(2017, 6, 19, 0, 0),"max":new Date(2017, 6, 20, 0, 0)},"gridlines":{"count":8}},"vAxes":{"0":{"title":"Temperatur (C)","viewWindow":{"min":10,"max":30}},"1":{"format":"percent","title":"Rel. Luftfeuchte %","viewWindow":{"min":0.3,"max":0.6},"gridlines":{"count":8}}},"series":{"0":{"targetAxisIndex":0},"1":{"targetAxisIndex":0},"2":{"targetAxisIndex":1}},"title":"Metar Temperatur"};} * * @return Line chart ready to use on page. */ private Chart createChartLine() { IComponentAssignedModel<ChartOptions> optionsModel = new ComponentModel<ChartOptions>() { private static final long serialVersionUID = 1L; @Override public ChartOptions getObject(Component component) { OptionHelper optionHelper = new ClassicOptionHelper((Chart) component); ChartOptions opts = new ChartOptions("options"); optionHelper.addTitle(opts); opts.put("pointSize", 5); OptionModifier temperatureModifier = new OptionModifier() { @Override public void modify(ChartOptions options) { ChartOptions viewWindow = new ChartOptions(); viewWindow.put("min", 10); viewWindow.put("max", 30); options.put("viewWindow", viewWindow); } }; OptionModifier humidityModifier = new OptionModifier() { @Override public void modify(ChartOptions options) { options.put("format", "percent"); ChartOptions viewWindow = new ChartOptions(); viewWindow.put("min", 0.30); viewWindow.put("max", 0.60); options.put("viewWindow", viewWindow); ChartOptions vAxisGridline = new ChartOptions(); vAxisGridline.put("count", 8); options.put("gridlines", vAxisGridline); } }; optionHelper.addDualAxisOptions(opts, new String[] { "Temp", "Humidity" }, new String[] { "Temp", "Temp", "Humidity" }, // add for use with no i18n: new String[]{"Temperatur", "Rel. Luftfeuchte"}, new OptionModifier[] { temperatureModifier, humidityModifier }, null); ChartOptions hAxisOpts = new ChartOptions(); hAxisOpts.put("title", "Ortszeit 19.07.2017"); hAxisOpts.put("format", "hh:mm a"); // just for demonstration, delete line to see Google's format, which is more pretty here ChartOptions viewWinOpts = new ChartOptions(); viewWinOpts.put("min", DataCell.getJsValue(new GregorianCalendar(2017, Calendar.JULY, 19, 0, 0))); viewWinOpts.put("max", DataCell.getJsValue(new GregorianCalendar(2017, Calendar.JULY, 20, 0, 0))); hAxisOpts.put("viewWindow", viewWinOpts); ChartOptions hAxisGridline = new ChartOptions(); hAxisGridline.put("count", 8); hAxisOpts.put("gridlines", hAxisGridline); opts.put("hAxis", hAxisOpts); return opts; } }; IComponentAssignedModel<DataTable> dataModel = new ComponentModel<DataTable>() { private static final long serialVersionUID = 1L; @Override public DataTable getObject(Component component) { OptionHelper optionHelper = new ClassicOptionHelper((Chart) component); List<ColumnDeclaration> colDefs; List<DataRow> rows; colDefs = new ArrayList<>(); colDefs.add(new ColumnDeclaration(ColumnType.DATETIME, "Timestamp")); // alternative colDefs.add(new ColumnDeclaration(ColumnType.DATETIME, optionHelper.getChartLabelResourceModel("series.0.label"))); // alternative colDefs.add(ColumnDeclaration.fromJSON("{'type': 'number', 'label':'Temperature'}")); colDefs.add(new ColumnDeclaration(ColumnType.NUMBER, optionHelper.getChartLabelResourceModel("series.1.label"))); colDefs.add(new ColumnDeclaration(ColumnType.STRING, ColumnRole.ANNOTATION)); colDefs.add(new ColumnDeclaration(ColumnType.NUMBER, optionHelper.getChartLabelResourceModel("series.2.label"))); colDefs.add(new ColumnDeclaration(ColumnType.NUMBER, optionHelper.getChartLabelResourceModel("series.3.label"))); Object[][] exampleData = new Object[][] { { new GregorianCalendar(2017, Calendar.JULY, 19, 8, 20).getTime(), 28, null, 12, 0.45 }, { new GregorianCalendar(2017, Calendar.JULY, 19, 8, 50), 18, null, 13, 0.49 }, { new GregorianCalendar(2017, Calendar.JULY, 19, 9, 20), 23, "Annotation", 14, 0.44 }, { new GregorianCalendar(2017, Calendar.JULY, 19, 9, 50), 16, null, 14, 0.40 } }; // demonstration of explicitly formatting the data. // If simple object is added to row instead of DataCell, Google Charts formats the values for you. Format dateFormat = new SimpleDateFormat("dd.MM HH:mm", ((Chart) component).getLocale()); Format celsiusFormat = new DecimalFormat("00.#"); Format percentFormat = new DecimalFormat("##0.0%"); rows = new ArrayList<>(); for (Object[] objects : exampleData) { DataRow row = new DataRow(5); row.add(new DataCell(objects[0], dateFormat)); // hAxis Date row.add(new DataCell(objects[1], celsiusFormat)); // series 1 row.add(objects[2]); // Annotation for series 1 row.add(new DataCell(objects[3], celsiusFormat)); // series 2 row.add(new DataCell(objects[4], percentFormat)); // series 3 rows.add(row); } return new DataTable("data", colDefs, rows); } }; return new Chart("chartLine", Model.of(ChartType.LINE), optionsModel, dataModel, chartLibLoader); }
From source file:org.wicketstuff.gchart.examples.HomePage.java
License:Apache License
/** * Line chart with two series and two axes according to * <a href="https://developers.google.com/chart/interactive/docs/gallery/linechart#dual-y-charts">Google's * example</a>. Make use of OptionBuiler. Shows use of {@link OptionModifier} * to demonstrate series configuring./*from ww w. j a v a 2s .c o m*/ * * @return Line chart ready to use on page. */ private Chart createChartDualLine() { IComponentAssignedModel<ChartOptions> optionsModel = new ComponentModel<ChartOptions>() { private static final long serialVersionUID = 1L; @Override public ChartOptions getObject(Component component) { OptionBuilder builder = OptionBuilder.classic((Chart) component); ChartOptions opts = new ChartOptions("options"); builder.title("Average Temperatures and Daylight in Iceland Throughout the Year"); opts.put("width", 900); opts.put("height", 500); builder.axis("TEMP", "Temps (Celsius)").axis("DAYLIGHT", "Daylight"); // change color of series 1 to orange to demonstrate use of modifiers OptionModifier daylightSeriesModifier = new OptionModifier() { @Override public void modify(ChartOptions options) { options.put("color", "#FF7D0E"); } }; builder.mapSeries("TEMP").mapSeries("DAYLIGHT", daylightSeriesModifier); ChartOptions hAxisOpts = new ChartOptions(); JSONArray ticksJSON = new JSONArray(); for (int month = 0; month < 12; month++) { JSONFunction dateFun = new JSONFunction(String.format("new Date(2014, %d)", month)); ticksJSON.put(dateFun); } hAxisOpts.put("ticks", ticksJSON); opts.put("hAxis", hAxisOpts); ChartOptions vAxisOpts = new ChartOptions(); ChartOptions viewWindowOpts = new ChartOptions(); viewWindowOpts.put("max", 30); vAxisOpts.put("viewWindow", viewWindowOpts); opts.put("vAxis", vAxisOpts); opts.putAll(builder.build()); return opts; } }; IComponentAssignedModel<DataTable> dataModel = new ComponentModel<DataTable>() { private static final long serialVersionUID = 1L; @Override public DataTable getObject(Component component) { List<ColumnDeclaration> colDefs; List<DataRow> rows; colDefs = new ArrayList<>(); colDefs.add(new ColumnDeclaration(ColumnType.DATE, "Month")); colDefs.add(new ColumnDeclaration(ColumnType.NUMBER, "Average Temperature")); colDefs.add(new ColumnDeclaration(ColumnType.NUMBER, "Average Hours of Daylight")); Object[][] exampleData = new Object[][] { { new GregorianCalendar(2014, Calendar.JANUARY, 1, 0, 0), -0.5, 5.7 }, { new GregorianCalendar(2014, Calendar.FEBRUARY, 1, 8, 0), .4, 8.7 }, { new GregorianCalendar(2014, Calendar.MARCH, 1, 0, 0), .5, 12 }, { new GregorianCalendar(2014, Calendar.APRIL, 1, 0, 0), 2.9, 15.3 }, { new GregorianCalendar(2014, Calendar.MAY, 1, 0, 0), 6.3, 18.6 }, { new GregorianCalendar(2014, Calendar.JUNE, 1, 0, 0), 9, 20.9 }, { new GregorianCalendar(2014, Calendar.JULY, 1, 0, 0), 10.6, 19.8 }, { new GregorianCalendar(2014, Calendar.AUGUST, 1, 0, 0), 10.3, 16.6 }, { new GregorianCalendar(2014, Calendar.SEPTEMBER, 1, 0, 0), 7.4, 13.3 }, { new GregorianCalendar(2014, Calendar.OCTOBER, 1, 0, 0), 4.4, 9.9 }, { new GregorianCalendar(2014, Calendar.NOVEMBER, 1, 0, 0), 1.1, 6.6 }, { new GregorianCalendar(2014, Calendar.DECEMBER, 1, 0, 0), -.2, 4.5 } }; rows = DataTable.fromArray(exampleData); return new DataTable("data", colDefs, rows); } }; final Chart chart = new Chart("chartDualLine", Model.of(ChartType.LINE), optionsModel, dataModel, chartLibLoader); chart.setResponsive(false); return chart; }
From source file:org.wicketstuff.gchart.examples.HomePage.java
License:Apache License
private Chart createChartBar() { // 100% stacked ba chart from https://developers.google.com/chart/interactive/docs/gallery/barchart IComponentAssignedModel<ChartOptions> optionsModel = new ComponentModel<ChartOptions>() { private static final long serialVersionUID = 1L; @Override// w w w. j av a 2s.c o m public ChartOptions getObject(Component component) { ChartOptions opts = new ChartOptions("options"); opts.put("width", 600); opts.put("height", 400); // opts.put("isStacked", "percent"); opts.put("isStacked", stackedPercent ? "percent" : true); ChartOptions barOpt = new ChartOptions(); barOpt.put("groupWidth", "75%"); opts.put("bar", barOpt); ChartOptions legendOpt = new ChartOptions(); legendOpt.put("position", "top"); legendOpt.put("maxLines", 3); opts.put("legend", legendOpt); ChartOptions hAxisOpts = new ChartOptions(); hAxisOpts.put("minValue", "0"); hAxisOpts.put("ticks", new JSONArray("[0, .3, .6, .9, 1]")); // opts.put("hAxis", hAxisOpts); return opts; } }; IComponentAssignedModel<DataTable> dataModel = new ComponentModel<DataTable>() { private static final long serialVersionUID = 1L; @Override public DataTable getObject(Component component) { List<ColumnDeclaration> colDefs = new ArrayList<>(); List<DataRow> rows; colDefs.add(new ColumnDeclaration(ColumnType.STRING, "Year")); colDefs.add(new ColumnDeclaration(ColumnType.NUMBER, "Fantasy & Sci Fi")); colDefs.add(new ColumnDeclaration(ColumnType.NUMBER, "Romance")); colDefs.add(new ColumnDeclaration(ColumnType.NUMBER, "Mystery/Crime")); colDefs.add(new ColumnDeclaration(ColumnType.NUMBER, "General")); colDefs.add(new ColumnDeclaration(ColumnType.NUMBER, "Western")); colDefs.add(new ColumnDeclaration(ColumnType.NUMBER, "Literature")); colDefs.add(new ColumnDeclaration(ColumnType.STRING, ColumnRole.ANNOTATION)); Object[][] exampleData = new Object[][] { { "2010", 10, 24, 20, 32, 18, 5, "" }, { "2020", 16, 22, 23, 30, 16, 9, "" }, { "2030", 28, 19, 29, 30, 12, 13, "" } }; rows = DataTable.fromArray(exampleData); return new DataTable("data", colDefs, rows); } }; final Chart chartB = new Chart("chartBar", Model.of(ChartType.BAR), optionsModel, dataModel, chartLibLoader); chartB.setResponsive(false); return chartB; }