Java 类org.jfree.chart.ChartPanel 实例源码

项目:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud    文件:MultiLineChart.java   
public MultiLineChart(final String title, List<Users> tpaverficationUserList) {
    super(title);
    this.tpaverficationUserList = tpaverficationUserList;
    XYDataset dataset = null;
    try {
        dataset = createDataset();
    } catch (Exception e) {
        System.out.println("MultiLineChart -- Constructor" + e);
    }
    final JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(700, 470));
    setContentPane(chartPanel);
    this.pack();
    RefineryUtilities.centerFrameOnScreen(this);
    this.setVisible(true);

}
项目:iveely.ml    文件:VisualizeUtils.java   
private static void draw(final Type type,
                         final String title,
                         final String xlabel,
                         final String ylabel,
                         final DefaultCategoryDataset dataset) {
    final JFrame frame = getFrame();

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            ChartPanel chartPanel = getChart(type).createChart(title, dataset, xlabel, ylabel);
            frame.getContentPane().add(chartPanel);
            frame.setVisible(true);
        }
    });
}
项目:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud    文件:TimeandCostGraph.java   
public TimeandCostGraph(String title, int one, int two) {

        super(title);
        XYDataset dataset = null;
        try {
            dataset = createDataset();
        } catch (Exception e) {
            System.out.println("MultiLineChart -- Constructor" + e);
        }
        final JFreeChart chart = createChart(dataset);
        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(700, 470));
        setContentPane(chartPanel);
        this.pack();
        RefineryUtilities.centerFrameOnScreen(this);
        this.setVisible(true);
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    }
项目:open-java-trade-manager    文件:ChartLayerUI.java   
private Point2D.Double _getPointForCandlestick(int plotIndex, int seriesIndex, int dataIndex) {
    final ChartPanel chartPanel = this.chartJDialog.getChartPanel();
    final XYPlot plot = this.chartJDialog.getPlot(plotIndex);
    final ValueAxis domainAxis = plot.getDomainAxis();
    final RectangleEdge domainAxisEdge = plot.getDomainAxisEdge();
    final ValueAxis rangeAxis = plot.getRangeAxis();
    final RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge();

    final org.jfree.data.xy.DefaultHighLowDataset defaultHighLowDataset = (org.jfree.data.xy.DefaultHighLowDataset)plot.getDataset(seriesIndex);

    if (dataIndex >= defaultHighLowDataset.getItemCount(0)) {
        /* Not ready yet. */
        return null;
    }

    final double xValue = defaultHighLowDataset.getXDate(0, dataIndex).getTime();
    final double yValue = defaultHighLowDataset.getCloseValue(0, dataIndex);
    final Rectangle2D plotArea = chartPanel.getChartRenderingInfo().getPlotInfo().getSubplotInfo(plotIndex).getDataArea();
    final double xJava2D = domainAxis.valueToJava2D(xValue, plotArea, domainAxisEdge);
    final double yJava2D = rangeAxis.valueToJava2D(yValue, plotArea, rangeAxisEdge);
    // Use Double version, to avoid from losing precision.
    return new Point2D.Double(xJava2D, yJava2D);
}
项目:open-java-trade-manager    文件:ChartLayerUI.java   
private void updateTraceInfosIfPossible(int dataOffset) {
    // Do we have a valid mainTraceInfo?
    if (this.mainTraceInfo.point == null) {
        // Nope. Returns early.
        return;
    }
    final int newDataIndex = dataOffset + this.mainTraceInfo.dataIndex;
    if (newDataIndex < 0) {
        // We try to offset beyond chart boundary. Returns early.
    }

    /* Try to get correct main chart area. */
    final ChartPanel chartPanel = this.chartJDialog.getChartPanel();
    final Rectangle2D _plotArea = chartPanel.getChartRenderingInfo().getPlotInfo().getSubplotInfo(0).getDataArea();

    final Point2D tmpPoint = this.getPoint(0, 0, newDataIndex);
    if (tmpPoint == null || _plotArea.contains(tmpPoint) == false) {
        return;
    }

    this.mainTraceInfo = TraceInfo.newInstance(tmpPoint, 0, 0, newDataIndex);
    this.updateTraceInfos();
}
项目:financehelper    文件:PieChart.java   
public PieChart() {
    DefaultPieDataset data = getDataSet();
    JFreeChart chart = ChartFactory.createPieChart3D("水果产量", data, true, false, false);
    //设置百分比
    PiePlot pieplot = (PiePlot) chart.getPlot();
    DecimalFormat df = new DecimalFormat("0.00%");//获得一个DecimalFormat对象,主要是设置小数问题
    NumberFormat nf = NumberFormat.getNumberInstance();//获得一个NumberFormat对象
    StandardPieSectionLabelGenerator sp1 = new StandardPieSectionLabelGenerator("{0}  {2}", nf, df);//获得StandardPieSectionLabelGenerator对象
    pieplot.setLabelGenerator(sp1);//设置饼图显示百分比

    //没有数据的时候显示的内容
    pieplot.setNoDataMessage("无数据显示");
    pieplot.setCircular(false);
    pieplot.setLabelGap(0.02D);

    pieplot.setIgnoreNullValues(true);//设置不显示空值
    pieplot.setIgnoreZeroValues(true);//设置不显示负值
    frame1 = new ChartPanel(chart, true);
    chart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));//设置标题字体
    PiePlot piePlot = (PiePlot) chart.getPlot();//获取图表区域对象
    piePlot.setLabelFont(new Font("宋体", Font.BOLD, 10));//解决乱码
    chart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 10));
}
项目:ramus    文件:ChartView.java   
@Override
public JComponent createComponent() {
    ChartDataPlugin plugin = chartDataFramework
            .getChartDataPlugin(chartSource.getChartType());
    try {
        chartPanel = new ChartPanel(plugin.createChart(element));
        chartPanel.setPopupMenu(null);
    } catch (ChartNotSetupedException e) {
        JOptionPane.showMessageDialog(framework.getMainFrame(),
                ChartResourceManager.getString("Error.chartNotSetuped"));
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                close();
            }
        });
        return new JPanel();
    }
    return chartPanel;
}
项目:NystagmusJava    文件:WaveChart.java   
public WaveChart(String chartContent,String title,String yaxisName)
{
    super();
    this.chart=createChart(chartContent,title,yaxisName);
    addChart(this.chart);

    // 将JFreeChart放在专用的图表容器ChartPanel中
    this.chartPanel = new ChartPanel(this.chart);
    this.chartPanel.setPreferredSize(new Dimension(500, 350));

    // 设置chartPanel容器边框
    CompoundBorder compoundBorder = BorderFactory.createCompoundBorder(
            BorderFactory.createEmptyBorder(1, 1,1, 1),
            BorderFactory.createEtchedBorder());
    this.chartPanel.setBorder(compoundBorder);

    // 将chartPanel加入到本容器中
    add(this.chartPanel);
}
项目:jaer    文件:NetPlotter.java   
public void raster(Collection<Spike> spikes,String title)
{   
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Time"));

    // Build a plot for each layer
    for (int i=0; i<net.nLayers(); i++)
        plot.add(layerRaster(spikes,net.lay(i)),1);

    JFreeChart chart= new JFreeChart("Raster: "+title,JFreeChart.DEFAULT_TITLE_FONT, plot,true);

    // Put it in a frame!
    JFrame fr=new JFrame();
    fr.getContentPane().add(new ChartPanel(chart));
    fr.setSize(1200,1000);
    fr.setVisible(true);
}
项目:Proyecto-DASI    文件:PieChartDemo1.java   
/**
     * Creates a panel for the demo (used by SuperDemo.java).
     *
     * @return A panel.
     */
    public static JPanel createDemoPanel() {
        JFreeChart chart = createChart(createDataset());
        chart.setPadding(new RectangleInsets(4, 8, 2, 2));
        ChartPanel panel = new ChartPanel(chart);
//        panel.setMouseWheelEnabled(true);
        panel.setPreferredSize(new Dimension(600, 300));
        return panel;
    }
项目:Proyecto-DASI    文件:VisualizacionJfreechart.java   
public void showJFreeChart(int coordX, int coordY){
        //Mostrar el chart
        ChartPanel chartPanel = new ChartPanel(chart1);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);           

        this.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);               

        addWindowListener(
                new WindowAdapter(){
                        public void WindowClosing (WindowEvent e){
                           System.out.println("No quiero cerrar la ventana !!!\n");
                        }   
                }
        );


        this.pack();
//        RefineryUtilities.centerFrameOnScreen(this);

        this.setLocation(coordX, coordY);

        this.setVisible(true);              
    }
项目:Proyecto-DASI    文件:VisualizacionJfreechart.java   
public void showJFreeChart(int coordX, int coordY){
        //Mostrar el chart
        ChartPanel chartPanel = new ChartPanel(chart1);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);           

        this.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);               

        addWindowListener(
                new WindowAdapter(){
                        public void WindowClosing (WindowEvent e){
                           System.out.println("No quiero cerrar la ventana !!!\n");
                        }   
                }
        );


        this.pack();
//        RefineryUtilities.centerFrameOnScreen(this);

        this.setLocation(coordX, coordY);

        this.setVisible(true);              
    }
项目:Proyecto-DASI    文件:VisualizacionJfreechart.java   
public void  visualizarSerieChartAsignRescateVict(Color color,CategoryDataset dataset) {
     ChartPanel chartPanel = new ChartPanel(chartNotifAsigResc);
     chartNotifAsigResc.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chartNotifAsigResc.getPlot();
     plot.setBackgroundPaint(color);
     plot.setDataset(dataset);
     plot.setDomainGridlinePaint(Color.white);
     plot.setRangeGridlinePaint(Color.white);
     NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
     rangeAxis.setUpperMargin(0.15);
     CategoryItemRenderer renderer = plot.getRenderer();
     renderer.setItemLabelGenerator(new LabelGenerator(50.0));
     renderer.setItemLabelFont(new Font("Serif", Font.PLAIN, 8));
     renderer.setItemLabelsVisible(true);
     chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
   setContentPane(chartPanel);
   this.pack();
   RefineryUtilities.centerFrameOnScreen(this);
   this.setVisible(true);
}
项目:Proyecto-DASI    文件:VisualizacionJfreechart.java   
public void  visualizarSeriesTiemposRescateVictPorRobots(CategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart(
     "Tiempos de Rescate de Victimas por cada robot ", // chart title
     "Robots en el entorno", // domain axis label
     "Tiempo milisegundos", // range axis label
     dataset, // data
     PlotOrientation.VERTICAL, // orientation
     true, // include legend
     true, // tooltips?
     false // URLs?
     );
     ChartPanel chartPanel = new ChartPanel(chart);
     chart.setBackgroundPaint(Color.white);
     CategoryPlot plot = chart.getCategoryPlot();
     plot.setBackgroundPaint(Color.lightGray);
     plot.setDomainGridlinePaint(Color.white);
     plot.setRangeGridlinePaint(Color.white);
     NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
     rangeAxis.setUpperMargin(0.15);
     CategoryItemRenderer renderer = plot.getRenderer();
     renderer.setItemLabelGenerator(new LabelGenerator(50.0));
     renderer.setItemLabelFont(new Font("Serif", Font.PLAIN, 8));
     renderer.setItemLabelsVisible(true);
     chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
     this.visualizar(chartPanel);
}
项目:iveely.ml    文件:VisualizeUtils.java   
public static void drawTimeSeriesChart(final String title,
                                       final String xlabel,
                                       final String ylabel,
                                       final TimeSeriesCollection dataset) {
    final JFrame frame = getFrame();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            ChartPanel chartPanel = new TimeSeriesChart().createChart(title,
                    xlabel, ylabel, dataset);
            frame.getContentPane().add(chartPanel);
            frame.setVisible(true);
        }
    });
}
项目:iveely.ml    文件:VisualizeUtils.java   
public static void drawPie(final String title,
                           final DefaultPieDataset dataset) {
    final JFrame frame = getFrame();

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            ChartPanel chartPanel = new PieChart().createChart(title, dataset);
            frame.getContentPane().add(chartPanel);
            frame.setVisible(true);
        }
    });
}
项目:iveely.ml    文件:LineChart.java   
public ChartPanel createChart(final String title,
                              final CategoryDataset dataset,
                              final String xlabel,
                              final String ylable) {
    JFreeChart chart = ChartFactory.createLineChart(title, xlabel, ylable, dataset);
    ChartUtils.setAntiAlias(chart);
    ChartUtils.setLineRender(chart.getCategoryPlot(), false,true);//
    ChartUtils.setXAixs(chart.getCategoryPlot());
    ChartUtils.setYAixs(chart.getCategoryPlot());
    chart.getLegend().setFrame(new BlockBorder(Color.WHITE));
    ChartPanel chartPanel = new ChartPanel(chart);
    return chartPanel;
}
项目:parabuild-ci    文件:TimeSeriesChartDemo1.java   
/**
 * A demonstration application showing how to create a simple time series 
 * chart.  This example uses monthly data.
 *
 * @param title  the frame title.
 */
