本文整理汇总了Java中org.jfree.chart.renderer.category.BoxAndWhiskerRenderer.setToolTipGenerator方法的典型用法代码示例。如果您正苦于以下问题:Java BoxAndWhiskerRenderer.setToolTipGenerator方法的具体用法?Java BoxAndWhiskerRenderer.setToolTipGenerator怎么用?Java BoxAndWhiskerRenderer.setToolTipGenerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.renderer.category.BoxAndWhiskerRenderer
的用法示例。
在下文中一共展示了BoxAndWhiskerRenderer.setToolTipGenerator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBoxAndWhiskerChart
import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer; //导入方法依赖的package包/类
/**
* Creates and returns a default instance of a box and whisker chart
* based on data from a {@link BoxAndWhiskerCategoryDataset}.
*
* @param title the chart title (<code>null</code> permitted).
* @param categoryAxisLabel a label for the category axis
* (<code>null</code> permitted).
* @param valueAxisLabel a label for the value axis (<code>null</code>
* permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param legend a flag specifying whether or not a legend is required.
*
* @return A box and whisker chart.
*
* @since 1.0.4
*/
public static JFreeChart createBoxAndWhiskerChart(String title,
String categoryAxisLabel, String valueAxisLabel,
BoxAndWhiskerCategoryDataset dataset, boolean legend) {
CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
valueAxis.setAutoRangeIncludesZero(false);
BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
renderer);
return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot,
legend);
}
示例2: boxWhiskerPlot
import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer; //导入方法依赖的package包/类
/**
* Plots Data for Chart
*/
private void boxWhiskerPlot() {
BoxAndWhiskerCategoryDataset dataset = createDataset();
CategoryAxis xAxis = new CategoryAxis("Model");
NumberAxis yAxis = new NumberAxis("Fitness");
yAxis.setRange(0.0, 1.0);
BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
renderer.setFillBox(false);
renderer.setMaximumBarWidth(0.2);
renderer.setItemMargin(0.5);
renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
plot.setOrientation(PlotOrientation.HORIZONTAL);
chart = new JFreeChart(
"Model comparison",
new Font("Palatino", Font.BOLD, 14),
plot,
true
);
chart.removeLegend();
// boxWhiskerPane.setCenter(viewer);
}
示例3: init
import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer; //导入方法依赖的package包/类
protected void init()
{
dataset = new DefaultBoxAndWhiskerCategoryDataset();
final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
renderer.setFillBox(false);
renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
final CategoryAxis xAxis = new CategoryAxis("Type");
final NumberAxis yAxis = new NumberAxis("Value");
final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
final JFreeChart chart = new JFreeChart(
getName(),
new Font("SansSerif", Font.BOLD, 14),
plot,
true
);
init(chart.getPlot());
}
示例4: getChart
import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer; //导入方法依赖的package包/类
public JFreeChart getChart() {
if (chart == null) {
createDataset();
chart = ChartFactory.createBarChart(getTitle(),
// chart title
"Category",
// domain axis label
"Value",
// range axis label
dataset,
// data
PlotOrientation.VERTICAL,
// orientation
false,
// include legend
true,
// tooltips?
false
// URLs?
);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
CategoryAxis rangeAxis = plot.getDomainAxis();
rangeAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
renderer.setFillBox(true);
renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
renderer.setMeanVisible(isMeanVisible);
plot.setRenderer(renderer);
}
return chart;
}
示例5: writeToFile
import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer; //导入方法依赖的package包/类
public void writeToFile(String outName) throws FileNotFoundException, UnsupportedEncodingException, IOException
{
//calcMeans();
// Create JFreeChart Dataset
DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset( );
HashMap<String, ArrayList<Double> > measuresFirst = algorithmMeasures.entrySet().iterator().next().getValue();
for (Map.Entry<String, ArrayList<Double> > measure : measuresFirst.entrySet())
{
String measureName = measure.getKey();
//Double measureValue = measure.getValue();
dataset.clear();
for (Map.Entry<String, HashMap<String, ArrayList<Double> >> entry : algorithmMeasures.entrySet())
{
String alg = entry.getKey();
ArrayList<Double> measureValues = entry.getValue().get(measureName);
// Parse algorithm name to show it correctly
String aName = alg.substring(0, alg.length()-1);
int startAlgName = aName.lastIndexOf("/");
aName = aName.substring(startAlgName + 1);
dataset.add(measureValues, aName, measureName);
}
// Tutorial: http://www.java2s.com/Code/Java/Chart/JFreeChartBoxAndWhiskerDemo.htm
final CategoryAxis xAxis = new CategoryAxis("Algorithm");
final NumberAxis yAxis = new NumberAxis("Value");
yAxis.setAutoRangeIncludesZero(false);
final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
// Black and White
int numItems = algorithmMeasures.size();
for(int i=0;i<numItems;i++)
{
Color color = Color.DARK_GRAY;
if(i%2 == 1)
{
color = Color.LIGHT_GRAY;
}
renderer.setSeriesPaint(i, color);
renderer.setSeriesOutlinePaint(i, Color.BLACK);
}
renderer.setMeanVisible(false);
renderer.setFillBox(false);
renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
Font font = new Font("SansSerif", Font.BOLD, 10);
//ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
JFreeChart jchart = new JFreeChart("Assotiation Rules Measures - BoxPlot", font, plot, true);
//StandardChartTheme.createLegacyTheme().apply(jchart);
int width = 640 * 2; /* Width of the image */
int height = 480 * 2; /* Height of the image */
// JPEG
File chart = new File( outName + "_" + measureName + "_boxplot.jpg" );
ChartUtilities.saveChartAsJPEG( chart , jchart , width , height );
// SVG
SVGGraphics2D g2 = new SVGGraphics2D(width, height);
Rectangle r = new Rectangle(0, 0, width, height);
jchart.draw(g2, r);
File BarChartSVG = new File( outName + "_" + measureName + "_boxplot.svg" );
SVGUtils.writeToSVG(BarChartSVG, g2.getSVGElement());
}
}
示例6: Evaluation
import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer; //导入方法依赖的package包/类
public Evaluation(){
String[] nameOfTestInstances = {"att48","brg180","ch150","gr202"};
int[] numberOfTestRuns = {100,100,50,20};
int[] timeLimits = {1,2,15,120};
LinkedList<Double> ilsResults = new LinkedList<Double>();
LinkedList<Double> memeResults = new LinkedList<Double>();
final DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset();
try {
for(int j = 0; j < nameOfTestInstances.length; j++)
{
// dataset.clear();
for(int i = 0; i<numberOfTestRuns[j]; i++)
{
String[] arguments = {nameOfTestInstances[j], String.valueOf(timeLimits[j]), String.valueOf(50), "noDiagrams"};
double[] results = TSP_Main.main(arguments);
ilsResults.add(results[0]);
memeResults.add(results[1]);
}
dataset.add(ilsResults, "Iterated Local Search", nameOfTestInstances[j]);
dataset.add(memeResults, "Memetic Algorithm", nameOfTestInstances[j]);
ilsResults.clear();
memeResults.clear();
}
final CategoryAxis xAxis = new CategoryAxis("Name of TSPLIB instance");
final NumberAxis yAxis = new NumberAxis("deviation from optimum in %");
// yAxis.setAutoRangeIncludesZero(false);
final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
// renderer.setFillBox(false);
renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
renderer.setMeanVisible(false);
renderer.setMaximumBarWidth(10);
final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
final NumberAxis axis = (NumberAxis) plot.getRangeAxis();
axis.setRange(Range.expandToInclude(axis.getRange(), -0.2));
final JFreeChart chart = new JFreeChart(
"Comparison of ILS and Memetic Algorithm",
new Font("SansSerif", Font.BOLD, 16),
plot,
true
);
final ChartPanel chartPanel = new ChartPanel(chart);
// chartPanel.setPreferredSize(new java.awt.Dimension(900, 540));
ChartUtilities.saveChartAsJPEG(new File("evaluation"), chart, 500, 400);
setContentPane(chartPanel);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}