當前位置: 首頁>>代碼示例>>Java>>正文


Java ChartUtilities類代碼示例

本文整理匯總了Java中org.jfree.chart.ChartUtilities的典型用法代碼示例。如果您正苦於以下問題:Java ChartUtilities類的具體用法?Java ChartUtilities怎麽用?Java ChartUtilities使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ChartUtilities類屬於org.jfree.chart包,在下文中一共展示了ChartUtilities類的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);
}
 
開發者ID:boecker-lab,項目名稱:passatuto,代碼行數:26,代碼來源:SimilarityMatrix.java

示例2: drawChart

import org.jfree.chart.ChartUtilities; //導入依賴的package包/類
public void drawChart(String filename, int width, int height) throws IOException {
  // Create plot
  NumberAxis xAxis = new NumberAxis(xAxisLabel);
  NumberAxis yAxis = new NumberAxis(yAxisLabel);
  XYSplineRenderer renderer = new XYSplineRenderer();
  XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
  plot.setBackgroundPaint(Color.lightGray);
  plot.setDomainGridlinePaint(Color.white);
  plot.setRangeGridlinePaint(Color.white);
  plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4));

  // Create chart
  JFreeChart chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
  ChartUtilities.applyCurrentTheme(chart);
  ChartPanel chartPanel = new ChartPanel(chart, false);

  // Draw png
  BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
  Graphics graphics = bi.getGraphics();
  chartPanel.setBounds(0, 0, width, height);
  chartPanel.paint(graphics);
  ImageIO.write(bi, "png", new File(filename));
}
 
開發者ID:Kurento,項目名稱:kurento-java,代碼行數:24,代碼來源:ChartWriter.java

示例3: 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);
			}
		}
	}
 
開發者ID:boecker-lab,項目名稱:passatuto,代碼行數:37,代碼來源:Plot.java

示例4: 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);
	}
 
開發者ID:boecker-lab,項目名稱:passatuto,代碼行數:25,代碼來源:HitStatistic.java

示例5: doSaveAs

import org.jfree.chart.ChartUtilities; //導入依賴的package包/類
/**
 * Opens a file chooser and gives the user an opportunity to save the chart in PNG format.
 * 
 * @throws IOException
 *             if there is an I/O error.
 */

@Override
public void doSaveAs() throws IOException {

	JFileChooser fileChooser = new JFileChooser();
	fileChooser.setCurrentDirectory(this.defaultDirectoryForSaveAs);
	ExtensionFileFilter filter = new ExtensionFileFilter(localizationResources.getString("PNG_Image_Files"), ".png");
	fileChooser.addChoosableFileFilter(filter);

	int option = fileChooser.showSaveDialog(this);
	if (option == JFileChooser.APPROVE_OPTION) {
		String filename = fileChooser.getSelectedFile().getPath();
		if (isEnforceFileExtensions()) {
			if (!filename.endsWith(".png")) {
				filename = filename + ".png";
			}
		}
		ChartUtilities.saveChartAsPNG(new File(filename), this.chart, getWidth(), getHeight());
	}

}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:28,代碼來源:AbstractChartPanel.java

示例6: 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());   
          }
}
 
開發者ID:mathhobbit,項目名稱:EditCalculateAndChart,代碼行數:23,代碼來源:SaveAs_Action.java

示例7: doGet

import org.jfree.chart.ChartUtilities; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    List<PollOption> results = null;
    try {
        Long pollId = (Long) req.getSession().getAttribute("pollID");
        results = DAOProvider.getDao().getPollOptions(pollId);
    } catch (Exception ex) {
        results = new ArrayList<>();
    }

    JFreeChart chart = DBUtility.getChart(results);
    ChartUtilities.writeChartAsPNG(resp.getOutputStream(), chart, 700, 400);
}
 
開發者ID:fgulan,項目名稱:java-course,代碼行數:19,代碼來源:GlasanjeGrafikaServlet.java

示例8: doGet

import org.jfree.chart.ChartUtilities; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    String resultFile = req.getServletContext().getRealPath(
            "/WEB-INF/glasanje-rezultati.txt");
    String definitionFile = req.getServletContext().getRealPath(
            "/WEB-INF/glasanje-definicija.txt");

    List<Band> results = ServerUtilty
            .getResults(definitionFile, resultFile);

    JFreeChart chart = ServerUtilty.getChart(results);
    ChartUtilities.writeChartAsPNG(resp.getOutputStream(), chart, 700, 400);
    resp.getOutputStream().flush();
}
 
開發者ID:fgulan,項目名稱:java-course,代碼行數:20,代碼來源:GlasanjeGrafikaServlet.java

示例9: saveChartAsPNG

import org.jfree.chart.ChartUtilities; //導入依賴的package包/類
/**
 * Saves the chart as a PNG 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 (<code>null</code> permitted).
 * @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 saveChartAsPNG(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, ".png", 
        new File(System.getProperty("java.io.tmpdir"))
    );
    ChartUtilities.saveChartAsPNG(tempFile, chart, width, height, info);
    ServletUtilities.registerChartForDeletion(tempFile, session);
    return tempFile.getName();

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:33,代碼來源:ServletUtilities.java

示例10: 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();

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:35,代碼來源:ServletUtilities.java

示例11: doSaveAs

import org.jfree.chart.ChartUtilities; //導入依賴的package包/類
/**
 * Opens a file chooser and gives the user an opportunity to save the chart
 * in PNG format.
 *
 * @throws IOException if there is an I/O error.
 */
