本文整理汇总了Java中org.jfree.chart.ChartUtilities.saveChartAsJPEG方法的典型用法代码示例。如果您正苦于以下问题:Java ChartUtilities.saveChartAsJPEG方法的具体用法?Java ChartUtilities.saveChartAsJPEG怎么用?Java ChartUtilities.saveChartAsJPEG使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.ChartUtilities
的用法示例。
在下文中一共展示了ChartUtilities.saveChartAsJPEG方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeRankVSScore
import org.jfree.chart.ChartUtilities; //导入方法依赖的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: writeRankVSPercentage
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public static void writeRankVSPercentage(File outputFile, String add, List<ResultList>[] resultsOriginal, List<List<ResultList>>[] resultsDecoy, int length) throws Exception{
for(List<ResultList> o:resultsOriginal){
for(List<List<ResultList>> ds:resultsDecoy){
String name="RankVSpercentage";
if(ds.size()>1)name+="Mean";
Map<String,int[]> numbers=new TreeMap<String,int[]>();
for(List<ResultList> d:ds){
List<ResultList> merged=ResultList.mergeResults(new List[]{o,d});
for(int i=0;i<merged.size();i++){
ResultList rl=merged.get(i);
for(int j=0;j<Math.min(length,rl.results.size());j++){
String key=rl.query.getDB()+"-"+rl.results.get(j).getDB();
if(!numbers.containsKey(key))numbers.put(key, new int[length]);
numbers.get(key)[j]=numbers.get(key)[j]+1;
}
}
}
String fileName="";
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for(Entry<String, int[]> n:numbers.entrySet()){
double all=0;
for(int i=0;i<n.getValue().length;i++){
dataset.addValue(n.getValue()[i], n.getKey(), Integer.toString(i));
}
fileName+=n.getKey()+"---";
}
fileName=fileName.substring(0,fileName.length()-3);
final JFreeChart chart = ChartFactory.createBarChart("Boxplot","Ranks","Percentage",dataset);
ChartUtilities.saveChartAsJPEG(new File(outputFile.getPath()+"\\"+name+"_"+fileName+add+".jpg"), chart, Math.min(2000,length*100), 1000);
}
}
}
示例3: writeROCCurves
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public static void writeROCCurves(File outputFile, TreeMap<String, HitStatistic> hits) throws Exception{
XYSeriesCollection dataset = new XYSeriesCollection();
for(Entry<String, HitStatistic> e:hits.entrySet()){
File txtFile=new File(outputFile.getAbsolutePath().replaceAll(".jpg","_"+e.getKey().split("-")[2]+".txt"));
BufferedWriter bw=new BufferedWriter(new FileWriter(txtFile));
XYSeries series= new XYSeries(e.getKey());
bw.write("false positive rate\tsensitivity");
bw.newLine();
List<double[]> roc=e.getValue().getROCAverage();
for(double[] r:roc){
bw.write(r[0]+"\t"+r[1]);
bw.newLine();
series.add(r[0],r[1]);
}
dataset.addSeries(series);
bw.close();
}
final JFreeChart chart =ChartFactory.createXYLineChart("ROCCurve", "false positive rate", "sensitivity", dataset);
ChartUtilities.saveChartAsJPEG(outputFile, chart, 1000, 400);
}
示例4: actionPerformed
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
try{
if(fileChooser.showSaveDialog(null)==JFileChooser.APPROVE_OPTION){
String SelectedFileName = fileChooser.getSelectedFile().getAbsolutePath();
if(SelectedFileName.toUpperCase().endsWith(".JPG")||
SelectedFileName.toUpperCase().endsWith(".JPEG")){
ChartUtilities.saveChartAsJPEG(new File(SelectedFileName),TEdit,500,500);
return;
}
if(SelectedFileName.toUpperCase().endsWith(".PNG")){
ChartUtilities.saveChartAsPNG(new File(SelectedFileName),TEdit,500,500);
return;
}
ChartUtilities.saveChartAsPNG(new File(SelectedFileName+".png"),TEdit,500,500);
}
}
catch(Exception Ex){
System.out.println(Ex.toString());
}
}
示例5: saveChartAsJPEG
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
/**
* Saves the chart as a JPEG format file in the temporary directory and
* populates the ChartRenderingInfo object which can be used to generate
* an HTML image map.
*
* @param chart the chart to be saved (<code>null</code> not permitted).
* @param width the width of the chart
* @param height the height of the chart
* @param info the ChartRenderingInfo object to be populated
* @param session the HttpSession of the client
*
* @return the filename of the chart saved in the temporary directory
*
* @throws IOException if there is a problem saving the file.
*/
public static String saveChartAsJPEG(JFreeChart chart, int width, int height,
ChartRenderingInfo info, HttpSession session)
throws IOException {
if (chart == null) {
throw new IllegalArgumentException("Null 'chart' argument.");
}
ServletUtilities.createTempDir();
File tempFile = File.createTempFile(
ServletUtilities.tempFilePrefix,
".jpeg", new File(System.getProperty("java.io.tmpdir"))
);
ChartUtilities.saveChartAsJPEG(tempFile, chart, width, height, info);
ServletUtilities.registerChartForDeletion(tempFile, session);
return tempFile.getName();
}
示例6: salvarJPEG
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
private void salvarJPEG() {
JFileChooser chooser = new JFileChooser();
chooser.setSelectedFile(new File(".jpg"));
int returnVal = chooser.showSaveDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
try {
ChartUtilities.saveChartAsJPEG(file,
chartPanel.getChart(),
chartPanel.getWidth(),
chartPanel.getHeight());
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
示例7: jpgLineChartTerminationRate
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public void jpgLineChartTerminationRate(Integer percentTerminations[], List<Float> reliabilities)
throws IOException {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (int j = 0; j < reliabilities.size(); j++) {
dataset.addValue(percentTerminations[j], "early termination rate", reliabilities.get(j));
}
JFreeChart lineChartObject = ChartFactory.createLineChart(
"Percent early termination rate of reliability estimation",
"Reliability Lower Bound (Slb)", "Percent early termination rate",
dataset, PlotOrientation.VERTICAL,
true, true, false);
int width = 640;
/* Width of the image */
int height = 480;
/* Height of the image */
String fileName = "earlyTerminationRate.jpeg";
File lineChart = new File(fileName);
ChartUtilities.saveChartAsJPEG(lineChart, lineChartObject, width, height);
logger.debug(fileName + " created");
}
示例8: jpgLineChartCostPRE
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public void jpgLineChartCostPRE(BigDecimal[] relativeErrors, List<Float> reliabilities) throws IOException {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (int j = 0; j < reliabilities.size(); j++) {
dataset.addValue(relativeErrors[j], "", reliabilities.get(j));
}
JFreeChart lineChartObject = ChartFactory.createLineChart(
"Percent relative error of CostEstimation",
"Reliability Lower Bound (Slb)", "Percent relative Error",
dataset, PlotOrientation.VERTICAL,
true, true, false);
int width = 640;
/* Width of the image */
int height = 480;
/* Height of the image */
String fileName = "costRelativeError.jpeg";
File lineChart = new File(fileName);
ChartUtilities.saveChartAsJPEG(lineChart, lineChartObject, width, height);
logger.debug(fileName + " created");
}
示例9: savePlots
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public void savePlots(String path)throws IOException{
File dir = new File(path);
if(!dir.exists()) dir.mkdirs();
//Will Save in a way that an OS will list them in selected order but omits the TCC
// int index=1;
// for(String s : names){
// JFreeChart c = charts.get(s);
// String n = "a"+index+"-"+s;
// ChartUtilities.saveChartAsJPEG(new File(dir.getAbsolutePath()+"/"+n+".jpg"), c, width, height);
// index++;
// }
for(String s : charts.keySet()){
JFreeChart c = charts.get(s);
ChartUtilities.saveChartAsJPEG(new File(dir.getAbsolutePath()+"/"+s+".jpg"), c, width, height);
}
}
示例10: build
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
private PDJpeg build(Chart<Float> chart, String title, PDFDocument document, int width, int height) throws IOException {
JFreeChart obj = null;
try {
obj = chart.createChart(title);
} catch (Exception ex) {
ex.printStackTrace();
throw new IOException(ex);
}
// output as file
File outputFile = File.createTempFile("img", "jpg");
ChartUtilities.saveChartAsJPEG(outputFile, obj, width, height);
PDJpeg img = new PDJpeg(document, new FileInputStream(outputFile) );
outputFile.delete();
return img;
}
示例11: writeChart
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public void writeChart(String filename, int x, int y)
throws Exception
{
JFreeChart chart = createChart();
if (param.backgroundPaint != null) chart.getPlot().setBackgroundPaint(param.backgroundPaint);
//TODO: handle legends with series titles
chart.removeLegend();
// plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
// plot.setNoDataMessage("No data available");
if (param.subtitle != null)
chart.addSubtitle(new TextTitle(param.subtitle));
if (param.showLegend)
chart.addLegend(new LegendTitle(chart.getPlot()));
String fileExt = filenameExtension(filename);
if (fileExt.equalsIgnoreCase("jpg") || fileExt.equalsIgnoreCase("jpeg"))
ChartUtilities.saveChartAsJPEG(new File(filename), chart, x, y);
else
ChartUtilities.saveChartAsPNG(new File(filename), chart, x, y);
}
示例12: writeQValues
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
private static List<double[]> writeQValues(File outputFile, List<File> inputFiles, double minQValue, double maxQValue, boolean normalizedEstimated) throws Exception{
List<List<double[]>> r=getPoints(inputFiles, minQValue, maxQValue, true, false, "and", false, normalizedEstimated);
Map<Integer,Map<Double, List<Double>>> allValues=new HashMap<Integer,Map<Double, List<Double>>>();
XYSeriesCollection dataset = new XYSeriesCollection();
List<double[]> result=new ArrayList<double[]>();
for(int i=0;i<inputFiles.size();i++){
XYSeries xyseries=new XYSeries(inputFiles.get(i).getName());
for(int j=0;j<r.get(i).size();j++){
double[] d=r.get(i).get(j);
xyseries.add(d[0],d[1]);
result.add(new double[]{d[0],d[1]});
if(!allValues.containsKey(j))allValues.put(j,new TreeMap<Double,List<Double>>());
if(!allValues.get(j).containsKey(d[0]))allValues.get(j).put(d[0], new ArrayList<Double>());
allValues.get(j).get(d[0]).add(d[1]);
}
dataset.addSeries(xyseries);
}
Collections.sort(result,new Comparator<double[]>(){
@Override
public int compare(double[] o1, double[] o2) {
int c=Double.compare(o1[0],o2[0]);
if(c!=0)return c;
return Double.compare(o1[1],o2[1]);
}
});
XYSeries seriesWH=SimilarityMatrix.getBisectingLine(minQValue, maxQValue);
dataset.addSeries(seriesWH);
final JFreeChart chart = ChartFactory.createScatterPlot("qValue", "qValue calculated", "qValue by decoy database", dataset, PlotOrientation.VERTICAL, false, false, false);
ChartUtilities.saveChartAsJPEG(outputFile, chart, 1000, 1000);
return result;
}
示例13: writeEstimatedQValueVSCalculatedQValue
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public static void writeEstimatedQValueVSCalculatedQValue(File outputFile, List<SimilarityMatrix> matrices, String add, boolean FDR) throws IOException{
XYSeriesCollection dataset = new XYSeriesCollection();
for(SimilarityMatrix m:matrices){
dataset.addSeries(m.getEstimatedQValueVSCalculatedQValue(FDR, m.massbankQuery,"",Double.NEGATIVE_INFINITY,Double.POSITIVE_INFINITY));
}
XYSeries seriesWH=getBisectingLine(0, 1);
dataset.addSeries(seriesWH);
String desc=FDR?"FDRsComparison_":"qValuesComparison_";
String desc2=FDR?"FDRs":"qValues";
final JFreeChart chart = ChartFactory.createScatterPlot(desc2, desc2+" calculated", desc2+" by decoy database", dataset);
ChartUtilities.saveChartAsJPEG(new File(outputFile.getAbsolutePath()+sep+add+desc+getMethodsQueryStringFromList(matrices)+".jpg"), chart, 1000, 1000);
}
示例14: writeRankVSPercentage
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public void writeRankVSPercentage(File outputFile, int length, String add) throws Exception{
int[][] sortedIndizes=getIndizesOfSortedScores();
Map<String,int[]> numbers=new TreeMap<String,int[]>();
numbers.put("Decoy", new int[Math.min(length,sortedIndizes[0].length)]);
numbers.put("Original", new int[Math.min(length,sortedIndizes[0].length)]);
for(int i=0;i<sortedIndizes.length;i++){
int l=0;
for(int j=0;j<sortedIndizes[i].length;j++){
int currCol=sortedIndizes[i][j];
if(Double.isNaN(getSimilarityValue(i,currCol)))continue;
String method=methodsDB.get(currCol);
if(typesDB.get(method)==DatabaseType.Original){
numbers.get("Original")[l]=numbers.get("Original")[l]+1;
}else if(typesDB.get(method)==DatabaseType.Decoy){
numbers.get("Decoy")[l]=numbers.get("Decoy")[l]+1;
}
l++;
if(l>=numbers.get("Original").length)break;
}
}
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for(Entry<String, int[]> n:numbers.entrySet()){
for(int i=0;i<n.getValue().length;i++){
dataset.addValue(n.getValue()[i], n.getKey(), Integer.toString(i));
}
}
final JFreeChart chart = ChartFactory.createBarChart("BarChart","Ranks","Percentage",dataset);
ChartUtilities.saveChartAsJPEG(new File(outputFile.getPath()+sep+add+"RankVSpercentage_"+getMethodsQueryAndDBString()+".jpg"), chart, Math.min(2000,length*100), 1000);
}
示例15: doSaveImageAction
import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
private void doSaveImageAction() {
filename = FileTools.getFile("File to store chart image", ".png", filename, true);
if (filename == null || filename.length() < 1) {
return;
}
try {
ChartUtilities.saveChartAsJPEG(new File(filename), freechart, 800, 600);
} catch (IOException ex) {
Logger.getLogger(FlowSignalDistributionPanel.class.getName()).log(Level.SEVERE, null, ex);
}
}