用報(bào)表工具,JavaReporter之類(lèi)的,把類(lèi)型改為曲線(xiàn)形式的(有柱狀圖、餅狀圖什么的)
創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),宣恩企業(yè)網(wǎng)站建設(shè),宣恩品牌網(wǎng)站建設(shè),網(wǎng)站定制,宣恩網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷(xiāo),網(wǎng)絡(luò)優(yōu)化,宣恩網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M(mǎn)足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專(zhuān)業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶(hù)成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
我來(lái)講下用Java編寫(xiě)一個(gè)繪制圖形的小程序吧,你看下有沒(méi)有用
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
//不規(guī)則圖形的繪制
public class IrregularShapeDemo extends JFrame {
GeneralPath gPath= new GeneralPath(); //GeneralPath對(duì)象實(shí)例
Point aPoint;
//構(gòu)造函數(shù)
public IrregularShapeDemo() {
super("不規(guī)則圖形的繪制"); //調(diào)用父類(lèi)構(gòu)造函數(shù)
enableEvents(AWTEvent.MOUSE_EVENT_MASK|AWTEvent.MOUSE_MOTION_EVENT_MASK); //允許事件
setSize(300, 200); //設(shè)置窗口尺寸
setVisible(true); //設(shè)置窗口可視
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //關(guān)閉窗口時(shí)退出程序
}
public void paint(Graphics g) { //重載窗口組件的paint()方法
Graphics2D g2D = (Graphics2D)g; //獲取圖形環(huán)境
g2D.draw(gPath); //繪制路徑
}
public static void main(String[] args) {
new IrregularShapeDemo();
}
protected void processMouseEvent(MouseEvent e) { //鼠標(biāo)事件處理
if(e.getID() == MouseEvent.MOUSE_PRESSED) {
aPoint = e.getPoint(); //得到當(dāng)前鼠標(biāo)點(diǎn)
gPath = new GeneralPath(); //重新實(shí)例化GeneralPath對(duì)象
gPath.moveTo(aPoint.x,aPoint.y); //設(shè)置路徑點(diǎn)
}
}
protected void processMouseMotionEvent(MouseEvent e) { //鼠標(biāo)運(yùn)動(dòng)事件處理
if(e.getID() == MouseEvent.MOUSE_DRAGGED) {
aPoint = e.getPoint(); //得到當(dāng)前鼠標(biāo)點(diǎn)
gPath.lineTo(aPoint.x, aPoint.y); //設(shè)置路徑
gPath.moveTo(aPoint.x, aPoint.y);
repaint(); //重繪組件
}
}
這個(gè)也是我在遠(yuǎn)標(biāo)java上學(xué)到的,分享給你!
使用一些已有的組件幫助我們實(shí)現(xiàn)這種上傳功能。常用的上傳組件:Apache的CommonsFileUploadJavaZoom的UploadBeanjspSmartUpload以下,以FileUpload為例講解1、在jsp端要注意enctype="multipart/form-data"然后只需要放置一個(gè)file控件,并執(zhí)行submit操作即可2、web端核心代碼如下:publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{request.setCharacterEncoding("UTF-8");DiskFileItemFactoryfactory=newDiskFileItemFactory();ServletFileUploadupload=newServletFileUpload(factory);try{Listitems=upload.parseRequest(request);Iteratoritr=items.iterator();while(itr.hasNext()){FileItemitem=(FileItem)itr.next();if(item.isFormField()){System.out.println("表單參數(shù)名:"+item.getFieldName()+",表單參數(shù)值:"+item.getString("UTF-8"));}else{if(item.getName()!=null!item.getName().equals("")){System.out.println("上傳文件的大小:"+item.getSize());System.out.println("上傳文件的類(lèi)型:"+item.getContentType());System.out.println("上傳文件的名稱(chēng):"+item.getName());FiletempFile=newFile(item.getName());Filefile=newFile(sc.getRealPath("/")+savePath,tempFile.getName());item.write(file);request.setAttribute("upload.message","上傳文件成功!");}else{request.setAttribute("upload.message","沒(méi)有選擇上傳文件!");}}}}catch(FileUploadExceptione){e.printStackTrace();}catch(Exceptione){e.printStackTrace();request.setAttribute("upload.message","上傳文件失??!");}request.getRequestDispatcher("/uploadResult.jsp").forward(request,response);}