简体   繁体   English

如何在 Java Swing 中将图形上的数据值显示为“x”?

[英]How to show data values on a graph as "x" in Java Swing?

I am using Swing library to plot a simple line graph.我正在使用 Swing 库来绘制一个简单的折线图。 To show the data values in the graph I use Graphics.fillOval to create a dot, which represents the data.为了在图中显示数据值,我使用 Graphics.fillOval 创建一个点,它代表数据。 But how do I show the data values as a small "x" instead of a dot?但是如何将数据值显示为一个小的“x”而不是一个点?

For example, you can draw a figure like "x" by drawing two lines.例如,您可以通过绘制两条线来绘制类似“x”的图形。

Example:例子:

void drawX(Graphics g, int x, int y, int size) {
    g.drawLine(x - size, y - size, x + size, y + size);
    g.drawLine(x + size, y - size, x - size, y + size);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM