⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linechart.java

📁 操作系统课程设计:页面置换算法!!!很好的操作系统大作业
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package app;import java.awt.Color;import java.awt.Dimension;import javax.swing.JPanel;import org.jfree.chart.ChartFactory;import org.jfree.chart.ChartPanel;import org.jfree.chart.JFreeChart;import org.jfree.chart.axis.NumberAxis;import org.jfree.chart.plot.PlotOrientation;import org.jfree.chart.plot.XYPlot;import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;import org.jfree.data.xy.XYDataset;import org.jfree.data.xy.XYSeries;import org.jfree.data.xy.XYSeriesCollection;import org.jfree.ui.RectangleInsets;/** * * @author Administrator */public class LineChart{      private ChartPanel chartpanel = null;    private String name1 = null;    private String name2 = null;    public LineChart(double[] fir,double[] sec,String name1,String name2)    {        this.name1 = name1;        this.name2 = name2;        XYDataset xydataset = createDataset(fir,sec);        JFreeChart jfreechart = createChart(xydataset);        chartpanel = new ChartPanel(jfreechart);    }    public JPanel getJPanel()    {        return chartpanel;    }    private JFreeChart createChart(XYDataset xydataset) {        JFreeChart jfreechart = ChartFactory.createXYLineChart(name1+"与"+name2+"各时刻缺页率的对比图", "时刻", "缺页率%", xydataset, PlotOrientation.VERTICAL, true, true, false);        jfreechart.setBackgroundPaint(Color.white);        XYPlot xyplot = (XYPlot)jfreechart.getPlot();        xyplot.setBackgroundPaint(Color.lightGray);        xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));        xyplot.setDomainGridlinePaint(Color.white);        xyplot.setRangeGridlinePaint(Color.white);        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer)xyplot.getRenderer();        xylineandshaperenderer.setShapesVisible(true);        xylineandshaperenderer.setShapesFilled(true);        NumberAxis numberaxis = (NumberAxis)xyplot.getRangeAxis();        numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());        return jfreechart;    }    private XYDataset createDataset(double[] fir,double[] sec) {        XYSeries xyseries = new XYSeries(name1);        for (int i = 1; i <= fir.length; i++) {            xyseries.add(i, fir[i-1]*100);        }        XYSeries xyseries1 = new XYSeries(name2);        for (int i = 1; i <= sec.length; i++) {            xyseries1.add(i, sec[i-1]*100);        }                XYSeriesCollection xyseriescollection = new XYSeriesCollection();        xyseriescollection.addSeries(xyseries);        xyseriescollection.addSeries(xyseries1);        return xyseriescollection;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -