如何在Java上绘制二维图形?

| 我有2个不同的清单。它们每个都有x和y值对(它们同时具有正值和负值)。如何在2D轴上绘制它们?我想为每个值加上
points
,它们将在第一个列表中显示为蓝色,在第二个列表中显示为红色。 我的列表的类型:
List<List<Double>>

List<Double> inside of List<...> has 2 variables, first of it for x value and the second one is for y value.
但是,我只需要在Java(桌面应用程序)上绘制二维图形并在需要的地方放置点,为变量改进代码就不那么重要了。 PS: 我想要那种图形的
more and more simple
: 就像是:     
已邀请:
        您可以使用http://www.jfree.org/jfreechart/(LGPL-License)之类的库,网络上有很多示例,并且非常易于使用。 这是一个符合您要求的示例: http://www.java2s.com/Code/Java/Chart/JFreeChartMarkerDemo1.htm     
        假设您将Swing与面板一起使用,则可以使用以下内容:
public class JImagePanelExample extends JPanel {

    private BufferedImage image;
    private Graphics2D drawingBoard;
    private int x, y; // Image position in the panel

    // Let\'s assume image is a chart and you need to draw lines
    public JImagePanelExample(BufferedImage image, int x, int y) {

        super();
        this.image = image;

        // Retrieving a mean to draw lines
        drawingBoard = image.createGraphics();

        // Draw what you need to draw (see other methods too)
        drawingBoard.drawLine(0, 10, 35, 55);

    }

    // Called by Swing to draw the image in the panel
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.drawImage(image, x, y, null);
    }

}
如果您不想使用Swing,而只需要绘制2D,则仅关注
BufferedImage
Graphics2D
。     
        有一个Java 2D API:http://java.sun.com/products/java-media/2D/和许多通过Web搜索轻松找到的图表库。     

要回复问题请先登录注册