public TimeSeriesChartDemo1(String title) {
    super(title);
    ChartPanel chartPanel = (ChartPanel) createDemoPanel();
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
}
项目:iveely.ml    文件:ScatterPlot.java   
public JPanel createPanel(XYDataset dataset) {
    JFreeChart chart = createChart(dataset);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setVerticalAxisTrace(true);
    chartPanel.setHorizontalAxisTrace(true);
    chartPanel.setPopupMenu(null);
    chartPanel.setDomainZoomable(true);
    chartPanel.setRangeZoomable(true);
    return chartPanel;
}
项目:iveely.ml    文件:PieChart.java   
public ChartPanel createChart(String title, DefaultPieDataset dataset) {
    JFreeChart chart = ChartFactory.createPieChart(title, dataset);
    ChartUtils.setAntiAlias(chart);
    ChartUtils.setPieRender(chart.getPlot());
    chart.getLegend().setFrame(new BlockBorder(Color.WHITE));
    chart.getLegend().setPosition(RectangleEdge.RIGHT);
    ChartPanel chartPanel = new ChartPanel(chart);
    return chartPanel;
}
项目:iveely.ml    文件:StackedBarChart.java   
public ChartPanel createChart(final String title,
                              final CategoryDataset dataset,
                              final String xlabel,
                              final String ylable) {
    JFreeChart chart = ChartFactory.createStackedBarChart(title, xlabel, ylable, dataset);
    ChartUtils.setAntiAlias(chart);
    ChartUtils.setStackBarRender(chart.getCategoryPlot());
    ChartUtils.setXAixs(chart.getCategoryPlot());
    ChartUtils.setYAixs(chart.getCategoryPlot());
    chart.getLegend().setFrame(new BlockBorder(Color.WHITE));
    ChartPanel chartPanel = new ChartPanel(chart);
    return chartPanel;
}
项目:Learn4J    文件:DBSCANClustererExample.java   
public static void main(String[] args) throws Exception{

    //create the config using the builder
    DBSCANClustererConfig config = DBSCANClustererConfig.builder()
            .distance(new EuclidianSquaredDistance())//choose a distance measure
            .minDistance(3)//count all neighbours within the distance of a point
            .minDensity(4)//how many neighbours are needed for a point to be a core point
            .build();

    Clusterer c = new DBSCANClusterer(config);

    //load a dataset
    Dataset s = CSVDatasetLoader.load(new File("/home/hugo4715/sample.csv"));

    Dataset[] result = c.cluster(s);

    DefaultXYDataset d = new DefaultXYDataset();
    //fill the XY dataset
    for (int i = 0; i < result.length; i++) {
        double[] x = new double[result[i].getContent().size()];
        double[] y = new double[result[i].getContent().size()];

        for(int l = 0; l < x.length;l++){
            x[l] = result[i].getContent().get(l)[0];
            y[l] = result[i].getContent().get(l)[1];
        }
        d.addSeries((Comparable)i, new double[][]{x,y});
    }

    //show the dataset using jfreechart
    final JFreeChart pieChart = ChartFactory.createScatterPlot("title", "x","y", d);
    final ChartPanel cPanel = new ChartPanel(pieChart);
    JOptionPane.showMessageDialog(null, cPanel);
}
项目:rapidminer    文件:ChartPanelShiftController.java   
/**
 * Creates a new controller to handle plot shifts.
 * 
 * @param chartPanel
 *            The panel displaying the plot.
 */
