Search in sources :

Example 1 with FileTypeSummary

use of com.att.aro.ui.model.overview.FileTypeSummary in project VideoOptimzer by attdevsupport.

the class FileTypesChartPanel method generateDataForChart.

/**
 * Creates the FilTypes list to be plotted on the chart.
 * @return
 */
private void generateDataForChart() {
    Map<String, FileTypeSummary> content = new HashMap<String, FileTypeSummary>();
    int totalContentLength = 0;
    if (traceDataModel != null && traceDataModel.getAnalyzerResult() != null) {
        for (Session tcp : traceDataModel.getAnalyzerResult().getSessionlist()) {
            if (!tcp.isUdpOnly()) {
                for (HttpRequestResponseInfo info : tcp.getRequestResponseInfo()) {
                    if (HttpDirection.RESPONSE.equals(info.getDirection())) {
                        long contentLength = info.getContentLength();
                        if (contentLength > 0) {
                            String contentType = info.getContentType();
                            if (contentType == null || contentType.isEmpty()) {
                                contentType = ResourceBundleHelper.getMessageString("chart.filetype.unknown");
                            }
                            FileTypeSummary summary = content.get(contentType);
                            if (summary == null) {
                                summary = new FileTypeSummary(contentType);
                                content.put(contentType, summary);
                            }
                            // summary.bytes += contentLength;
                            summary.setBytes(summary.getBytes() + contentLength);
                            totalContentLength += contentLength;
                        }
                    }
                }
            }
        }
    }
    List<FileTypeSummary> result = new ArrayList<FileTypeSummary>(content.values());
    Collections.sort(result);
    if (result.size() > MAX_LIMIT_FILETYPES) {
        long otherValuesTotal = 0;
        Iterator<FileTypeSummary> iterator = result.iterator();
        for (int index = 0; index < (MAX_LIMIT_FILETYPES - 1); index++) {
            iterator.next();
        }
        while (iterator.hasNext()) {
            otherValuesTotal += iterator.next().getBytes();
            iterator.remove();
        }
        FileTypeSummary other = new FileTypeSummary(ResourceBundleHelper.getMessageString("chart.filetype.others"));
        other.setBytes(otherValuesTotal);
        result.add(other);
        // Sort again
        Collections.sort(result);
    }
    for (FileTypeSummary summary : result) {
        summary.setPct((double) summary.getBytes() / totalContentLength * 100.0);
    }
    this.setFileTypeContent(result);
}
Also used : HashMap(java.util.HashMap) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) FileTypeSummary(com.att.aro.ui.model.overview.FileTypeSummary) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 2 with FileTypeSummary

use of com.att.aro.ui.model.overview.FileTypeSummary in project VideoOptimzer by attdevsupport.

the class FileTypesChartPanel method initializeChart.

