Search in sources :

Example 1 with SlidingCategoryDataset

use of org.jfree.data.category.SlidingCategoryDataset in project VideoOptimzer by attdevsupport.

the class WaterfallPanel method refresh.

/**
 * Refreshes the waterfall display with the specified analysis data
 * @param Analyzed data from aro core.
 */
public void refresh(AROTraceData aModel) {
    this.data = aModel;
    this.popup.refresh(null, 0);
    this.popup.setVisible(false);
    // Create sorted list of request/response pairs
    categoryList = new ArrayList<WaterfallCategory>();
    if (aModel != null && aModel.getAnalyzerResult() != null) {
        this.traceDuration = aModel.getAnalyzerResult().getTraceresult().getTraceDuration();
        // add 20% to make sure labels close to the right edge of the screen are visible
        this.traceDuration *= 1.2;
        for (Session tcpSession : aModel.getAnalyzerResult().getSessionlist()) {
            Session thisSession = tcpSession;
            if (!tcpSession.isUdpOnly()) {
                for (HttpRequestResponseInfo reqResInfo : tcpSession.getRequestResponseInfo()) {
                    if (reqResInfo.getDirection() == HttpDirection.REQUEST && reqResInfo.getWaterfallInfos() != null) {
                        categoryList.add(new WaterfallCategory(reqResInfo, thisSession));
                    }
                }
            }
        }
        // Sort and set index
        Collections.sort(categoryList);
        int index = 0;
        for (WaterfallCategory wCategory : categoryList) {
            wCategory.setIndex(++index);
        }
    }
    // Horizontal scroll bar used to scroll through trace duration
    JScrollBar hScrollBar = getHorizontalScroll();
    hScrollBar.setMaximum((int) Math.ceil(this.traceDuration));
    CategoryAxis cAxis = getCategoryAxis();
    cAxis.clearCategoryLabelToolTips();
    DefaultCategoryDataset underlying = new DefaultCategoryDataset();
    for (WaterfallCategory wfc : categoryList) {
        RequestResponseTimeline rrTimeLine = wfc.getReqResp().getWaterfallInfos();
        underlying.addValue(rrTimeLine.getStartTime(), Waterfall.BEFORE, wfc);
        underlying.addValue(rrTimeLine.getDnsLookupDuration(), Waterfall.DNS_LOOKUP, wfc);
        underlying.addValue(rrTimeLine.getInitialConnDuration(), Waterfall.INITIAL_CONNECTION, wfc);
        underlying.addValue(rrTimeLine.getSslNegotiationDuration(), Waterfall.SSL_NEGOTIATION, wfc);
        underlying.addValue(rrTimeLine.getRequestDuration(), Waterfall.REQUEST_TIME, wfc);
        underlying.addValue(rrTimeLine.getTimeToFirstByte(), Waterfall.TIME_TO_FIRST_BYTE, wfc);
        underlying.addValue(rrTimeLine.getContentDownloadDuration(), Waterfall.CONTENT_DOWNLOAD, wfc);
        underlying.addValue(null, Waterfall.HTTP_3XX_REDIRECTION, wfc);
        underlying.addValue(null, Waterfall.HTTP_4XX_CLIENTERROR, wfc);
        int code = wfc.getReqResp().getAssocReqResp().getStatusCode();
        double endTime = this.traceDuration - rrTimeLine.getStartTime() - rrTimeLine.getTotalTime();
        if (code >= 300 && code < 400) {
            underlying.addValue(endTime, Waterfall.AFTER_3XX, wfc);
        } else if (code >= 400) {
            underlying.addValue(endTime, Waterfall.AFTER_4XX, wfc);
        } else {
            underlying.addValue(endTime, Waterfall.AFTER, wfc);
        }
        cAxis.addCategoryLabelToolTip(wfc, wfc.getTooltip());
    }
    // Vertical scroll bar is used to scroll through data
    JScrollBar vScrollBar = getVerticalScroll();
    int count = underlying.getColumnCount();
    vScrollBar.setValue(0);
    vScrollBar.setMaximum(count);
    vScrollBar.setVisibleAmount(count > 0 ? this.dataset.getMaximumCategoryCount() - 1 / count : 1);
    // Add the dataset to the plot
    CategoryPlot plot = getChartPanel().getChart().getCategoryPlot();
    this.dataset = new SlidingCategoryDataset(underlying, 0, CATEGORY_MAX_COUNT);
    plot.setDataset(this.dataset);
    // Set the visible time range
    setTimeRange(startGraphRange, startGraphRange + 100);
    // Place proper colors on renderer for waterfall states
    final CategoryItemRenderer renderer = plot.getRenderer();
    for (Object obj : underlying.getRowKeys()) {
        Waterfall wFall = (Waterfall) obj;
        int index = underlying.getRowIndex(wFall);
        Color paint;
        switch(wFall) {
            case DNS_LOOKUP:
                paint = dnsLoolupColor;
                break;
            case INITIAL_CONNECTION:
                paint = initiaConnColor;
                break;
            case SSL_NEGOTIATION:
                paint = sslNegColor;
                break;
            case REQUEST_TIME:
                paint = requestTimeColor;
                break;
            case TIME_TO_FIRST_BYTE:
                paint = firstByteTimeColor;
                break;
            case CONTENT_DOWNLOAD:
                paint = contentDownloadColor;
                break;
            case INACTIVE:
                paint = inactiveConnectionColor;
                break;
            case AFTER_3XX:
                paint = noneColor;
                renderer.setSeriesItemLabelPaint(index, threexColor);
                renderer.setSeriesVisibleInLegend(index, false);
                break;
            case AFTER_4XX:
                paint = noneColor;
                renderer.setSeriesItemLabelPaint(index, fourxColor);
                renderer.setSeriesVisibleInLegend(index, false);
                break;
            case HTTP_3XX_REDIRECTION:
                paint = threexColor;
                break;
            case HTTP_4XX_CLIENTERROR:
                paint = fourxColor;
                break;
            default:
                renderer.setSeriesItemLabelPaint(index, Color.black);
                renderer.setSeriesVisibleInLegend(index, false);
                paint = noneColor;
        }
        renderer.setSeriesPaint(index, paint);
    }
    // Adding the label at the end of bars
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator() {

        private static final long serialVersionUID = 1L;

        @Override
        public String generateLabel(CategoryDataset dataset, int row, int column) {
            if (Waterfall.AFTER == dataset.getRowKey(row) || Waterfall.AFTER_3XX == dataset.getRowKey(row) || Waterfall.AFTER_4XX == dataset.getRowKey(row)) {
                WaterfallCategory waterfallItem = (WaterfallCategory) dataset.getColumnKey(column);
                RequestResponseTimeline waterfallInfos = waterfallItem.getReqResp().getWaterfallInfos();
                DecimalFormat formatter = new DecimalFormat("#.##");
                int code = waterfallItem.getReqResp().getAssocReqResp().getStatusCode();
                return MessageFormat.format(getMessageString("waterfall.totalTime"), formatter.format(waterfallInfos.getTotalTime()), code > 0 ? waterfallItem.getReqResp().getScheme() + " " + code : getMessageString("waterfall.unknownCode"));
            }
            return null;
        }
    });
    new Thread(() -> setCrosshairs(aModel)).start();
}
Also used : StandardCategoryItemLabelGenerator(org.jfree.chart.labels.StandardCategoryItemLabelGenerator) RequestResponseTimeline(com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) Color(java.awt.Color) DecimalFormat(java.text.DecimalFormat) ResourceBundleHelper.getMessageString(com.att.aro.ui.utils.ResourceBundleHelper.getMessageString) CategoryPlot(org.jfree.chart.plot.CategoryPlot) SlidingCategoryDataset(org.jfree.data.category.SlidingCategoryDataset) JScrollBar(javax.swing.JScrollBar) CategoryAxis(org.jfree.chart.axis.CategoryAxis) SlidingCategoryDataset(org.jfree.data.category.SlidingCategoryDataset) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) WaterfallCategory(com.att.aro.ui.model.waterfall.WaterfallCategory) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 2 with SlidingCategoryDataset