public ChartPanelShiftController(ChartPanel chartPanel) {
    super();
    this.chartPanel = chartPanel;

    // Check to see if plot is shiftable
    Plot plot = chartPanel.getChart().getPlot();
    if ((plot instanceof XYPlot) || (plot instanceof FastScatterPlot)) {
        plotSupported = true;
        axesSwaped = isHorizontalPlot(plot);
    }
}
项目:rapidminer    文件:LinkAndBrushChartPanel.java   
/**
 * Returns the value of a {@link Field} of the {@link ChartPanel}. If the field can not be
 * found, returns {@code null}.
 * 
 * @param name
 *            the name of the {@link Field}
 * @return
 */
private Object getChartFieldValueByName(String name) {
    try {
        Field field = ChartPanel.class.getDeclaredField(name);
        field.setAccessible(true);
        Object value = field.get(this);
        field.setAccessible(false);
        return value;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
项目:rapidminer    文件:LinkAndBrushChartPanel.java   
/**
 * Returns the {@link Field} of the {@link ChartPanel}. If the field can not be found, returns
 * {@code null}.
 * 
 * @param name
 *            the name of the {@link Field}
 * @return
 */
private Field getChartFieldByName(String name) {
    try {
        Field field = ChartPanel.class.getDeclaredField(name);
        field.setAccessible(true);
        return field;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
项目:NeuralNetworksLite    文件:PlotUtil.java   
public static void plot(double[] predicts, double[] actuals, String name) {
    double[] index = new double[predicts.length];
    for (int i = 0; i < predicts.length; i++)
        index[i] = i;
    int min = minValue(predicts, actuals);
    int max = maxValue(predicts, actuals);
    final XYSeriesCollection dataSet = new XYSeriesCollection();
    addSeries(dataSet, index, predicts, "Predicts");
    addSeries(dataSet, index, actuals, "Actuals");
    final JFreeChart chart = ChartFactory.createXYLineChart(
            "Prediction Result", // chart title
            "Index", // x axis label
            name, // y axis label
            dataSet, // data
            PlotOrientation.VERTICAL,
            true, // include legend
            true, // tooltips
            false // urls
    );
    XYPlot xyPlot = chart.getXYPlot();
    // X-axis
    final NumberAxis domainAxis = (NumberAxis) xyPlot.getDomainAxis();
    domainAxis.setRange((int) index[0], (int) (index[index.length - 1] + 2));
    domainAxis.setTickUnit(new NumberTickUnit(20));
    domainAxis.setVerticalTickLabels(true);
    // Y-axis
    final NumberAxis rangeAxis = (NumberAxis) xyPlot.getRangeAxis();
    rangeAxis.setRange(min, max);
    rangeAxis.setTickUnit(new NumberTickUnit(50));
    final ChartPanel panel = new ChartPanel(chart);
    final JFrame f = new JFrame();
    f.add(panel);
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
}
项目:athena    文件:GraphGenerator.java   
public GraphGenerator(final String title) {
    super(title);
    final XYDataset dataset = createDataset();
    final JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(1000, 500));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
}
项目:open-java-trade-manager    文件:ChartLayerUI.java   
private TimeSeries getTimeSeries(int plotIndex, int seriesIndex) {
    final ChartPanel chartPanel = this.chartJDialog.getChartPanel();

    if (plotIndex >= chartPanel.getChartRenderingInfo().getPlotInfo().getSubplotCount()) {
        /* Not ready yet. */
        return null;
    }

    if (plotIndex >= this.chartJDialog.getPlotSize()) {
        /* Not ready yet. */
        return null;
    }

    final XYDataset xyDataset = this.chartJDialog.getPlot(plotIndex).getDataset();
    if (xyDataset instanceof TimeSeriesCollection) {
        final TimeSeriesCollection timeSeriesCollection = (TimeSeriesCollection)xyDataset;
        if (seriesIndex >= timeSeriesCollection.getSeriesCount()) {
            return null;
        }
        return timeSeriesCollection.getSeries(seriesIndex);
    }
    else {
        // 0 is candlestick chart.
        if (plotIndex == 0 && seriesIndex == 0) {
            return null;
        }
        if (seriesIndex >= this.chartJDialog.getPlot(plotIndex).getDatasetCount()) {
            return null;
        }
        final XYDataset d = this.chartJDialog.getPlot(plotIndex).getDataset(seriesIndex);
        return ((TimeSeriesCollection)d).getSeries(0);
    }
}
项目:NeuralNetworksLite    文件:RegressionMathFunctions.java   
private static void plot(final MathFunction function, final INDArray x, final INDArray y, final INDArray... predicted) {
    final XYSeriesCollection dataSet = new XYSeriesCollection();
    addSeries(dataSet,x,y,"True Function (Labels)");

    for( int i=0; i<predicted.length; i++ ){
        addSeries(dataSet,x,predicted[i],String.valueOf(i));
    }

    final JFreeChart chart = ChartFactory.createXYLineChart(
            "Regression Example - " + function.getName(),      // chart title
            "X",                        // x axis label
            function.getName() + "(X)", // y axis label
            dataSet,                    // data
            PlotOrientation.VERTICAL,
            true,                       // include legend
            true,                       // tooltips
            false                       // urls
    );

    final ChartPanel panel = new ChartPanel(chart);

    final JFrame f = new JFrame();
    f.add(panel);
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.pack();

    f.setVisible(true);
}
项目:financehelper    文件:TimeSeriesChart.java   
public TimeSeriesChart() {
    XYDataset xydataset = createDataset();
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General单位信托基金价格", "日期", "价格", xydataset, true, true, true);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    frame1 = new ChartPanel(jfreechart, true);
    dateaxis.setLabelFont(new Font("黑体", Font.BOLD, 14));         //水平底部标题
    dateaxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12));  //垂直标题
    ValueAxis rangeAxis = xyplot.getRangeAxis();//获取柱状
    rangeAxis.setLabelFont(new Font("黑体", Font.BOLD, 15));
    jfreechart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
    jfreechart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));//设置标题字体

}
项目:financehelper    文件:BarChart.java   
public BarChart() {
    CategoryDataset dataset = getDataSet();
    JFreeChart chart = ChartFactory.createBarChart3D(
            "水果", // 图表标题
            "水果种类", // 目录轴的显示标签
            "数量", // 数值轴的显示标签
            dataset, // 数据集
            PlotOrientation.VERTICAL, // 图表方向:水平、垂直
            true,           // 是否显示图例(对于简单的柱状图必须是false)
            false,          // 是否生成工具
            false           // 是否生成URL链接
    );

    //从这里开始
    CategoryPlot plot = chart.getCategoryPlot();//获取图表区域对象
    CategoryAxis domainAxis = plot.getDomainAxis();         //水平底部列表
    domainAxis.setLabelFont(new Font("黑体", Font.BOLD, 14));         //水平底部标题
    domainAxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12));  //垂直标题
    ValueAxis rangeAxis = plot.getRangeAxis();//获取柱状
    rangeAxis.setLabelFont(new Font("黑体", Font.BOLD, 15));
    chart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
    chart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));//设置标题字体

    //到这里结束,虽然代码有点多,但只为一个目的,解决汉字乱码问题

    frame1 = new ChartPanel(chart, true);        //这里也可以用chartFrame,可以直接生成一个独立的Frame

}
项目:financehelper    文件:IndustryTimeSeriesChart.java   
public ChartPanel getChartPanel(List<String> industrys) {
    XYDataset xydataset = createDataset(industrys);
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("行业资金流入流出", "日期(日/单位)", "价格(亿/单位)", xydataset, true, true, true);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd"));
    dateaxis.setLabelFont(new Font("黑体", Font.BOLD, 14));         //水平底部标题
    dateaxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12));  //垂直标题
    ValueAxis rangeAxis = xyplot.getRangeAxis();//获取柱状
    rangeAxis.setLabelFont(new Font("黑体", Font.BOLD, 15));
    jfreechart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
    jfreechart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));//设置标题字体
    ChartPanel frame1 = new ChartPanel(jfreechart, true);
    return frame1;
}
项目:Learn4J    文件:SingleLinkageClustererExample.java   
public static void main(String[] args) throws Exception{

    //create the config using the builder
    LinkageClustererConfig config = LinkageClustererConfig.builder()
            .distance(new EuclidianSquaredDistance())//choose a distance measure
            .clusterAmount(3)//try to find clusters
            .build();

    Clusterer c = new SingleLinkageClusterer(config);

    //load a dataset
    Dataset s = CSVDatasetLoader.load(new File("/home/hugo4715/sample.csv"));

    Dataset[] result = c.cluster(s);

    DefaultXYDataset d = new DefaultXYDataset();
    //fill the XY dataset
    for (int i = 0; i < result.length; i++) {
        double[] x = new double[result[i].getContent().size()];
        double[] y = new double[result[i].getContent().size()];

        for(int l = 0; l < x.length;l++){
            x[l] = result[i].getContent().get(l)[0];
            y[l] = result[i].getContent().get(l)[1];
        }
        d.addSeries((Comparable)i, new double[][]{x,y});
    }

    //show the dataset using jfreechart
    final JFreeChart pieChart = ChartFactory.createScatterPlot("title", "x","y", d);
    final ChartPanel cPanel = new ChartPanel(pieChart);
    JOptionPane.showMessageDialog(null, cPanel);
}
项目:ta4j    文件:BuyAndSellSignalsToChart.java   
/**
 * Displays a chart in a frame.
 * @param chart the chart to be displayed
 */
