use of com.vaadin.ui.Component in project charts by vaadin.
the class ChartWithExternalDataProvider method getChart.
@Override
protected Component getChart() {
HorizontalLayout lo = new HorizontalLayout();
lo.setSpacing(true);
DataProvider<Order, ?> dp = getOrderDataProvider();
DataProviderSeries<Order> chartDataSeries1 = createChartDataSeries1(dp);
DataProviderSeries<Order> chartDataSeries2 = createChartDataSeries2(dp);
Component table = createGrid(dp);
table.setSizeFull();
Chart chart1 = createChart1(chartDataSeries1);
chart1.setSizeFull();
Chart chart2 = createChart2(chartDataSeries2);
chart2.setSizeFull();
lo.setWidth("100%");
lo.setHeight("450px");
lo.addComponents(table);
lo.addComponent(chart1);
lo.addComponent(chart2);
lo.setExpandRatio(table, 0.2f);
lo.setExpandRatio(chart1, 0.4f);
lo.setExpandRatio(chart2, 0.4f);
return lo;
}
use of com.vaadin.ui.Component in project charts by vaadin.
the class DataProviderWithLotsOfData method getChart.
@Override
protected Component getChart() {
HorizontalLayout lo = new HorizontalLayout();
DataProviderSeries<Data> ds = createChartDS();
Component grid = createGrid();
Component chart = createChart(ds);
lo.addComponents(grid);
lo.addComponent(chart);
grid.setSizeFull();
chart.setSizeFull();
lo.setSizeFull();
lo.setExpandRatio(grid, 1);
lo.setExpandRatio(chart, 5);
return lo;
}
use of com.vaadin.ui.Component in project charts by vaadin.
the class AbstractVaadinChartExample method setup.
protected void setup() {
if (content.getComponentCount() == 0) {
final Component map = getChart();
content.addComponent(map);
content.setExpandRatio(map, 1);
}
}
use of com.vaadin.ui.Component in project VaadinUtils by rlsutton1.
the class BaseCrudView method selectFirstFieldAndShowTab.
protected void selectFirstFieldAndShowTab() {
for (Field<?> field : fieldGroup.getFields()) {
Component childField = field;
for (int i = 0; i < 10; i++) {
Component parentField = childField.getParent();
if (parentField instanceof TabSheet) {
((TabSheet) parentField).setSelectedTab(childField);
break;
}
if (parentField == null) {
// out of luck, didn't find a parent tab
break;
}
childField = parentField;
}
field.focus();
break;
}
}
use of com.vaadin.ui.Component in project v-leaflet by mstahv.
the class GeoJSONExample method getTestComponent.
@Override
public Component getTestComponent() {
leafletMap = new LMap();
leafletMap.setWidth("600px");
leafletMap.setHeight("400px");
/*
* Note, this is just one option to read GeoJSON in java. Here, using
* helper from geotools library. In some simple cases approach to use
* plain Json library like Jackson or GSON might be better.
*/
FeatureJSON io = new FeatureJSON();
try {
long currentTimeMillis = System.currentTimeMillis();
// Look ma, no proxy needed, how cool is that!
FeatureCollection fc = io.readFeatureCollection(new URL("https://gist.githubusercontent.com/hrbrmstr/91ea5cc9474286c72838/raw/59421ff9b268ff0929b051ddafafbeb94a4c1910/continents.json").openStream());
Logger.getLogger(GeoJSONExample.class.getName()).severe("Download in " + (System.currentTimeMillis() - currentTimeMillis));
currentTimeMillis = System.currentTimeMillis();
FeatureIterator iterator = fc.features();
try {
while (iterator.hasNext()) {
Feature feature = iterator.next();
Geometry geometry = (Geometry) feature.getDefaultGeometryProperty().getValue();
// The geojson provided in example is rather complex (several megabytes)
// Use JTS to simplyfy. Note that it is rather easy to use
// different settings on different zoom levels, as well as decide
// to drop the feature form client altogether
geometry = DouglasPeuckerSimplifier.simplify(geometry, 0.2);
// In this example can be Polygon/Multipolygon
Collection<LeafletLayer> toLayers = JTSUtil.toLayers(geometry);
for (LeafletLayer l : toLayers) {
leafletMap.addComponent(l);
if (l instanceof LLayerGroup) {
LLayerGroup group = (LLayerGroup) l;
Iterator<Component> components = group.getComponentIterator();
while (components.hasNext()) {
LPolygon lPolygon = (LPolygon) components.next();
lPolygon.setStroke(false);
lPolygon.setFillColor("brown");
}
}
}
}
Logger.getLogger(GeoJSONExample.class.getName()).severe("Reducing and creating layers " + (System.currentTimeMillis() - currentTimeMillis));
} finally {
iterator.close();
}
} catch (MalformedURLException ex) {
Logger.getLogger(GeoJSONExample.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(GeoJSONExample.class.getName()).log(Level.SEVERE, null, ex);
}
leafletMap.zoomToContent();
return leafletMap;
}
Aggregations