use of org.jfree.data.category.SlidingCategoryDataset in project VideoOptimzer by attdevsupport.

the class WaterfallPanel method layoutDataPanel.

public JPanel layoutDataPanel() {
    this.setLayout(new BorderLayout());
    this.dataset = new SlidingCategoryDataset(new DefaultCategoryDataset(), 0, CATEGORY_MAX_COUNT);
    this.popup = new WaterfallPopup();
    JPanel graphPanel = new JPanel(new BorderLayout());
    graphPanel.add(getChartPanel(), BorderLayout.CENTER);
    graphPanel.add(getVerticalScroll(), BorderLayout.EAST);
    graphPanel.add(getHorizontalScroll(), BorderLayout.SOUTH);
    this.add(graphPanel, BorderLayout.CENTER);
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.add(getZoomInButton());
    buttonsPanel.add(getZoomOutButton());
    this.add(buttonsPanel, BorderLayout.SOUTH);
    return this;
}
Also used : TabPanelJPanel(com.att.aro.ui.commonui.TabPanelJPanel) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) SlidingCategoryDataset(org.jfree.data.category.SlidingCategoryDataset)

Example 3 with SlidingCategoryDataset

use of org.jfree.data.category.SlidingCategoryDataset in project tdq-studio-se by Talend.

the class TOPChartServiceTest method testClearDatasetForEncapsulationCumstomerDatasetCase.

/**
 * Test method for {@link org.talend.dataprofiler.chart.TOPChartService#clearDataset(java.lang.Object)}.
 */
@Test
public void testClearDatasetForEncapsulationCumstomerDatasetCase() {
    CustomerDefaultCategoryDataset customerDefaultCategoryDataset = new CustomerDefaultCategoryDataset();
    // $NON-NLS-1$ //$NON-NLS-2$
    customerDefaultCategoryDataset.addValue(100, "1", "id");
    ChartDataEntity chartDataEntity = new ChartDataEntity();
    customerDefaultCategoryDataset.addDataEntity(chartDataEntity);
    DefaultCategoryDataset defaultCategoryDataset = new DefaultCategoryDataset();
    // $NON-NLS-1$ //$NON-NLS-2$
    defaultCategoryDataset.addValue(100, "1", "id");
    SlidingCategoryDataset slidingCategoryDataset = new SlidingCategoryDataset(defaultCategoryDataset, 0, 1);
    EncapsulationCumstomerDataset encapsulationCumstomerDataset = new EncapsulationCumstomerDataset(slidingCategoryDataset, customerDefaultCategoryDataset);
    TOPChartService topService = new TOPChartService();
    topService.clearDataset(encapsulationCumstomerDataset);
    Assert.assertEquals(// $NON-NLS-1$
    "The count of defaultCategoryDataset should be clear", // $NON-NLS-1$
    0, defaultCategoryDataset.getRowCount());
    Assert.assertEquals(// $NON-NLS-1$
    "The count of customerDefaultCategoryDataset value should be clear", // $NON-NLS-1$
    0, ((DefaultCategoryDataset) customerDefaultCategoryDataset.getDataset()).getRowCount());
    Assert.assertEquals(// $NON-NLS-1$
    "The length of customerDefaultCategoryDataset entity should be clear", // $NON-NLS-1$
    0, customerDefaultCategoryDataset.getDataEntities().length);
}
Also used : EncapsulationCumstomerDataset(org.talend.dataprofiler.chart.util.EncapsulationCumstomerDataset) TOPChartService(org.talend.dataprofiler.chart.TOPChartService) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) CustomerDefaultCategoryDataset(org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CustomerDefaultCategoryDataset(org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset) SlidingCategoryDataset(org.jfree.data.category.SlidingCategoryDataset) Test(org.junit.Test)

Example 4 with SlidingCategoryDataset

use of org.jfree.data.category.SlidingCategoryDataset in project tdq-studio-se by Talend.

the class TopChartFactory method createBarChartByECD.

/**
 * create bar chart.
 *
 * @param titile
 * @param dataset
 * @return
 */
public static JFreeChart createBarChartByECD(String title, Object eCDataset) {
    EncapsulationCumstomerDataset ecd = (EncapsulationCumstomerDataset) eCDataset;
    // ADD msjian TDQ-5112 2012-4-10: after upgrate to jfreechart-1.0.12.jar, change the default chart wallPaint
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    // TDQ-13378 add to vertical scroll bar. the scroll bar will be visible when the count >10
    SlidingCategoryDataset slideDataset = (SlidingCategoryDataset) ecd.getDataset();
    Object cusmomerDataset = ecd.getCusmomerDataset();
    // TDQ-5112~
    JFreeChart createBarChart = ChartFactory.createBarChart(// $NON-NLS-1$
    null, // $NON-NLS-1$
    Messages.getString("TopChartFactory.Value"), // $NON-NLS-1$
    title, // $NON-NLS-1$
    slideDataset, PlotOrientation.HORIZONTAL, false, false, false);
    CategoryPlot plot = createBarChart.getCategoryPlot();
    if (cusmomerDataset != null) {
        plot.setDataset(1, new EncapsulationCumstomerDataset(slideDataset, cusmomerDataset));
    }
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelPaint(NULL_FIELD, Color.RED);
    domainAxis.setTickLabelPaint(NULL_FIELD2, Color.RED);
    domainAxis.setTickLabelPaint(EMPTY_FIELD, Color.RED);
    // ADD TDQ-5251 msjian 2012-7-31: do not display the shadow
    BarRenderer renderer = new TalendBarRenderer(false, ChartDecorator.COLOR_LIST);
    renderer.setShadowVisible(false);
    // TDQ-5251~
    plot.setRenderer(renderer);
    return createBarChart;
}
Also used : CategoryAxis(org.jfree.chart.axis.CategoryAxis) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) StackedBarRenderer(org.jfree.chart.renderer.category.StackedBarRenderer) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) TalendBarRenderer(org.talend.dataprofiler.chart.TalendBarRenderer) TalendBarRenderer(org.talend.dataprofiler.chart.TalendBarRenderer) SlidingCategoryDataset(org.jfree.data.category.SlidingCategoryDataset) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Example 5 with SlidingCategoryDataset