private static void displayChart(JFreeChart chart) {
    // Chart panel
    ChartPanel panel = new ChartPanel(chart);
    panel.setFillZoomRectangle(true);
    panel.setMouseWheelEnabled(true);
    panel.setPreferredSize(new Dimension(1024, 400));
    // Application frame
    ApplicationFrame frame = new ApplicationFrame("Ta4j example - Buy and sell signals to chart");
    frame.setContentPane(panel);
    frame.pack();
    RefineryUtilities.centerFrameOnScreen(frame);
    frame.setVisible(true);
}
项目:ta4j    文件:CashFlowToChart.java   
/**
 * Displays a chart in a frame.
 * @param chart the chart to be displayed
 */
private static void displayChart(JFreeChart chart) {
    // Chart panel
    ChartPanel panel = new ChartPanel(chart);
    panel.setFillZoomRectangle(true);
    panel.setMouseWheelEnabled(true);
    panel.setPreferredSize(new Dimension(1024, 400));
    // Application frame
    ApplicationFrame frame = new ApplicationFrame("Ta4j example - Cash flow to chart");
    frame.setContentPane(panel);
    frame.pack();
    RefineryUtilities.centerFrameOnScreen(frame);
    frame.setVisible(true);
}
项目:ta4j    文件:CandlestickChart.java   
/**
 * Displays a chart in a frame.
 * @param chart the chart to be displayed
 */