public void doSaveAs() throws IOException {
    FileDialog fileDialog = new FileDialog(canvas.getShell(), SWT.SAVE);
    String[] extensions = { "*.png" };
    fileDialog.setFilterExtensions(extensions);
    String filename = fileDialog.open();
    if (filename != null) {
        if (isEnforceFileExtensions()) {
            if (!filename.endsWith(".png")) {
                filename = filename + ".png";
            }
        }
        //TODO replace getSize by getBounds ?
        ChartUtilities.saveChartAsPNG(new File(filename), this.chart, 
                canvas.getSize().x, canvas.getSize().y);
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:23,代碼來源:ChartComposite.java

示例12: saveChartAsPNG

import org.jfree.chart.ChartUtilities; //導入依賴的package包/類
/**
 * Saves the chart as a PNG format file in the temporary directory and
 * populates the {@link 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 
 *              (<code>null</code> permitted).
 * @param session  the HttpSession of the client (if <code>null</code>, the
 *                 temporary file is marked as "one-time" and deleted by 
 *                 the {@link DisplayChart} servlet right after it is
 *                 streamed to 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 saveChartAsPNG(JFreeChart chart, int width, int height,
        ChartRenderingInfo info, HttpSession session) throws IOException {

    if (chart == null) {
        throw new IllegalArgumentException("Null 'chart' argument.");   
    }
    ServletUtilities.createTempDir();
    String prefix = ServletUtilities.tempFilePrefix;
    if (session == null) {
        prefix = ServletUtilities.tempOneTimeFilePrefix;
    }
    File tempFile = File.createTempFile(prefix, ".png", 
            new File(System.getProperty("java.io.tmpdir")));
    ChartUtilities.saveChartAsPNG(tempFile, chart, width, height, info);
    if (session != null) {
        ServletUtilities.registerChartForDeletion(tempFile, session);
    }
    return tempFile.getName();

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:40,代碼來源:ServletUtilities.java

示例13: GenerateRTMapPNG

import org.jfree.chart.ChartUtilities; //導入依賴的package包/類
private void GenerateRTMapPNG(XYSeriesCollection xySeriesCollection, XYSeries series, float R2) throws IOException {
    new File(Workfolder + "/RT_Mapping/").mkdir();
    String pngfile = Workfolder + "/RT_Mapping/" + FilenameUtils.getBaseName(LCMSA.mzXMLFileName).substring(0, Math.min(120, FilenameUtils.getBaseName(LCMSA.mzXMLFileName).length() - 1)) + "_" + FilenameUtils.getBaseName(LCMSB.mzXMLFileName).substring(0, Math.min(120, FilenameUtils.getBaseName(LCMSB.mzXMLFileName).length() - 1)) + "_RT.png";

    XYSeries smoothline = new XYSeries("RT fitting curve");
    for (XYZData data : regression.PredictYList) {
        smoothline.add(data.getX(), data.getY());
    }
    xySeriesCollection.addSeries(smoothline);
    xySeriesCollection.addSeries(series);
    JFreeChart chart = ChartFactory.createScatterPlot("Retention time mapping: R2=" + R2, "RT:" + FilenameUtils.getBaseName(LCMSA.mzXMLFileName), "RT:" + FilenameUtils.getBaseName(LCMSB.mzXMLFileName), xySeriesCollection,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) chart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);

    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesPaint(1, Color.blue);
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesShape(1, new Ellipse2D.Double(0, 0, 3, 3));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    xyPlot.setBackgroundPaint(Color.white);
    ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
}
 
開發者ID:YcheCourseProject,項目名稱:DIA-Umpire-Maven,代碼行數:26,代碼來源:RTAlignedPepIonMapping.java

示例14: doSaveAs

import org.jfree.chart.ChartUtilities; //導入依賴的package包/類
/**
 * Opens a file chooser and gives the user an opportunity to save the chart
 * in PNG format.
 *
 * @throws IOException if there is an I/O error.
 */
public void doSaveAs() throws IOException {
    FileDialog fileDialog = new FileDialog(this.canvas.getShell(),
            SWT.SAVE);
    String[] extensions = {"*.png"};
    fileDialog.setFilterExtensions(extensions);
    String filename = fileDialog.open();
    if (filename != null) {
        if (isEnforceFileExtensions()) {
            if (!filename.endsWith(".png")) {
                filename = filename + ".png";
            }
        }
        //TODO replace getSize by getBounds ?
        ChartUtilities.saveChartAsPNG(new File(filename), this.chart,
                this.canvas.getSize().x, this.canvas.getSize().y);
    }
}
 
開發者ID:mdzio,項目名稱:ccu-historian,代碼行數:24,代碼來源:ChartComposite.java

示例15: writeJChartToFile

import org.jfree.chart.ChartUtilities; //導入依賴的package包/類
static String writeJChartToFile(JFreeChart chart, File file, FileTypes fileType) throws IOException, DocumentException {
    String fileName = file.getPath();
    switch (fileType) {
        case svg:
            Tools.exportChartAsSVG(chart, new Rectangle(1000, 1000), file);
            break;
        case pdf:
            Tools.exportChartAsPDF(chart, new Rectangle(500, 400), file);
            break;
        case jchart:
            break;
        case csv:
            Tools.exportChartAsCSV(chart, file);
            break;
        default:
            ChartUtilities.saveChartAsPNG(file, chart, 1000, 1000);
            break;
    }
    return fileName;
}
 
開發者ID:IARC-CSU,項目名稱:CanReg5,代碼行數:21,代碼來源:Tools.java


注:本文中的org.jfree.chart.ChartUtilities類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。