Search in sources :

Example 51 with VerticalLayout

use of com.vaadin.ui.VerticalLayout in project charts by vaadin.

the class ColumnWithLazyMultiLevelDrilldown method getChart.

@Override
protected Component getChart() {
    VerticalLayout layout = new VerticalLayout();
    final Chart chart = new Chart(ChartType.COLUMN);
    chart.setId("chart");
    conf = chart.getConfiguration();
    conf.setTitle("Global happiness index");
    conf.setSubTitle("Source: www.happyplanetindex.org");
    conf.getLegend().setEnabled(false);
    XAxis x = new XAxis();
    x.setType(AxisType.CATEGORY);
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setTitle("Total");
    conf.addyAxis(y);
    PlotOptionsColumn column = new PlotOptionsColumn();
    column.setCursor(Cursor.POINTER);
    column.setDataLabels(new DataLabels(true));
    conf.setPlotOptions(column);
    DataSeries series = new DataSeries();
    series.setName("Regions");
    PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
    plotOptionsColumn.setColorByPoint(true);
    series.setPlotOptions(plotOptionsColumn);
    DataSeriesItem item = new DataSeriesItem("Latin America and Carribean", 60);
    item.setId("Latin America and Carribean");
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Western Nations", 50);
    item.setId("Western Nations");
    series.addItemWithDrilldown(item);
    conf.addSeries(series);
    drillSeries = new HashMap<String, DataSeries>();
    DataSeries drill = new DataSeries("Latin America and Carribean Countries");
    item = new DataSeriesItem("Costa Rica", 64);
    item.setId("Costa Rica");
    drill.addItemWithDrilldown(item);
    item = new DataSeriesItem("Colombia", 59.8);
    item.setId("Colombia");
    drill.addItemWithDrilldown(item);
    item = new DataSeriesItem("Belize", 59.3);
    item.setId("Belize");
    drill.addItemWithDrilldown(item);
    drillSeries.put("Latin America and Carribean", drill);
    drill = new DataSeries("Western Nations Countries");
    item = new DataSeriesItem("New Zealand", 51.6);
    item.setId("New Zealand");
    drill.addItemWithDrilldown(item);
    item = new DataSeriesItem("Norway", 51.4);
    item.setId("Norway");
    drill.addItemWithDrilldown(item);
    item = new DataSeriesItem("Switzerland", 50.3);
    item.setId("Switzerland");
    drill.addItemWithDrilldown(item);
    drillSeries.put("Western Nations", drill);
    drill = new DataSeries("Details Costa Rica");
    drill.setId("Details Costa Rica");
    String[] categories = new String[] { "Life Expectancy", "Well-being (0-10)", "Footprint (gha/capita)" };
    Number[] ys = new Number[] { 79.3, 7.3, 2.5 };
    drill.setData(categories, ys);
    drillSeries.put("Costa Rica", drill);
    drill = new DataSeries("Details Colombia");
    drill.setId("Details Colombia");
    ys = new Number[] { 73.7, 6.4, 1.8 };
    drill.setData(categories, ys);
    drillSeries.put("Colombia", drill);
    drill = new DataSeries("Details Belize");
    drill.setId("Details Belize");
    ys = new Number[] { 76.1, 6.5, 2.1 };
    drill.setData(categories, ys);
    drillSeries.put("Belize", drill);
    drill = new DataSeries("Details New Zealand");
    drill.setId("Details New Zealand");
    ys = new Number[] { 80.7, 7.2, 4.3 };
    drill.setData(categories, ys);
    drillSeries.put("New Zealand", drill);
    drill = new DataSeries("Details Norway");
    drill.setId("Details Norway");
    ys = new Number[] { 81.1, 7.6, 4.8 };
    drill.setData(categories, ys);
    drillSeries.put("Norway", drill);
    drill = new DataSeries("Details Switzerland");
    drill.setId("Details Switzerland");
    ys = new Number[] { 82.3, 7.5, 5.0 };
    drill.setData(categories, ys);
    drillSeries.put("Switzerland", drill);
    chart.setDrilldownCallback(new DrilldownCallback() {

        @Override
        public Series handleDrilldown(DrilldownEvent event) {
            log("DrilldownEvent: " + event.getItem().getId());
            return getPointDrilldown(event.getItem());
        }
    });
    chart.addPointClickListener(new PointClickListener() {

        @Override
        public void onClick(PointClickEvent event) {
            log("PointClickEvent: " + event.getSeries().getName() + " index :" + event.getPointIndex());
        }
    });
    chart.addChartDrillupListener(new ChartDrillupListener() {

        @Override
        public void onDrillup(ChartDrillupEvent event) {
            log("ChartDrillupEvent");
        }
    });
    layout.addComponent(chart);
    layout.addComponent(log);
    return layout;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) PointClickEvent(com.vaadin.addon.charts.PointClickEvent) ChartDrillupListener(com.vaadin.addon.charts.ChartDrillupListener) XAxis(com.vaadin.addon.charts.model.XAxis) DrilldownEvent(com.vaadin.addon.charts.DrilldownEvent) Series(com.vaadin.addon.charts.model.Series) DataSeries(com.vaadin.addon.charts.model.DataSeries) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) PointClickListener(com.vaadin.addon.charts.PointClickListener) DrilldownCallback(com.vaadin.addon.charts.DrilldownCallback) VerticalLayout(com.vaadin.ui.VerticalLayout) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis) ChartDrillupEvent(com.vaadin.addon.charts.ChartDrillupEvent)

