急:如何用java画曲线?? 你需要画什么曲线,一般的曲线有API可以用。特殊的曲线可以给特殊的方法 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我得函数是 y=(1-1/n)的n-1次方 怎么画,最好能详细一点, 看看这个例子,看能不能有所帮助吧import java.io.*;import java.util.*;import com.sun.image.codec.jpeg.*;import java.awt.image.*;import java.awt.*;public class jeruGraphics { BufferedImage image; // 创建 jpg 文件到指定路径下 public void createJpg(String path) { try { FileOutputStream fos = new FileOutputStream(path); BufferedOutputStream bos = new BufferedOutputStream(fos); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos); encoder.encode(image); bos.close(); } catch(FileNotFoundException fnfe) { System.out.println(fnfe); } catch(IOException ioe) { System.out.println(ioe); } } public static void main(String[] args) { int width=400, height=200; int xLength=300, yLength=150; int count=5; Vector data=new Vector(); data.addElement(new Integer(100)); data.addElement(new Integer(120)); data.addElement(new Integer(150)); data.addElement(new Integer(40)); data.addElement(new Integer(5)); jeruGraphics jg = new jeruGraphics(); jg.image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics g = jg.image.getGraphics(); // 画坐标 g.setColor(Color.white); g.fillRect(0, 0, width, height); g.setColor(Color.blue); g.drawLine(10,height-10,10,height-10-yLength); g.drawLine(10,height-10,10+xLength,height-10); // 连线 int yTo; int yFrom = ((Integer)(data.elementAt(0))).intValue(); for (int i=1; i<count; i++) { yTo=((Integer)(data.elementAt(i))).intValue(); g.drawLine(10+i*xLength/count,height-10,10+i*xLength/count,height-15); g.drawLine(10+(i-1)*xLength/count,yFrom,10+i*xLength/count,yTo); yFrom=yTo; } jg.createJpg("d:\\aaa.jpg"); }} 我的想法是画点,然后组成你要的曲线,这里就用到导数,p=(1-1/n)^(n-1) p'=-(n-1)(1/n)^(n-2)然后就是根据p(n) = p'n,然后n变化得到p(n)画出曲线来! Polygon()和他的addPoint()方法不知道可不可以 Java字体控制 已知两个路径,复制文件内容问题 HttpURLConnection cookie 问题,帮忙看一下 共同探讨《java线程》第3版o'reilly 需要一个函数 在哪里下载jspSmartUpload? 問各有關LINUX的問題 开始学java 问个基础问题 java里面有没有象MSDN一样的帮助系统啊??? 菜鸟提问,学java,该看哪些书,用什么编译器?? 用什么方法可以让JInternalFrame对象生成子窗口有最小化按钮 图片添加问题:求救!
怎么画,最好能详细一点,
import java.util.*;
import com.sun.image.codec.jpeg.*;
import java.awt.image.*;
import java.awt.*;public class jeruGraphics {
BufferedImage image;
// 创建 jpg 文件到指定路径下
public void createJpg(String path) {
try {
FileOutputStream fos = new FileOutputStream(path);
BufferedOutputStream bos = new BufferedOutputStream(fos);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);
encoder.encode(image);
bos.close();
} catch(FileNotFoundException fnfe) {
System.out.println(fnfe);
} catch(IOException ioe) {
System.out.println(ioe);
}
}
public static void main(String[] args) {
int width=400, height=200;
int xLength=300, yLength=150;
int count=5;
Vector data=new Vector();
data.addElement(new Integer(100));
data.addElement(new Integer(120));
data.addElement(new Integer(150));
data.addElement(new Integer(40));
data.addElement(new Integer(5));
jeruGraphics jg = new jeruGraphics();
jg.image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = jg.image.getGraphics();
// 画坐标
g.setColor(Color.white);
g.fillRect(0, 0, width, height);
g.setColor(Color.blue);
g.drawLine(10,height-10,10,height-10-yLength);
g.drawLine(10,height-10,10+xLength,height-10); // 连线
int yTo;
int yFrom = ((Integer)(data.elementAt(0))).intValue();
for (int i=1; i<count; i++) {
yTo=((Integer)(data.elementAt(i))).intValue();
g.drawLine(10+i*xLength/count,height-10,10+i*xLength/count,height-15);
g.drawLine(10+(i-1)*xLength/count,yFrom,10+i*xLength/count,yTo);
yFrom=yTo;
}
jg.createJpg("d:\\aaa.jpg");
}
}
然后就是根据p(n) = p'n,然后n变化得到p(n)画出曲线来!