private static void displayChart(JFreeChart chart) {
    // Chart panel
    ChartPanel panel = new ChartPanel(chart);
    panel.setFillZoomRectangle(true);
    panel.setMouseWheelEnabled(true);
    panel.setPreferredSize(new java.awt.Dimension(740, 300));
    // Application frame
    ApplicationFrame frame = new ApplicationFrame("Ta4j example - Candlestick chart");
    frame.setContentPane(panel);
    frame.pack();
    RefineryUtilities.centerFrameOnScreen(frame);
    frame.setVisible(true);
}
项目:Wilmersdorf_SER316    文件:EnergyChart.java   
public EnergyChart(String appFrame , String chartTitle ) throws IOException {
      super(appFrame);  

        new EnergyFactory();
        _energy = EnergyFactory.getEnergy();

        JFreeChart barChart = ChartFactory.createBarChart(
         chartTitle,           
         "",            
         "Visited Frequency ",            
         createDataset(),          
         PlotOrientation.VERTICAL,           
         true, true, false);

      ChartPanel chartPanel = new ChartPanel( barChart );        
      chartPanel.setPreferredSize(new java.awt.Dimension( 560 , 367 ) );  
      setContentPane(chartPanel);

      EnergyChartDialog dlg = new EnergyChartDialog(App.getFrame(), Local.getString("Time Management/Energy Bar Chart"),chartPanel);
;

      Dimension frmSize = App.getFrame().getSize();
      Point loc = App.getFrame().getLocation();

      dlg.setLocation((frmSize.width - dlg.getSize().width) / 2 + loc.x, (frmSize.height - dlg.getSize().height) / 2 + loc.y);
     // dlg.add(jPanel4);
      dlg.setVisible(true);
      //setContentPane( chartPanel ); 
   }