Example 52 with VerticalLayout

use of com.vaadin.ui.VerticalLayout in project charts by vaadin.

the class MultipleAxesWithResetZoom method getChart.

@Override
protected Component getChart() {
    final Chart chart = (Chart) new MultipleAxes().getChart();
    chart.getConfiguration().getTooltip().setEnabled(false);
    Button button = new Button("Reset zoom", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            chart.getConfiguration().resetZoom();
        }
    });
    VerticalLayout verticalLayout = new VerticalLayout(chart, button);
    verticalLayout.setSpacing(false);
    verticalLayout.setMargin(false);
    return verticalLayout;
}
Also used : Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) VerticalLayout(com.vaadin.ui.VerticalLayout) Chart(com.vaadin.addon.charts.Chart) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 53 with VerticalLayout

use of com.vaadin.ui.VerticalLayout in project opennms by OpenNMS.

the class SurveillanceViewsUI method init.

/**
 * {@inheritDoc}
 */
@Override
protected void init(VaadinRequest request) {
    /**
     * Force the reload of the configuration
     */
    SurveillanceViewProvider.getInstance().load();
    /**
     * create a layout
     */
    VerticalLayout rootLayout = new VerticalLayout();
    rootLayout.setSpacing(true);
    /**
     * check query parameters for viewName, dashboard
     */
    String viewName = request.getParameter("viewName");
    boolean dashboard = request.getParameter("dashboard") != null && "true".equals(request.getParameter("dashboard"));
    /**
     * retrieve the username
     */
    String username = request.getRemoteUser();
    /**
     * now select the right view
     */
    View view;
    if (viewName == null) {
        view = m_surveillanceViewService.selectDefaultViewForUsername(username);
    } else {
        view = SurveillanceViewProvider.getInstance().getView(viewName);
    }
    /**
     * set the poll interval
     */
    setPollInterval(1000);
    /**
     * check for dashboard role
     */
    boolean isDashboardRole = true;
    SecurityContext context = SecurityContextHolder.getContext();
    if ((context != null) && !(context.toString().contains(org.opennms.web.api.Authentication.ROLE_DASHBOARD))) {
        isDashboardRole = false;
    }
    LOG.debug("User {} is in dashboard role? {}", username, isDashboardRole);
    /**
     * now construct the surveillance view/dashboard
     */
    rootLayout.addComponent(new SurveillanceView(view, m_surveillanceViewService, dashboard, !isDashboardRole));
    setContent(rootLayout);
    Page.getCurrent().getJavaScript().execute("function receiveMessage(event){\n" + "if(event.origin !== window.location.origin){ return; }\n" + "\n" + "event.source.postMessage( (document.getElementById('surveillance-window').offsetHeight + 17) + 'px', window.location.origin )\n" + "}\n" + "window.addEventListener(\"message\", receiveMessage, false);");
}
Also used : SecurityContext(org.springframework.security.core.context.SecurityContext) VerticalLayout(com.vaadin.ui.VerticalLayout) View(org.opennms.netmgt.config.surveillanceViews.View)

Example 54 with VerticalLayout

use of com.vaadin.ui.VerticalLayout in project opennms by OpenNMS.

the class RrdDashlet method getGraphComponent.

/**
 * Returns the graph component for a given graph of the {@link DashletSpec}.
 *
 * @param i              the entry id
 * @param width          the width
 * @param height         the height
 * @param timeFrameType  the timeframe type
 * @param timeFrameValue the timeframe value
 * @return the component
 */
