List of usage examples for org.jfree.chart.title ShortTextTitle ShortTextTitle
public ShortTextTitle(String text)
From source file:org.datacleaner.widgets.result.UniqueKeyCheckAnalyzerResultSwingRenderer.java
@Override public JComponent render(UniqueKeyCheckAnalyzerResult result) { final int nullCount = result.getNullCount(); final int nonUniqueCount = result.getNonUniqueCount(); final DefaultKeyedValues keyedValues = new DefaultKeyedValues(); keyedValues.addValue("Unique keys", result.getUniqueCount()); final List<Title> subTitles = new ArrayList<Title>(); subTitles.add(new ShortTextTitle("Row count: " + result.getRowCount())); subTitles.add(new ShortTextTitle("Unique key count: " + result.getUniqueCount())); if (nonUniqueCount > 0) { keyedValues.addValue("Non-unique keys", nonUniqueCount); subTitles.add(new ShortTextTitle("Non-unique key count: " + nonUniqueCount)); }//from www . j av a 2s .c o m final String title; if (nullCount == 0) { title = "Unique and non-unique keys"; } else { keyedValues.addValue(LabelUtils.NULL_LABEL, nullCount); title = "Unique, non-unique and <null> keys"; subTitles.add(new ShortTextTitle("<null> key count: " + result.getNullCount())); } final DefaultPieDataset dataset = new DefaultPieDataset(keyedValues); final JFreeChart chart = ChartFactory.createRingChart(title, dataset, true, true, false); chart.setSubtitles(subTitles); ChartUtils.applyStyles(chart); ChartPanel chartPanel = ChartUtils.createPanel(chart, false); final DCPanel leftPanel = new DCPanel(); leftPanel.setLayout(new VerticalLayout()); leftPanel.add(WidgetUtils.decorateWithShadow(chartPanel)); final Map<String, Integer> samples = result.getNonUniqueSamples(); if (samples == null || samples.isEmpty()) { return leftPanel; } final DefaultTableModel samplesTableModel = new DefaultTableModel(new String[] { "Key", "Count" }, 0); for (final Entry<String, Integer> entry : samples.entrySet()) { final String key = entry.getKey(); final Integer count = entry.getValue(); samplesTableModel.addRow(new Object[] { key, count }); } final DCTable samplesTable = new DCTable(samplesTableModel); final DCPanel rightPanel = new DCPanel(); rightPanel.setLayout(new BorderLayout()); rightPanel.add(DCLabel.dark("Sample non-unique keys:")); rightPanel.add(samplesTable.toPanel(), BorderLayout.CENTER); final JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.setOpaque(false); split.add(leftPanel); split.add(rightPanel); split.setDividerLocation(550); return split; }
From source file:org.eobjects.datacleaner.widgets.result.UniqueKeyCheckAnalyzerResultSwingRenderer.java
@Override public JComponent render(UniqueKeyCheckAnalyzerResult result) { final int nullCount = result.getNullCount(); final int nonUniqueCount = result.getNonUniqueCount(); final DefaultKeyedValues keyedValues = new DefaultKeyedValues(); keyedValues.addValue("Unique keys", result.getUniqueCount()); final List<Title> subTitles = new ArrayList<Title>(); subTitles.add(new ShortTextTitle("Row count: " + result.getRowCount())); subTitles.add(new ShortTextTitle("Unique key count: " + result.getUniqueCount())); if (nonUniqueCount > 0) { keyedValues.addValue("Non-unique keys", nonUniqueCount); subTitles.add(new ShortTextTitle("Non-unique key count: " + nonUniqueCount)); }/* w w w. ja v a 2 s . c o m*/ final String title; if (nullCount == 0) { title = "Unique and non-unique keys"; } else { keyedValues.addValue(LabelUtils.NULL_LABEL, nullCount); title = "Unique, non-unique and <null> keys"; subTitles.add(new ShortTextTitle("<null> key count: " + result.getNullCount())); } final DefaultPieDataset dataset = new DefaultPieDataset(keyedValues); final JFreeChart chart = ChartFactory.createRingChart(title, dataset, true, true, false); chart.setSubtitles(subTitles); ChartUtils.applyStyles(chart); ChartPanel chartPanel = new ChartPanel(chart); final DCPanel leftPanel = new DCPanel(); leftPanel.setLayout(new VerticalLayout()); leftPanel.add(WidgetUtils.decorateWithShadow(chartPanel, true, 4)); final Map<String, Integer> samples = result.getNonUniqueSamples(); if (samples == null || samples.isEmpty()) { return leftPanel; } final DefaultTableModel samplesTableModel = new DefaultTableModel(new String[] { "Key", "Count" }, 0); for (final Entry<String, Integer> entry : samples.entrySet()) { final String key = entry.getKey(); final Integer count = entry.getValue(); samplesTableModel.addRow(new Object[] { key, count }); } final DCTable samplesTable = new DCTable(samplesTableModel); final DCPanel rightPanel = new DCPanel(); rightPanel.setLayout(new BorderLayout()); rightPanel.add(DCLabel.dark("Sample non-unique keys:")); rightPanel.add(samplesTable.toPanel(), BorderLayout.CENTER); final JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.setOpaque(false); split.add(leftPanel); split.add(rightPanel); split.setDividerLocation(550); return split; }
From source file:org.apache.qpid.disttest.charting.chartbuilder.BaseChartBuilder.java
private void addSubtitle(JFreeChart chart, ChartingDefinition chartingDefinition) { if (chartingDefinition.getChartSubtitle() != null) { chart.addSubtitle(new ShortTextTitle(chartingDefinition.getChartSubtitle())); }//from w w w . ja v a 2 s . c o m }
From source file:org.eobjects.datacleaner.widgets.result.ValueDistributionResultSwingRendererGroupDelegate.java
public JSplitPane renderGroupResult(final ValueCountingAnalyzerResult result) { final Integer distinctCount = result.getDistinctCount(); final Integer unexpectedValueCount = result.getUnexpectedValueCount(); final int totalCount = result.getTotalCount(); _valueCounts = result.getReducedValueFrequencies(_preferredSlices); for (ValueFrequency valueCount : _valueCounts) { setDataSetValue(valueCount.getName(), valueCount.getCount()); }/*from w w w. java 2 s . co m*/ logger.info("Rendering with {} slices", getDataSetItemCount()); drillToOverview(result); // chart for display of the dataset String title = "Value distribution of " + _groupOrColumnName; final JFreeChart chart = ChartFactory.createBarChart(title, "Value", "Count", _dataset, PlotOrientation.HORIZONTAL, true, true, false); List<Title> titles = new ArrayList<Title>(); titles.add(new ShortTextTitle("Total count: " + totalCount)); if (distinctCount != null) { titles.add(new ShortTextTitle("Distinct count: " + distinctCount)); } if (unexpectedValueCount != null) { titles.add(new ShortTextTitle("Unexpected value count: " + unexpectedValueCount)); } chart.setSubtitles(titles); ChartUtils.applyStyles(chart); // code-block for tweaking style and coloring of chart { final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.getDomainAxis().setVisible(false); int colorIndex = 0; for (int i = 0; i < getDataSetItemCount(); i++) { final String key = getDataSetKey(i); final Color color; final String upperCaseKey = key.toUpperCase(); if (_valueColorMap.containsKey(upperCaseKey)) { color = _valueColorMap.get(upperCaseKey); } else { if (i == getDataSetItemCount() - 1) { // the last color should not be the same as the first if (colorIndex == 0) { colorIndex++; } } Color colorCandidate = SLICE_COLORS[colorIndex]; int darkAmount = i / SLICE_COLORS.length; for (int j = 0; j < darkAmount; j++) { colorCandidate = WidgetUtils.slightlyDarker(colorCandidate); } color = colorCandidate; colorIndex++; if (colorIndex >= SLICE_COLORS.length) { colorIndex = 0; } } plot.getRenderer().setSeriesPaint(i, color); } } final ChartPanel chartPanel = new ChartPanel(chart); // chartPanel.addChartMouseListener(new ChartMouseListener() { // // @Override // public void chartMouseMoved(ChartMouseEvent event) { // ChartEntity entity = event.getEntity(); // if (entity instanceof PieSectionEntity) { // PieSectionEntity pieSectionEntity = (PieSectionEntity) entity; // String sectionKey = (String) pieSectionEntity.getSectionKey(); // if (_groups.containsKey(sectionKey)) { // chartPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); // } else { // chartPanel.setCursor(Cursor.getDefaultCursor()); // } // } else { // chartPanel.setCursor(Cursor.getDefaultCursor()); // } // } // // @Override // public void chartMouseClicked(ChartMouseEvent event) { // ChartEntity entity = event.getEntity(); // if (entity instanceof PieSectionEntity) { // PieSectionEntity pieSectionEntity = (PieSectionEntity) entity; // String sectionKey = (String) pieSectionEntity.getSectionKey(); // if (_groups.containsKey(sectionKey)) { // drillToGroup(result, sectionKey, true); // } // } // } // }); final DCPanel leftPanel = new DCPanel(); leftPanel.setLayout(new VerticalLayout()); leftPanel.add(WidgetUtils.decorateWithShadow(chartPanel, true, 4)); _backButton.setMargin(new Insets(0, 0, 0, 0)); _backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { drillToOverview(result); } }); final DCPanel rightPanel = new DCPanel(); rightPanel.setLayout(new BorderLayout()); rightPanel.add(_backButton, BorderLayout.NORTH); rightPanel.add(_table.toPanel(), BorderLayout.CENTER); final JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.setOpaque(false); split.add(leftPanel); split.add(rightPanel); split.setDividerLocation(550); return split; }
From source file:org.datacleaner.widgets.result.ValueDistributionResultSwingRendererGroupDelegate.java
public JSplitPane renderGroupResult(final ValueCountingAnalyzerResult result) { final Integer distinctCount = result.getDistinctCount(); final Integer unexpectedValueCount = result.getUnexpectedValueCount(); final int totalCount = result.getTotalCount(); _valueCounts = result.getReducedValueFrequencies(_preferredSlices); _valueCounts = moveUniqueToEnd(_valueCounts); for (ValueFrequency valueCount : _valueCounts) { setDataSetValue(valueCount.getName(), valueCount.getCount()); }/*from ww w. j a v a 2s. co m*/ logger.info("Rendering with {} slices", getDataSetItemCount()); drillToOverview(result); // chart for display of the dataset String title = "Value distribution of " + _groupOrColumnName; final JFreeChart chart = ChartFactory.createBarChart(title, "Value", "Count", _dataset, PlotOrientation.HORIZONTAL, true, true, false); List<Title> titles = new ArrayList<Title>(); titles.add(new ShortTextTitle("Total count: " + totalCount)); if (distinctCount != null) { titles.add(new ShortTextTitle("Distinct count: " + distinctCount)); } if (unexpectedValueCount != null) { titles.add(new ShortTextTitle("Unexpected value count: " + unexpectedValueCount)); } chart.setSubtitles(titles); ChartUtils.applyStyles(chart); // code-block for tweaking style and coloring of chart { final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.getDomainAxis().setVisible(false); int colorIndex = 0; for (int i = 0; i < getDataSetItemCount(); i++) { final String key = getDataSetKey(i); final Color color; final String upperCaseKey = key.toUpperCase(); if (_valueColorMap.containsKey(upperCaseKey)) { color = _valueColorMap.get(upperCaseKey); } else { if (i == getDataSetItemCount() - 1) { // the last color should not be the same as the first if (colorIndex == 0) { colorIndex++; } } Color colorCandidate = SLICE_COLORS[colorIndex]; int darkAmount = i / SLICE_COLORS.length; for (int j = 0; j < darkAmount; j++) { colorCandidate = WidgetUtils.slightlyDarker(colorCandidate); } color = colorCandidate; colorIndex++; if (colorIndex >= SLICE_COLORS.length) { colorIndex = 0; } } plot.getRenderer().setSeriesPaint(i, color); } } final ChartPanel chartPanel = ChartUtils.createPanel(chart, false); final DCPanel leftPanel = new DCPanel(); leftPanel.setLayout(new VerticalLayout()); leftPanel.add(WidgetUtils.decorateWithShadow(chartPanel)); _backButton.setMargin(new Insets(0, 0, 0, 0)); _backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { drillToOverview(result); } }); _rightPanel.setLayout(new VerticalLayout()); _rightPanel.add(_backButton); _rightPanel.add(WidgetUtils.decorateWithShadow(_table.toPanel())); final JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.setOpaque(false); split.add(leftPanel); split.add(_rightPanel); split.setDividerLocation(550); return split; }
From source file:org.martus.client.swingui.actions.ActionMenuCharts.java
private JFreeChart createChart(ChartAnswers answers, MiniFieldSpec fieldToCount, HashMap<String, Integer> counts) throws Exception, TokenInvalidException { String selectedFieldLabel = fieldToCount.getLabel(); if (selectedFieldLabel.equals("")) selectedFieldLabel = getLocalization().getFieldLabel(fieldToCount.getTag()); JFreeChart chart = createRawChart(answers, counts, selectedFieldLabel); new MartusChartTheme().apply(chart); TextTitle subtitle = new TextTitle(answers.getSubtitle()); subtitle.setFont(FontHandler.getDefaultFont()); chart.addSubtitle(subtitle);/*from www. j a v a 2s . com*/ chart.addSubtitle(createLegend(chart)); String today = getLocalization().formatDateTime(new Date().getTime()); String chartCreatedOnLabel = getLocalization().getFieldLabel("ChartCreatedOn"); chartCreatedOnLabel = TokenReplacement.replaceToken(chartCreatedOnLabel, "#Date#", today); chart.addSubtitle(new ShortTextTitle(chartCreatedOnLabel)); return chart; }