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);
}
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;
}
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));
}
}
Aggregations