当前位置: 技术问答>java相关
画图的问题,清高手指点
来源: 互联网 发布时间:2017-03-28
本文导语: 我要写个程序:把数据库中读出的数据画成曲线,这条曲线有坐标的,而且我还要有比例,这方面的东西我不懂,怎么实现它,清高手指点指点。 能不能给个小的例子,谢谢先! 祝大家Merry Christmas!!! ...
我要写个程序:把数据库中读出的数据画成曲线,这条曲线有坐标的,而且我还要有比例,这方面的东西我不懂,怎么实现它,清高手指点指点。
能不能给个小的例子,谢谢先!
祝大家Merry Christmas!!!
能不能给个小的例子,谢谢先!
祝大家Merry Christmas!!!
|
package statistics;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class zhe extends Applet {
int x[]={10,60,110,160,210,260};
int y[]={40,100,250,90,30,200};
public void paint(Graphics g){
g.setColor(Color.blue);
g.drawLine(10,20,10,280);
g.drawLine(10,280,280,280);
g.drawLine(5,25,10,20);
g.drawLine(10,20,15,25);
g.drawLine(275,275,280,280);
g.drawLine(275,285,280,280);
g.setColor(Color.white);
g.drawPolyline(x,y,6);
g.setColor(Color.red);
g.drawString("甲厂",15,35);
g.drawString("乙厂",65,95);
g.drawString("丙厂",115,245);
g.drawString("丁厂",145,85);
g.drawString("戊厂",215,25);
g.drawString("己厂",265,195);
}
boolean isStandalone = false;
/**Get a parameter value*/
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
/**Construct the applet*/
public zhe() {
}
/**Initialize the applet*/
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception {
}
/**Get Applet information*/
public String getAppletInfo() {
return "Applet Information";
}
/**Get parameter info*/
public String[][] getParameterInfo() {
return null;
}
}
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class zhe extends Applet {
int x[]={10,60,110,160,210,260};
int y[]={40,100,250,90,30,200};
public void paint(Graphics g){
g.setColor(Color.blue);
g.drawLine(10,20,10,280);
g.drawLine(10,280,280,280);
g.drawLine(5,25,10,20);
g.drawLine(10,20,15,25);
g.drawLine(275,275,280,280);
g.drawLine(275,285,280,280);
g.setColor(Color.white);
g.drawPolyline(x,y,6);
g.setColor(Color.red);
g.drawString("甲厂",15,35);
g.drawString("乙厂",65,95);
g.drawString("丙厂",115,245);
g.drawString("丁厂",145,85);
g.drawString("戊厂",215,25);
g.drawString("己厂",265,195);
}
boolean isStandalone = false;
/**Get a parameter value*/
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
/**Construct the applet*/
public zhe() {
}
/**Initialize the applet*/
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception {
}
/**Get Applet information*/
public String getAppletInfo() {
return "Applet Information";
}
/**Get parameter info*/
public String[][] getParameterInfo() {
return null;
}
}
|
柱状案例分析
package statistics;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class rect extends Applet {
boolean isStandalone = false;
Color color1=new Color(255,0,0);
Color color2=new Color(0,255,0);
Color color3=new Color(0,0,255);
public void paint(Graphics g){
g.drawLine(20,50,20,250);
g.drawLine(20,50,200,50);
g.setColor(color1);
g.drawString("条形统计图",40,20);
g.fillRect(20,50,40,150);
g.setColor(color2);
g.fillRect(80,50,40,100);
g.setColor(color3);
g.fillRect(140,50,40,130);
}
/**Get a parameter value*/
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
/**Construct the applet*/
public rect() {
}
/**Initialize the applet*/
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception {
}
/**Get Applet information*/
public String getAppletInfo() {
return "Applet Information";
}
/**Get parameter info*/
public String[][] getParameterInfo() {
return null;
}
}
package statistics;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class rect extends Applet {
boolean isStandalone = false;
Color color1=new Color(255,0,0);
Color color2=new Color(0,255,0);
Color color3=new Color(0,0,255);
public void paint(Graphics g){
g.drawLine(20,50,20,250);
g.drawLine(20,50,200,50);
g.setColor(color1);
g.drawString("条形统计图",40,20);
g.fillRect(20,50,40,150);
g.setColor(color2);
g.fillRect(80,50,40,100);
g.setColor(color3);
g.fillRect(140,50,40,130);
}
/**Get a parameter value*/
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
/**Construct the applet*/
public rect() {
}
/**Initialize the applet*/
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception {
}
/**Get Applet information*/
public String getAppletInfo() {
return "Applet Information";
}
/**Get parameter info*/
public String[][] getParameterInfo() {
return null;
}
}
|
http://java.sun.com/docs/books/tutorial/2d/index.html
|
我的QQ:110304916
我也在做这方面的东西,和我联系
我也在做这方面的东西,和我联系
|
画过柱图没画过曲线
|
到这个网站下载个柱状的例子
http://www.jpowered.com/graph_chart/index.htm
参考下
http://www.jpowered.com/graph_chart/index.htm
参考下