use of org.jfree.data.category.SlidingCategoryDataset in project tdq-studio-se by Talend.

the class TOPChartService method addValueToLastTimeCategoryDataset.

/*
     * (non-Javadoc)
     *
     * @see org.talend.dataprofiler.service.ITOPChartService#addValueToLastTimeCategoryDataset(double, java.lang.String,
     * java.lang.String)
     */
@Override
public void addValueToLastTimeCategoryDataset(Object dataset, double value, String labelX, String labelY) {
    try {
        if (dataset instanceof EncapsulationCumstomerDataset) {
            EncapsulationCumstomerDataset ecDataset = ((EncapsulationCumstomerDataset) dataset);
            CategoryDataset underlyingDataset = ((SlidingCategoryDataset) ecDataset.getDataset()).getUnderlyingDataset();
            if (underlyingDataset instanceof DefaultCategoryDataset) {
                ((DefaultCategoryDataset) underlyingDataset).addValue(value, labelX, labelY);
            }
        }
    } catch (Exception e) {
        log.error(e, e);
    }
}
Also used : EncapsulationCumstomerDataset(org.talend.dataprofiler.chart.util.EncapsulationCumstomerDataset) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) SlidingCategoryDataset(org.jfree.data.category.SlidingCategoryDataset) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) BoxAndWhiskerCategoryDataset(org.jfree.data.statistics.BoxAndWhiskerCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) CustomerDefaultCategoryDataset(org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CustomerDefaultCategoryDataset(org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset) SlidingCategoryDataset(org.jfree.data.category.SlidingCategoryDataset) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

SlidingCategoryDataset (org.jfree.data.category.SlidingCategoryDataset)8 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)5 CategoryDataset (org.jfree.data.category.CategoryDataset)4 CategoryAxis (org.jfree.chart.axis.CategoryAxis)3 CategoryPlot (org.jfree.chart.plot.CategoryPlot)3 EncapsulationCumstomerDataset (org.talend.dataprofiler.chart.util.EncapsulationCumstomerDataset)3 CustomerDefaultCategoryDataset (org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 JFreeChart (org.jfree.chart.JFreeChart)2 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)2 StackedBarRenderer (org.jfree.chart.renderer.category.StackedBarRenderer)2 XYBarRenderer (org.jfree.chart.renderer.xy.XYBarRenderer)2 BoxAndWhiskerCategoryDataset (org.jfree.data.statistics.BoxAndWhiskerCategoryDataset)2 DefaultBoxAndWhiskerCategoryDataset (org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset)2 TalendBarRenderer (org.talend.dataprofiler.chart.TalendBarRenderer)2 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)1 RequestResponseTimeline (com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline)1 Session (com.att.aro.core.packetanalysis.pojo.Session)1 TabPanelJPanel (com.att.aro.ui.commonui.TabPanelJPanel)1 WaterfallCategory (com.att.aro.ui.model.waterfall.WaterfallCategory)1