@Override public void clear() { windowHandler.clear(); overviewHandler.clear(); lastDataPoint = null; firstDataPoint = null; lockSelection = false; }
private double getWindowMinX() { double x = selection[0]; if (x == overviewHandler.getData().getX(0)) { return firstDataPoint.getX(); } return x; }
void populateWindowSeries(final Command toExcuteAfterSelection) { final double x1 = getWindowMinX(); final double x2 = getWindowMaxX(); windowHandler.clear(); if (x1 < x2) { provider.getData( x1, x2, new AsyncCallback<SeriesData>() { @Override public void onFailure(Throwable caught) { GWT.log("Failed to obtain data for PlotWithOverview", caught); if (toExcuteAfterSelection != null) { toExcuteAfterSelection.execute(); } } @Override public void onSuccess(SeriesData result) { for (int i = 0; i < result.length(); i++) { windowHandler.add(result.get(i)); } lockSelection = x2 >= lastDataPoint.getX(); if (toExcuteAfterSelection != null) { toExcuteAfterSelection.execute(); } } }); } }
private double getWindowMaxX() { double x = selection[1]; SeriesData data = overviewHandler.getData(); int size = data.length(); if (size > 0 && x == data.getX(size - 1)) { return lastDataPoint.getX(); } return x; }
@Override public void add(DataPoint datapoint) { overviewHandler.add(datapoint); if (lockSelection && selection[1] < datapoint.getX()) { double diff = datapoint.getX() - lastDataPoint.getX(); double x1 = selection[0] + diff; double x2 = selection[1] + diff; setSelection(Math.max(x1, selection[0]), Math.max(x2, selection[1])); } if (firstDataPoint == null) { firstDataPoint = datapoint; } lastDataPoint = datapoint; }
private void renderPlots( HTMLPanel panel, List<PlotSeriesDto> plotSeriesDtoList, String id, double yMinimum, boolean isMetric) { panel.add(loadIndicator); SimplePlot redrawingPlot = null; VerticalPanel plotGroupPanel = new VerticalPanel(); plotGroupPanel.setWidth("100%"); plotGroupPanel.getElement().setId(id); for (PlotSeriesDto plotSeriesDto : plotSeriesDtoList) { Markings markings = null; if (plotSeriesDto.getMarkingSeries() != null) { markings = new Markings(); for (MarkingDto plotDatasetDto : plotSeriesDto.getMarkingSeries()) { double x = plotDatasetDto.getValue(); markings.addMarking( new Marking() .setX(new Range(x, x)) .setLineWidth(1) .setColor(plotDatasetDto.getColor())); } markingsMap.put(id, new TreeSet<MarkingDto>(plotSeriesDto.getMarkingSeries())); } final SimplePlot plot = createPlot(id, markings, plotSeriesDto.getXAxisLabel(), yMinimum, isMetric); redrawingPlot = plot; PlotModel plotModel = plot.getModel(); for (PlotDatasetDto plotDatasetDto : plotSeriesDto.getPlotSeries()) { SeriesHandler handler = plotModel.addSeries(plotDatasetDto.getLegend(), plotDatasetDto.getColor()); // Populate plot with data for (PointDto pointDto : plotDatasetDto.getPlotData()) { handler.add(new DataPoint(pointDto.getX(), pointDto.getY())); } } // Add X axis label Label xLabel = new Label(plotSeriesDto.getXAxisLabel()); xLabel.addStyleName(getResources().css().xAxisLabel()); Label plotHeader = new Label(plotSeriesDto.getPlotHeader()); plotHeader.addStyleName(getResources().css().plotHeader()); Label plotLegend = new Label("PLOT LEGEND"); plotLegend.addStyleName(getResources().css().plotLegend()); VerticalPanel vp = new VerticalPanel(); vp.setWidth("100%"); Label panLeftLabel = new Label(); panLeftLabel.addStyleName(getResources().css().panLabel()); panLeftLabel.getElement().appendChild(new Image(getResources().getArrowLeft()).getElement()); panLeftLabel.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { plot.pan(new Pan().setLeft(-100)); } }); Label panRightLabel = new Label(); panRightLabel.addStyleName(getResources().css().panLabel()); panRightLabel .getElement() .appendChild(new Image(getResources().getArrowRight()).getElement()); panRightLabel.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { plot.pan(new Pan().setLeft(100)); } }); Label zoomInLabel = new Label("Zoom In"); zoomInLabel.addStyleName(getResources().css().zoomLabel()); zoomInLabel.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { plot.zoom(); } }); Label zoomOutLabel = new Label("Zoom Out"); zoomOutLabel.addStyleName(getResources().css().zoomLabel()); zoomOutLabel.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { plot.zoomOut(); } }); FlowPanel zoomPanel = new FlowPanel(); zoomPanel.addStyleName(getResources().css().zoomPanel()); zoomPanel.add(panLeftLabel); zoomPanel.add(panRightLabel); zoomPanel.add(zoomInLabel); zoomPanel.add(zoomOutLabel); vp.add(plotHeader); vp.add(zoomPanel); vp.add(plot); vp.add(xLabel); // Will be added if there is need it // vp.add(plotLegend); plotGroupPanel.add(vp); } int loadingId = panel.getWidgetCount() - 1; panel.remove(loadingId); panel.add(plotGroupPanel); // Redraw plot if (redrawingPlot != null) { redrawingPlot.redraw(); } }
@Override public void setVisible(boolean visisble) { overviewHandler.setVisible(visisble); windowHandler.setVisible(visisble); }
@Override public void setData(SeriesData newData) { overviewHandler.setData(newData); windowHandler.clear(); }
@Override public boolean isVisible() { return overviewHandler.isVisible(); }
@Override public SeriesData getData() { return overviewHandler.getData(); }
public Series getWindowSeries() { return windowHandler.getSeries(); }
public Series getOverviewSeries() { return overviewHandler.getSeries(); }