项目:javaportfolio    文件:CountryAllocationPane.java   
public CountryAllocationPane(Portfolio portfolio ) {
    this.dataset = new DefaultPieDataset();
    Set<Entry<String, Double>> bookEntries = portfolio.getCountryAllocations();
    double totalValue = portfolio.getPortfolioValue();

    for (Entry<String, Double> entry : bookEntries) {
        double percentage = (Double) entry.getValue()/totalValue * 100.0 ;
        dataset.setValue(entry.getKey(), new Double(percentage) );
    }

    this.chart = ChartFactory.createPieChart(
            "Maantieteellinen jakauma", // The chart title
            dataset,         // The dataset for the chart
            false,          // Is a legend required?
            true,          // Use tooltips
            false          // Configure chart to generate URLs?
            );
    /* Creating a pieplot so as to customize the chart  generated */
    final PiePlot plot = (PiePlot)chart.getPlot( ); 

    /* Customizing Label using an inner class */

    plot.setLabelGenerator(new StandardPieSectionLabelGenerator(
            "{0} = {2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()
            ));
    // Create this panel
    this.setLayout( new GridLayout( 1, 1 ) );
    this.panel = new ChartPanel( chart );

    this.add( panel );
}
项目:StockPrediction    文件:PlotUtil.java   
public static void plot(double[] predicts, double[] actuals, String name) {
    double[] index = new double[predicts.length];
    for (int i = 0; i < predicts.length; i++)
        index[i] = i;
    int min = minValue(predicts, actuals);
    int max = maxValue(predicts, actuals);
    final XYSeriesCollection dataSet = new XYSeriesCollection();
    addSeries(dataSet, index, predicts, "Predicts");
    addSeries(dataSet, index, actuals, "Actuals");
    final JFreeChart chart = ChartFactory.createXYLineChart(
            "Prediction Result", // chart title
            "Index", // x axis label
            name, // y axis label
            dataSet, // data
            PlotOrientation.VERTICAL,
            true, // include legend
            true, // tooltips
            false // urls
    );
    XYPlot xyPlot = chart.getXYPlot();
    // X-axis
    final NumberAxis domainAxis = (NumberAxis) xyPlot.getDomainAxis();
    domainAxis.setRange((int) index[0], (int) (index[index.length - 1] + 2));
    domainAxis.setTickUnit(new NumberTickUnit(20));
    domainAxis.setVerticalTickLabels(true);
    // Y-axis
    final NumberAxis rangeAxis = (NumberAxis) xyPlot.getRangeAxis();
    rangeAxis.setRange(min, max);
    rangeAxis.setTickUnit(new NumberTickUnit(50));
    final ChartPanel panel = new ChartPanel(chart);
    final JFrame f = new JFrame();
    f.add(panel);
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
}
项目:StazioneMetereologica    文件:ChartsGenerator.java   
public void generatePrecipitazioni(){
    ChartPanel chart;
    synchronized (this.dm){
        chart = ChartsGenerator.genertateLineChart("Precipitazioni", "Timestamp", "Quantità", this.dm.getPrecipitazioni());
    }
    chart.setPreferredSize(new Dimension(this.mf.getjTabbedPane1().getWidth(), this.mf.getjTabbedPane1().getHeight()-20));
    this.mf.getjTabbedPane1().addTab("Precipitazioni", chart);
}