📄 c_paint.java
字号:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
class c_paint implements paint_interface{
public void paint(int i,int x1,int y1,int x2,int y2,int mouseflag,Color c,Vector vector,Toolkit tool,JRadioButton fillt,Graphics g,TextField t1,TextField t2){
Dimension dim=tool.getScreenSize(); //获得屏幕大小
int hudu1;
int hudu2;
String str1;
String str2;
str1=t1.getText();
str2=t2.getText();
hudu1=get_int_value.getIntValue(str1);
hudu2=get_int_value.getIntValue(str2);
g.clearRect(0,0,dim.width,dim.height); //先清空一次屏幕
///////*******先绘制向量里保存的图形******////////
int vector_i=0; //下标
int fillflag; //是否填充
Color vc; //颜色
int lx1=0,ly1=0,lx2=0,ly2=0,lxs=0,lys=0,lxe=0,lye=0; //坐标
int h1=0,h2=0;
int style; //形状
while(vector_i<vector.size()){
style=(Integer)vector.get(vector_i);
lx1=(Integer)vector.get(vector_i+2);
ly1=(Integer)vector.get(vector_i+3);
lx2=(Integer)vector.get(vector_i+4);
ly2=(Integer)vector.get(vector_i+5);
fillflag=(Integer)vector.get(vector_i+1);
vc=(Color)vector.get(vector_i+6);
h1=(Integer)vector.get(vector_i+7);
h2=(Integer)vector.get(vector_i+8);
int xy[]=new int[4];
xy[0]=lx1;
xy[1]=ly1;
xy[2]=lx2;
xy[3]=ly2;
location_analyze.analyze(xy);
if(fillflag==1){
switch(style){
case 1:
g.setColor(vc);
g.fillOval(xy[0],xy[1],xy[2],xy[3]);
break;
case 2:
g.setColor(vc);
g.fillRect(xy[0],xy[1],xy[2],xy[3]);
break;
case 3:
g.setColor(vc);
g.fillRoundRect(xy[0],xy[1],xy[2],xy[3],20,20);
break;
case 4:
g.setColor(vc);
g.drawLine(lx1,ly1,lx2,ly2);
break;
case 5:
g.setColor(vc);
g.fillArc(xy[0],xy[1],xy[2],xy[3],h1,h2);
break;
case 6:
g.setColor(vc);
g.fillOval(xy[0],xy[1],xy[2],xy[2]);
break;
}
}
else{
switch(style){
case 1:
g.setColor(vc);
g.drawOval(xy[0],xy[1],xy[2],xy[3]);
break;
case 2:
g.setColor(vc);
g.drawRect(xy[0],xy[1],xy[2],xy[3]);
break;
case 3:
g.setColor(vc);
g.drawRoundRect(xy[0],xy[1],xy[2],xy[3],20,20);
break;
case 4:
g.setColor(vc);
g.drawLine(lx1,ly1,lx2,ly2);
break;
case 5:
g.setColor(vc);
g.drawArc(xy[0],xy[1],xy[2],xy[3],h1,h2);
break;
case 6:
g.setColor(vc);
g.drawOval(xy[0],xy[1],xy[2],xy[2]);
break;
}
}
// System.out.println(lxs);
vector_i+=9;
}
/////****分析坐标*****///
int xy[]=new int[4];
xy[0]=x1;
xy[1]=y1;
xy[2]=x2;
xy[3]=y2;
location_analyze.analyze(xy);
if(i==1&&mouseflag==1){
if(fillt.isSelected()){ //画填充图形
g.setColor(c);
g.fillOval(xy[0],xy[1],xy[2],xy[3]);
}
else
{
g.setColor(c);
g.drawOval(xy[0],xy[1],xy[2],xy[3]);
}
}
if(i==2&&mouseflag==1){
if(fillt.isSelected()){
g.setColor(c);
g.fillRect(xy[0],xy[1],xy[2],xy[3]);
}
else {
g.setColor(c);
g.drawRect(xy[0],xy[1],xy[2],xy[3]);}
}
if(i==3&&mouseflag==1){
if(fillt.isSelected()){
g.setColor(c);
g.fillRoundRect(xy[0],xy[1],xy[2],xy[3],20,20);
}
else {
g.setColor(c);
g.drawRoundRect(xy[0],xy[1],xy[2],xy[3],20,20);
}
}
if(i==5&&mouseflag==1){
if(fillt.isSelected()){
g.setColor(c);
g.drawArc(xy[0],xy[1],xy[2],xy[3],hudu1,hudu2);
}
else {
g.setColor(c);
g.drawArc(xy[0],xy[1],xy[2],xy[3],hudu1,hudu2);}
}
if(i==6&&mouseflag==1){
if(fillt.isSelected()){
g.setColor(c);
g.fillOval(xy[0],xy[1],xy[2],xy[2]);
}
else {
g.setColor(c);
g.drawOval(xy[0],xy[1],xy[2],xy[2]);}
}
if(mouseflag==1&&i==4){ // mouseflag为1表示鼠标划线
g.setColor(c);
g.drawLine(x1,y1,x2,y2); //x1,y1的值从mousepressed()函数中获得
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -