Search in sources :

Example 1 with GraphContainer

use of org.opennms.features.vaadin.components.graph.GraphContainer in project opennms by OpenNMS.

the class KscDashlet method getGraphContainer.

private static GraphContainer getGraphContainer(Graph graph, Date start, Date end) {
    GraphContainer graphContainer = new GraphContainer(graph.getGraphtype(), graph.getResourceId().orElse(null));
    graphContainer.setTitle(graph.getTitle());
    // Setup the time span
    graphContainer.setStart(start);
    graphContainer.setEnd(end);
    // Use all of the available width
    graphContainer.setWidthRatio(1.0d);
    return graphContainer;
}
Also used : GraphContainer(org.opennms.features.vaadin.components.graph.GraphContainer)

Example 2 with GraphContainer

use of org.opennms.features.vaadin.components.graph.GraphContainer in project opennms by OpenNMS.

the class RrdGraphEntry method update.

/**
     * Updates the labels and buttons according to the properties set.
     */
public void update() {
    m_graphLayout.removeAllComponents();
    if (m_graphId == null) {
        m_nodeLabelComponent.setValue("No Rrd graph");
        m_graphLabelComponent.setValue("selected");
        m_changeButton.setCaption("Select Rrd graph");
        m_removeButton.setVisible(false);
    } else {
        String graphName = RrdGraphHelper.getGraphNameFromQuery(m_graphUrl);
        GraphContainer graph = new GraphContainer(graphName, m_resourceId);
        graph.setTitle(m_graphLabel);
        // Setup the time span
        Calendar cal = new GregorianCalendar();
        graph.setEnd(cal.getTime());
        cal.add(m_calendarField, -m_calendarDiff);
        graph.setStart(cal.getTime());
        // Use all of the available width
        graph.setWidthRatio(1.0d);
        graph.setHeightRatio(0.2d);
        m_graphLayout.addComponent(graph);
        m_graphLabelComponent.setValue(m_resourceTypeLabel + ": " + m_resourceLabel);
        m_nodeLabelComponent.setValue(getNodeLabel());
        m_changeButton.setCaption("Change Rrd graph");
        m_removeButton.setVisible(true);
    }
}
Also used : GraphContainer(org.opennms.features.vaadin.components.graph.GraphContainer) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar)

Example 3 with GraphContainer

use of org.opennms.features.vaadin.components.graph.GraphContainer in project opennms by OpenNMS.

the class SurveillanceViewGraphComponent method replaceGraph.

private void replaceGraph(String graphName, String resourceId) {
    m_graphLayout.removeAllComponents();
    if (graphName != null && resourceId != null) {
        final GraphContainer graph = new GraphContainer(graphName, resourceId);
        // Span the last hour
        final Calendar calendar = new GregorianCalendar();
        graph.setEnd(calendar.getTime());
        calendar.add(Calendar.HOUR_OF_DAY, -1);
        graph.setStart(calendar.getTime());
        // Use all of the available width
        graph.setWidthRatio(1.0d);
        // Use a smaller height ratio
        graph.setHeightRatio(0.2d);
        m_graphLayout.addComponent(graph);
    }
}
Also used : GraphContainer(org.opennms.features.vaadin.components.graph.GraphContainer) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar)

Example 4 with GraphContainer

use of org.opennms.features.vaadin.components.graph.GraphContainer 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)

Aggregations

GraphContainer (org.opennms.features.vaadin.components.graph.GraphContainer)4 Calendar (java.util.Calendar)3 GregorianCalendar (java.util.GregorianCalendar)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Label (com.vaadin.ui.Label)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1