java中怎么定义圆状体,java 如何画圆

当前位置:我的异常网» J2SE » java 如何画圆

java 如何画圆

www.myexceptions.net  网友分享于:2013-01-31  浏览:256次

java 怎么画圆

java   怎么画圆啊

我现在想画一个类似雷达的图,要画一组同心圆,要怎么画啊,最好圆的边框能是虚线.

------解决方案--------------------

import javax.swing.JFrame;

public class TestFrame extends JFrame {

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

TestFrame frame=new TestFrame();

frame.setBounds(0, 0, 200, 200);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.getGraphics().setColor(java.awt.Color.BLUE);

frame.getGraphics().drawOval(10, 60, 100, 100);

}

}

------解决方案--------------------

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.PolarPlot;

import org.jfree.data.xy.XYDataset;

import org.jfree.data.xy.XYSeries;

import org.jfree.data.xy.XYSeriesCollection;

import org.jfree.ui.ApplicationFrame;

import org.jfree.ui.RefineryUtilities;

public class PolarChartDemo1 extends ApplicationFrame

{

public PolarChartDemo1(String s)

{

super(s);

JPanel jpanel = createDemoPanel();

jpanel.setPreferredSize(new Dimension(600, 500));

setContentPane(jpanel);

}

private static XYDataset createDataset()

{

XYSeriesCollection xyseriescollection = new XYSeriesCollection();

XYSeries xyseries = new XYSeries( "Series 1 ");

xyseries.add(0.0D, 2D);

xyseries.add(90D, 13D);

xyseries.add(180D, 9D);

xyseries.add(270D, 8D);

xyseriescollection.addSeries(xyseries);

XYSeries xyseries1 = new XYSeries( "Series 2 ");

xyseries1.add(90D, -11.199999999999999D);

xyseries1.add(180D, 21.399999999999999D);

xyseries1.add(250D, 17.300000000000001D);

xyseries1.add(355D, 10.9D);

xyseriescollection.addSeries(xyseries1);

return xyseriescollection;

}

private static JFreeChart createChart(XYDataset xydataset)

{

JFreeChart jfreechart = ChartFactory.createPolarChart( "Polar Chart Demo 1 ", xydataset, true, false, false);

jfreechart.setBackgroundPaint(Color.white);

PolarPlot polarplot = (PolarPlot)jfreechart.getPlot();

polarplot.setBackgroundPaint(Color.lightGray);

polarplot.addCornerTextItem( "Corner Item 1 ");

polarplot.addCornerTextItem( "Corner Item 2 ");

NumberAxis numberaxis = (NumberAxis)polarplot.getAxis();

numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

return jfreechart;

}

public static JPanel createDemoPanel()

{

JFreeChart jfreechart = createChart(createDataset());

ChartPanel chartpanel = new ChartPanel(jfreechart);

chartpanel.setMouseZoomable(false);

文章评论

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值