只是对气垫船充满鳗鱼的解决方案的补充:
我重新设计了他的代码,对其进行了一些微调,添加了网格,轴标签,现在Y轴从当前的最小值变为最大值。我计划添加一些吸气剂/吸气剂,但我不需要它们,可以根据需要添加它们。
这是Gist链接,我还将粘贴以下代码:Gist上的GraphPanel
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.Stroke;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class GraphPanel extends JPanel {
private int width = 800;
private int heigth = 400;
private int padding = 25;
private int labelPadding = 25;
private Color lineColor = new Color(44, 102, 230, 180);
private Color pointColor = new Color(100, 100, 100, 180);
private Color gridColor = new Color(200, 200, 200, 200);
private static final Stroke GRAPH_STROKE = new BasicStroke(2f);
private int pointWidth = 4;
private int numberYDivisions = 10;
private List scores;
public GraphPanel(List scores) {
this.scores = scores;
}
@Override