91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 98KB
    文件類型: .zip
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-06-03
  • 語(yǔ)言: Java
  • 標(biāo)簽: java??繪圖板??

資源簡(jiǎn)介

java 小小繪圖板 各種圖形的繪制和文字的寫入,也可以調(diào)整文字畫筆的粗細(xì) 。還可以保存圖像

資源截圖

代碼片段和文件信息

package?minidrawpad;


import?java.awt.*;
import?java.awt.event.*;
import?javax.swing.*;

import?java.awt.event.MouseMotionAdapter;



//繪圖區(qū)類(各種圖形的繪制和鼠標(biāo)事件)
public?class?DrawArea?extends?JPanel{
DrawPad?drawpad?=null;
????Drawing[]?itemList?=new?Drawing[5000];;?//繪制圖形類
????
????private?int?currentChoice?=?3;//設(shè)置默認(rèn)基本圖形狀態(tài)為隨筆畫
????int?index?=?0;//當(dāng)前已經(jīng)繪制的圖形數(shù)目
????private?Color?color?=?Color.black;//當(dāng)前畫筆的顏色
????int?RGB;//用來(lái)存放當(dāng)前顏色的彩值
????int?f1f2;//用來(lái)存放當(dāng)前字體的風(fēng)格
????String?stytle?;//存放當(dāng)前字體
????float?stroke?=?1.0f;//設(shè)置畫筆的粗細(xì)?,默認(rèn)的是?1.0
DrawArea(DrawPad?dp)?{
drawpad?=?dp;
//?把鼠標(biāo)設(shè)置成十字形
setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
//?setCursor?設(shè)置鼠標(biāo)的形狀?,getPredefinedCursor()返回一個(gè)具有指定類型的光標(biāo)的對(duì)象

setBackground(Color.white);//?設(shè)置繪制區(qū)的背景是白色
addMouseListener(new?MouseA());//?添加鼠標(biāo)事件
addMouseMotionListener(new?MouseB());
?createNewitem();

}
????
public?void?paintComponent(Graphics?g){
super.paintComponent(g);
Graphics2D?g2d?=?(Graphics2D)g;//定義隨筆畫
int??j?=?0;
while(j<=index)
{
draw(g2ditemList[j]);
j++;
????}

}
void?draw(Graphics2D?g2d??Drawing?i)
{
i.draw(g2d);//將畫筆傳到個(gè)各類的子類中,用來(lái)完成各自的繪圖
}

//新建一個(gè)圖形的基本單元對(duì)象的程序段
void?createNewitem(){
if(currentChoice?==?14)//字體的輸入光標(biāo)相應(yīng)的設(shè)置為文本輸入格式
setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
else?? setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
switch(currentChoice){
case?3:?itemList[index]?=?new?Pencil();break;
case?4:?itemList[index]?=?new?Line();break;
case?5:?itemList[index]?=?new?Rect();break;
case?6:?itemList[index]?=?new?fillRect();break;
case?7:?itemList[index]?=?new?Oval();break;
case?8:?itemList[index]?=?new?fillOval();break;
case?9:?itemList[index]?=?new?Circle();break;
case?10:?itemList[index]?=?new?fillCircle();break;
case?11:?itemList[index]?=?new?RoundRect();break;
case?12:?itemList[index]?=?new?fillRoundRect();break;
case?13:?itemList[index]?=?new?Rubber();break;
case?14:?itemList[index]?=?new?Word();break;
}
??itemList[index].type?=?currentChoice;
??itemList[index].R?=?R;
??itemList[index].G?=?G;
??itemList[index].B?=?B;
??itemList[index].stroke?=?stroke?;
?
}
???
????public?void?setIndex(int?x){//設(shè)置index的接口
???? index?=?x;
????}
????public?int?getIndex(){//設(shè)置index的接口
???? return?index?;
????}
????public?void?setColor(Color?color)//設(shè)置顏色的值
????{
???? this.color?=?color;?
????}
????public?void?setStroke(float?f)//設(shè)置畫筆粗細(xì)的接口
????{
???? stroke?=?f;
????}
public?void?chooseColor()//選擇當(dāng)前顏色
{
color?=?JColorChooser.showDialog(drawpad?“請(qǐng)選擇顏色“?color);
try?{
R?=?color.getRed();
G?=?color.getGreen();
B?=?color.getBlue();
}?catch?(Exception?e)?{
R?=?0;
G?=?0;
B?=?0;
}
itemList[index].R?=?R;
itemList[index].G?=?G;
itemList[index].B?=?B;
}
public?void?setStroke()//畫筆粗細(xì)的調(diào)整
{
String?input?;
input?=?JOptionPane.showInputDialog(“請(qǐng)輸入畫筆的粗細(xì)

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2010-05-19?17:42??新建文件夾\
?????文件???????38339??2009-12-17?00:02??新建文件夾\小小繪圖板.jar
?????目錄???????????0??2010-05-19?17:42??新建文件夾\畫圖板\
?????文件?????????413??2009-12-24?11:06??新建文件夾\畫圖板\.classpath
?????文件?????????576??2009-12-24?11:06??新建文件夾\畫圖板\.project
?????目錄???????????0??2010-05-19?17:42??新建文件夾\畫圖板\.settings\
?????文件?????????629??2009-12-12?16:36??新建文件夾\畫圖板\.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2010-05-19?17:42??新建文件夾\畫圖板\bin\
?????目錄???????????0??2010-05-19?17:42??新建文件夾\畫圖板\bin\icon\
?????文件?????????939??2009-12-12?23:38??新建文件夾\畫圖板\bin\icon\circle.jpg
?????文件?????????927??2009-12-13?00:12??新建文件夾\畫圖板\bin\icon\color.jpg
?????文件?????????821??2009-12-12?23:38??新建文件夾\畫圖板\bin\icon\fcircle.jpg
?????文件?????????749??2009-12-12?23:37??新建文件夾\畫圖板\bin\icon\foval.jpg
?????文件?????????751??2009-12-12?23:33??新建文件夾\畫圖板\bin\icon\frect.jpg
?????文件?????????793??2009-12-12?23:43??新建文件夾\畫圖板\bin\icon\froundrect.jpg
?????文件?????????854??2009-12-12?23:30??新建文件夾\畫圖板\bin\icon\line.jpg
?????文件?????????919??2009-12-12?22:34??新建文件夾\畫圖板\bin\icon\newfile.jpg
?????文件????????1078??2009-12-12?22:34??新建文件夾\畫圖板\bin\icon\openfile.jpg
?????文件?????????838??2009-12-12?23:36??新建文件夾\畫圖板\bin\icon\oval.jpg
?????文件?????????900??2009-12-12?23:27??新建文件夾\畫圖板\bin\icon\pen.jpg
?????文件?????????809??2009-12-12?23:32??新建文件夾\畫圖板\bin\icon\rect.jpg
?????文件?????????898??2009-12-12?23:42??新建文件夾\畫圖板\bin\icon\roundrect.jpg
?????文件?????????879??2009-12-12?23:49??新建文件夾\畫圖板\bin\icon\rubber.jpg
?????文件?????????917??2009-12-12?22:34??新建文件夾\畫圖板\bin\icon\savefile.jpg
?????文件?????????879??2009-12-13?00:00??新建文件夾\畫圖板\bin\icon\stroke.jpg
?????文件?????????807??2009-12-12?23:56??新建文件夾\畫圖板\bin\icon\word.jpg
?????目錄???????????0??2010-05-19?17:42??新建文件夾\畫圖板\bin\minidrawpad\
?????文件?????????978??2009-12-24?11:35??新建文件夾\畫圖板\bin\minidrawpad\Circle.class
?????文件????????2782??2009-12-24?11:35??新建文件夾\畫圖板\bin\minidrawpad\DrawArea$MouseA.class
?????文件????????1761??2009-12-24?11:35??新建文件夾\畫圖板\bin\minidrawpad\DrawArea$MouseB.class
?????文件????????4641??2009-12-24?11:35??新建文件夾\畫圖板\bin\minidrawpad\DrawArea.class
............此處省略43個(gè)文件信息

評(píng)論

共有 條評(píng)論

相關(guān)資源