本文整理匯總了Java中org.jfree.chart.ChartFactory類的典型用法代碼示例。如果您正苦於以下問題:Java ChartFactory類的具體用法?Java ChartFactory怎麽用?Java ChartFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ChartFactory類屬於org.jfree.chart包,在下文中一共展示了ChartFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeRankVSScore
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
public static void writeRankVSScore(File outputFile, List<SimilarityMatrix> matrices, int length, String add) throws Exception{
final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
for(SimilarityMatrix m:matrices){
int[][] sortedIndizes=m.getIndizesOfSortedScores();
List<Double>[] scoreList=new List[Math.min(length,sortedIndizes[0].length)];
for(int i=0;i<scoreList.length;i++)scoreList[i]=new ArrayList<Double>();
for(int i=0;i<sortedIndizes.length;i++){
int l=0;
for(int j=0;j<sortedIndizes[i].length;j++){
double v=m.getSimilarityValue(i,sortedIndizes[i][j]);
if(!Double.isNaN(v)){
scoreList[l].add(v);
l++;
}
if(l>=scoreList.length)break;
}
}
for(int i=0;i<scoreList.length;i++)
dataset.add(scoreList[i], m.getMethodsQueryAndDBString(), i);
}
JFreeChart chart=ChartFactory.createBoxAndWhiskerChart("Whiskerplot", "Ranks", "Scores", dataset, true);
ChartUtilities.saveChartAsJPEG(new File(outputFile.getPath()+sep+add+"RankVSScore_"+getMethodsQueryStringFromList(matrices)+".jpg"), chart, Math.min(2000,length*100), 1000);
}
示例2: createChartCategory
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
/**
* Creates a sample chart for the given dataset.
*
* @param dataset
* the dataset.
*
* @return A sample chart.
*/
private JFreeChart createChartCategory(final CategoryDataset dataset) {
final JFreeChart chart = ChartFactory.createMultiplePieChart3D("Multiple Pie Chart Demo 4", dataset,
TableOrder.BY_COLUMN, false, true, false);
chart.setBackgroundPaint(new Color(216, 255, 216));
final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
final JFreeChart subchart = plot.getPieChart();
// final StandardLegend legend = new StandardLegend();
// legend.setItemFont(new Font("SansSerif", Font.PLAIN, 8));
// legend.setAnchor(Legend.SOUTH);
// subchart.setLegend(legend);
plot.setLimit(0.10);
final PiePlot p = (PiePlot) subchart.getPlot();
// p.setLabelGenerator(new StandardPieItemLabelGenerator("{0}"));
p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
p.setInteriorGap(0.30);
return chart;
}
示例3: testFindDomainBounds
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
/**
* Check that the renderer is calculating the domain bounds correctly.
*/
public void testFindDomainBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset,
PlotOrientation.VERTICAL, false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StackedXYBarRenderer());
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
Range bounds = domainAxis.getRange();
assertFalse(bounds.contains(0.3));
assertTrue(bounds.contains(0.5));
assertTrue(bounds.contains(2.5));
assertFalse(bounds.contains(2.8));
}
示例4: testDrawWithEmptyDataset
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
/**
* Test chart drawing with an empty dataset to ensure that this special
* case doesn't cause any exceptions.
*/
public void testDrawWithEmptyDataset() {
boolean success = false;
JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
"y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
true, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StackedXYAreaRenderer2());
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
success = true;
}
catch (Exception e) {
success = false;
}
assertTrue(success);
}
示例5: linePlot
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
public JFreeChart linePlot(String xLabel, String yLabel){
int numDatasets = dataset.size();
JFreeChart result = ChartFactory.createXYLineChart(
chartTitle, // chart title
xLabel, // x axis label
yLabel, // y axis label
dataset.get(0), // data
PlotOrientation.VERTICAL,
true, // include legend
true, // tooltips
false // urls
);
XYPlot plot = result.getXYPlot();
plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer().setSeriesPaint(0, seriesColor.get(0));
for(int i=1;i<numDatasets;i++){
plot.setDataset(i,dataset.get(i));
//XYItemRenderer renderer = plot.getRenderer(i-0);
//plot.setRenderer(i, new XYLineAndShapeRenderer(false, true));
plot.getRenderer(i).setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer(i).setSeriesPaint(0,seriesColor.get(i));
}
return result;
}
開發者ID:PacktPublishing,項目名稱:Neural-Network-Programming-with-Java-SecondEdition,代碼行數:26,代碼來源:Chart.java
示例6: createLineChart3D
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
/**
* Create a line chart with sample data in the range -3 to +3.
*
* @return The chart.
*/
private static JFreeChart createLineChart3D() {
// create a dataset...
Number[][] data = new Integer[][]
{{new Integer(-3), new Integer(-2)},
{new Integer(-1), new Integer(1)},
{new Integer(2), new Integer(3)}};
CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S",
"C", data);
// create the chart...
return ChartFactory.createLineChart3D(
"Line Chart",
"Domain", "Range",
dataset,
PlotOrientation.HORIZONTAL,
true, // include legend
true,
true
);
}
示例7: scatterGridPlot
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
public JFreeChart scatterGridPlot(String xLabel, String yLabel){
int numDatasets = dataset.size();
JFreeChart result = ChartFactory.createScatterPlot(chartTitle
, xLabel
, yLabel
, dataset.get(0));
XYPlot plot = result.getXYPlot();
plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer().setSeriesPaint(0, seriesColor.get(0));
for(int i=1;i<numDatasets;i++){
plot.setDataset(i,dataset.get(i));
//XYItemRenderer renderer = plot.getRenderer(i-0);
plot.setRenderer(i, new XYLineAndShapeRenderer(true, true));
plot.getRenderer(i).setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer(i).setSeriesPaint(0,seriesColor.get(i));
}
return result;
}
開發者ID:PacktPublishing,項目名稱:Neural-Network-Programming-with-Java-SecondEdition,代碼行數:20,代碼來源:Chart.java
示例8: testFindRangeBounds
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
/**
* Check that the renderer is calculating the range bounds correctly.
*/
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
plot.setRenderer(renderer);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
Range bounds = rangeAxis.getRange();
assertTrue(bounds.contains(6.0));
assertTrue(bounds.contains(8.0));
// try null argument
assertNull(renderer.findRangeBounds(null));
// try empty dataset
assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
示例9: TimeSeriesChartTab
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
/**
* Constructor
* @param model The data model for this time series
*/
public TimeSeriesChartTab(TimeSeriesDataModel model, TimeSeriesChartEditorJPanel parent){
super(ChartFactory.createTimeSeriesChart(
model.getTimeSeriesOntologyModel().getChartSettings().getChartTitle(),
model.getTimeSeriesOntologyModel().getChartSettings().getXAxisLabel(),
model.getTimeSeriesOntologyModel().getChartSettings().getYAxisLabel(),
model.getTimeSeriesChartModel().getTimeSeriesCollection(),
true, false, false
), parent);
this.dataModel = model;
applySettings();
model.getChartModel().addObserver(this);
}
示例10: createChart
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
/**
* Create a horizontal bar chart with sample data in the range -3 to +3.
*
* @return The chart.
*/
private static JFreeChart createChart() {
// create a dataset...
XYSeries series1 = new XYSeries("Series 1");
series1.add(1.0, 1.0);
series1.add(2.0, 2.0);
series1.add(3.0, 3.0);
IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection(
series1), 1.0);
// create the chart...
return ChartFactory.createXYBarChart(
"XY Bar Chart", // chart title
"Domain", false,
"Range",
dataset, // data
PlotOrientation.VERTICAL,
true, // include legend
true, // tooltips
true // urls
);
}
示例11: replaceModel
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
@Override
public void replaceModel(DataModel newModel) {
this.dataModel = newModel;
this.chartPanel.setChart(ChartFactory.createXYLineChart(
dataModel.getOntologyModel().getChartSettings().getChartTitle(),
dataModel.getOntologyModel().getChartSettings().getXAxisLabel(),
dataModel.getOntologyModel().getChartSettings().getYAxisLabel(),
((XyChartModel)dataModel.getChartModel()).getXySeriesCollection(),
PlotOrientation.VERTICAL,
true, false, false
));
this.applySettings();
this.dataModel.getChartModel().addObserver(this);
}
示例12: createChart
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
private static JFreeChart createChart(XYDataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
null, // x axis label
null, // y axis label
dataset, // data
PlotOrientation.VERTICAL, false, // include legend
true, // tooltips
false // urls
);
chart.setBackgroundPaint(Color.white);
// get a reference to the plot for further customization...
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.WHITE);
ValueAxis valueAxis = plot.getRangeAxis();
valueAxis.setLabelFont(LABEL_FONT_BOLD);
valueAxis.setTickLabelFont(LABEL_FONT);
return chart;
}
示例13: test1654215
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
/**
* A test for bug 1654215 (where a renderer is added to the plot without
* a corresponding dataset and it throws an exception at drawing time).
*/
public void test1654215() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
dataset, PlotOrientation.VERTICAL, true, false, false);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setRenderer(1, new LineAndShapeRenderer());
boolean success = false;
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
success = true;
}
catch (Exception e) {
e.printStackTrace();
success = false;
}
assertTrue(success);
}
示例14: createHistogramChart
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
/**
* Creates the histogram chart.
*
* @param exampleSet
* @return
*/
private JFreeChart createHistogramChart(final ExampleSet exampleSet) {
JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(exampleSet),
PlotOrientation.VERTICAL, false, false, false);
AbstractAttributeStatisticsModel.setDefaultChartFonts(chart);
chart.setBackgroundPaint(null);
chart.setBackgroundImageAlpha(0.0f);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRangeGridlinesVisible(false);
plot.setDomainGridlinesVisible(false);
plot.setOutlineVisible(false);
plot.setRangeZeroBaselineVisible(false);
plot.setDomainZeroBaselineVisible(false);
plot.getDomainAxis().setTickLabelsVisible(false);
plot.setBackgroundPaint(COLOR_INVISIBLE);
plot.setBackgroundImageAlpha(0.0f);
XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.DATE_TIME));
renderer.setBarPainter(new StandardXYBarPainter());
renderer.setDrawBarOutline(true);
renderer.setShadowVisible(false);
return chart;
}
示例15: testFindRangeBounds
import org.jfree.chart.ChartFactory; //導入依賴的package包/類
/**
* Check that the renderer is calculating the range bounds correctly.
*/
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createXYLineChart(
"Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setAutoRangeIncludesZero(false);
Range bounds = rangeAxis.getRange();
assertFalse(bounds.contains(1.0));
assertTrue(bounds.contains(2.0));
assertTrue(bounds.contains(5.0));
assertFalse(bounds.contains(6.0));
}