private Component getGraphComponent(int i, int width, int height, int timeFrameType, int timeFrameValue) {
    String graphTitle = getDashletSpec().getParameters().get("graphLabel" + i);
    String graphName = RrdGraphHelper.getGraphNameFromQuery(getDashletSpec().getParameters().get("graphUrl" + i));
    String resourceId = getDashletSpec().getParameters().get("resourceId" + i);
    GraphContainer graph = new GraphContainer(graphName, resourceId);
    graph.setTitle(graphTitle);
    // Setup the time span
    Calendar cal = new GregorianCalendar();
    graph.setEnd(cal.getTime());
    cal.add(timeFrameType, -timeFrameValue);
    graph.setStart(cal.getTime());
    // Use all of the available width
    graph.setWidthRatio(1.0d);
    VerticalLayout verticalLayout = new VerticalLayout();
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.addStyleName("box");
    horizontalLayout.setHeight("42px");
    VerticalLayout leftLayout = new VerticalLayout();
    leftLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    leftLayout.addStyleName("margin");
    Label labelFrom = new Label(getDashletSpec().getParameters().get("nodeLabel" + i));
    labelFrom.addStyleName("text");
    Label labelTo = new Label(getDashletSpec().getParameters().get("resourceTypeLabel" + i) + ": " + getDashletSpec().getParameters().get("resourceLabel" + i));
    labelTo.addStyleName("text");
    leftLayout.addComponent(labelFrom);
    leftLayout.addComponent(labelTo);
    horizontalLayout.addComponent(leftLayout);
    horizontalLayout.setExpandRatio(leftLayout, 1.0f);
    verticalLayout.addComponent(horizontalLayout);
    verticalLayout.addComponent(graph);
    verticalLayout.setWidth(width, Unit.PIXELS);
    verticalLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER);
    verticalLayout.setComponentAlignment(graph, Alignment.MIDDLE_CENTER);
    verticalLayout.setMargin(true);
    return verticalLayout;
}
Also used : GraphContainer(org.opennms.features.vaadin.components.graph.GraphContainer) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 55 with VerticalLayout

use of com.vaadin.ui.VerticalLayout in project opennms by OpenNMS.

the class SimpleIframeInVaadinApplication method init.

/* (non-Javadoc)
	 * @see com.vaadin.ui.UI#init(com.vaadin.server.VaadinRequest)
	 */
@Override
public void init(VaadinRequest request) {
    if (iframePageUrl == null)
        throw new RuntimeException("iframePageUrl must not be null");
    m_rootLayout = new VerticalLayout();
    m_rootLayout.setSizeFull();
    m_rootLayout.addStyleName("root-layout");
    setContent(m_rootLayout);
    addHeader(request);
    // add diagnostic page links
    if (headerLinks != null) {
        // defining 2 horizontal layouts to force links to stay together
        HorizontalLayout horizontalLayout1 = new HorizontalLayout();
        horizontalLayout1.setWidth("100%");
        horizontalLayout1.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
        HorizontalLayout horizontalLayout2 = new HorizontalLayout();
        horizontalLayout1.addComponent(horizontalLayout2);
        for (String name : headerLinks.keySet()) {
            String urlStr = headerLinks.get(name);
            ExternalResource urlResource = new ExternalResource(urlStr);
            Link link = new Link(name, urlResource);
            // adds space between links
            Label label = new Label("&nbsp;&nbsp;&nbsp;", ContentMode.HTML);
            horizontalLayout2.addComponent(link);
            horizontalLayout2.addComponent(label);
        }
        m_rootLayout.addComponent(horizontalLayout1);
    }
    ExternalResource iframPageResource = new ExternalResource(iframePageUrl);
    BrowserFrame browser = new BrowserFrame("", iframPageResource);
    browser.setWidth("100%");
    browser.setHeight("100%");
    m_rootLayout.addComponent(browser);
    // this forces the UI panel to use up all the available space below the header
    m_rootLayout.setExpandRatio(browser, 1.0f);
}
Also used : BrowserFrame(com.vaadin.ui.BrowserFrame) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) ExternalResource(com.vaadin.server.ExternalResource) Link(com.vaadin.ui.Link) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

VerticalLayout (com.vaadin.ui.VerticalLayout)101 Label (com.vaadin.ui.Label)38 HorizontalLayout (com.vaadin.ui.HorizontalLayout)25 Button (com.vaadin.ui.Button)24 Chart (com.vaadin.addon.charts.Chart)18 ClickEvent (com.vaadin.ui.Button.ClickEvent)15 Link (com.vaadin.ui.Link)15 ExternalResource (com.vaadin.server.ExternalResource)11 Configuration (com.vaadin.addon.charts.model.Configuration)10 ListSeries (com.vaadin.addon.charts.model.ListSeries)9 ClickListener (com.vaadin.ui.Button.ClickListener)8 PostConstruct (javax.annotation.PostConstruct)8 YAxis (com.vaadin.addon.charts.model.YAxis)7 DataSeries (com.vaadin.addon.charts.model.DataSeries)6 Panel (com.vaadin.ui.Panel)6 XAxis (com.vaadin.addon.charts.model.XAxis)5 Embedded (com.vaadin.ui.Embedded)5 TextField (com.vaadin.ui.TextField)5 PointClickEvent (com.vaadin.addon.charts.PointClickEvent)4 PointClickListener (com.vaadin.addon.charts.PointClickListener)4