private JFreeChart initializeChart() {
    JFreeChart chart = ChartFactory.createBarChart(ResourceBundleHelper.getMessageString("chart.filetype.title"), null, ResourceBundleHelper.getMessageString("simple.percent"), null, PlotOrientation.HORIZONTAL, false, false, false);
    // chart.setBackgroundPaint(fileTypePanel.getBackground());
    chart.setBackgroundPaint(this.getBackground());
    chart.getTitle().setFont(AROUIManager.HEADER_FONT);
    this.cPlot = chart.getCategoryPlot();
    cPlot.setBackgroundPaint(Color.white);
    cPlot.setDomainGridlinePaint(Color.gray);
    cPlot.setRangeGridlinePaint(Color.gray);
    cPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    CategoryAxis domainAxis = cPlot.getDomainAxis();
    domainAxis.setMaximumCategoryLabelWidthRatio(.5f);
    domainAxis.setLabelFont(AROUIManager.LABEL_FONT);
    domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT);
    NumberAxis rangeAxis = (NumberAxis) cPlot.getRangeAxis();
    rangeAxis.setRange(0.0, 100.0);
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);
    BarRenderer renderer = new StackedBarRenderer();
    renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBaseItemLabelGenerator(new PercentLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelPaint(Color.black);
    // Make second bar in stack invisible
    renderer.setSeriesItemLabelsVisible(1, false);
    renderer.setSeriesPaint(1, new Color(0, 0, 0, 0));
    renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {

        @Override
        public String generateToolTip(CategoryDataset dataset, int row, int column) {
            FileTypeSummary summary = fileTypeContent.get(column);
            return MessageFormat.format(ResourceBundleHelper.getMessageString("chart.filetype.tooltip"), NumberFormat.getIntegerInstance().format(summary.getBytes()));
        }
    });
    ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT);
    renderer.setBasePositiveItemLabelPosition(insideItemlabelposition);
    ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT);
    renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition);
    BarPainter painter = new StandardBarPainter();
    renderer.setBarPainter(painter);
    renderer.setShadowVisible(false);
    renderer.setMaximumBarWidth(0.1);
    cPlot.setRenderer(renderer);
    cPlot.getDomainAxis().setMaximumCategoryLabelLines(2);
    return chart;
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) StackedBarRenderer(org.jfree.chart.renderer.category.StackedBarRenderer) Color(java.awt.Color) StackedBarRenderer(org.jfree.chart.renderer.category.StackedBarRenderer) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) FileTypeSummary(com.att.aro.ui.model.overview.FileTypeSummary) JFreeChart(org.jfree.chart.JFreeChart) NumberTickUnit(org.jfree.chart.axis.NumberTickUnit) StandardBarPainter(org.jfree.chart.renderer.category.StandardBarPainter) BarPainter(org.jfree.chart.renderer.category.BarPainter) CategoryAxis(org.jfree.chart.axis.CategoryAxis) CategoryToolTipGenerator(org.jfree.chart.labels.CategoryToolTipGenerator) CategoryDataset(org.jfree.data.category.CategoryDataset) StandardBarPainter(org.jfree.chart.renderer.category.StandardBarPainter) ItemLabelPosition(org.jfree.chart.labels.ItemLabelPosition)

Example 3 with FileTypeSummary

use of com.att.aro.ui.model.overview.FileTypeSummary in project VideoOptimzer by attdevsupport.

the class FileTypesChartPanel method setAnalysisDataToPlot.

/**
 * Sets the trace analysis data used for calculating the plot data for the
 * chart.
 */
public void setAnalysisDataToPlot() {
    if (fileTypeContent == null) {
        cPlot.setDataset(null);
    } else {
        double[][] data = new double[2][fileTypeContent.size()];
        String[] titles = new String[fileTypeContent.size()];
        for (int i = 0; i < fileTypeContent.size(); ++i) {
            FileTypeSummary summary = fileTypeContent.get(i);
            String key = summary.getFileType();
            titles[i] = key;
            data[0][i] = summary.getPct();
            data[1][i] = 100.0 - summary.getPct();
        }
        cPlot.setDataset(DatasetUtilities.createCategoryDataset(new Integer[] { 1, 2 }, titles, data));
    }
}
Also used : FileTypeSummary(com.att.aro.ui.model.overview.FileTypeSummary)

Aggregations

FileTypeSummary (com.att.aro.ui.model.overview.FileTypeSummary)3 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)1 Session (com.att.aro.core.packetanalysis.pojo.Session)1 Color (java.awt.Color)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 JFreeChart (org.jfree.chart.JFreeChart)1 CategoryAxis (org.jfree.chart.axis.CategoryAxis)1 NumberAxis (org.jfree.chart.axis.NumberAxis)1 NumberTickUnit (org.jfree.chart.axis.NumberTickUnit)1 CategoryToolTipGenerator (org.jfree.chart.labels.CategoryToolTipGenerator)1 ItemLabelPosition (org.jfree.chart.labels.ItemLabelPosition)1 BarPainter (org.jfree.chart.renderer.category.BarPainter)1 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)1 StackedBarRenderer (org.jfree.chart.renderer.category.StackedBarRenderer)1 StandardBarPainter (org.jfree.chart.renderer.category.StandardBarPainter)1 CategoryDataset (org.jfree.data.category.CategoryDataset)1