
package guitestmyboard;
import javaawt;
import javaawtevent;
import javaawtgeom;
import javaio;
import javautil;
import javaxswing;
//the point
//impress the info of one point,the x and y
class OnePoint implements Serializable {
int x;
int y;
int tool;
Color c;
int border;
public OnePoint(int x,int y,int tool,Color cc,int border){
thisx=x;
thisy=y;
thistool=tool;
thisc=cc;
thisborder=border;
}
}
class DrawingBoard extends Frame implements MouseListener,ItemListener,ActionListener,MouseMotionListener{
Button pen;
Button line ;
Button ellipse ;
Button rect ;
Button clear ;
Button colorboard ;
Button storebutton;
Button openbutton;
Choice sizechoice ;
Choice colorchoice ;
Label pensize;
Label pencolor;
Panel panel ;
FileDialog storefile;
FileDialog openfile;
FileInputStream filein;
FileOutputStream fileout;
ObjectInputStream objectin;
ObjectOutputStream objectout;
int flagtool=0;
Color flagcolor;
int border;
BasicStroke size;
OnePoint p1,p2;
Vector<OnePoint> points=new Vector<OnePoint>();
public DrawingBoard(){
pen=new Button("画笔");
line=new Button("直线");
ellipse=new Button("圆");
rect=new Button("矩形");
clear=new Button("清除");
colorboard=new Button("调色板");
storebutton=new Button("存储文件");
openbutton=new Button("打开文件");
pensize=new Label("画笔大小");
pencolor=new Label("画笔颜色");
storefile=new FileDialog(this,"存储文件",FileDialogSAVE);
storefilesetVisible(false);
storefileaddWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
storefilesetVisible(false);
}
});
openfile=new FileDialog(this,"打开文件",FileDialogLOAD);
openfilesetVisible(false);
openfileaddWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
openfilesetVisible(false);
}
});
sizechoice=new Choice();
sizechoiceadd("1");
sizechoiceadd("2");
sizechoiceadd("4");
sizechoiceadd("6");
sizechoiceadd("8");
sizechoiceaddItemListener(this);
colorchoice=new Choice();
colorchoiceadd("black");
colorchoiceadd("red");
colorchoiceadd("blue");
colorchoiceadd("green");
colorchoiceaddItemListener(this);
penaddActionListener(this);
lineaddActionListener(this);
ellipseaddActionListener(this);
rectaddActionListener(this);
clearaddActionListener(this);
colorboardaddActionListener(this);
storebuttonaddActionListener(this);
openbuttonaddActionListener(this);
panel=new Panel();
paneladd(storebutton);
paneladd(openbutton);
paneladd(pen);
paneladd(line);
paneladd(ellipse);
paneladd(rect);
paneladd(clear);
paneladd(sizechoice);
paneladd(pensize);
paneladd(colorchoice);
paneladd(pencolor);
paneladd(colorboard);
add(panel,BorderLayoutNORTH);
setBounds(100,100,700,600);
setVisible(true);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
Systemexit(0);
}
});
/
添加鼠标事件的监听器,否则,鼠标的移动和点击都将无法识别!
/
addMouseListener(this);
addMouseMotionListener(this);
}
public void paint(Graphics g){
Graphics2D g2d=(Graphics2D)g;
if(flagtool==2){ //qing chu
gclearRect(0,0,getSize()width,getSize()height);
}
for(int i=0;i<pointssize()-1;i++){
p1=(OnePoint)pointselementAt(i);
p2=(OnePoint)pointselementAt(i+1);
g2dsetColor(p1c); //////////////需要使用Graphics2D从Graphics类中继承下来的方法 setColor()设置当前的颜色
size=new BasicStroke(p1border,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);
g2dsetStroke(size);
if(p1tool==p2tool){
switch(p1tool){
case 0:
Line2DDouble line1=new Line2DDouble(p1x,p1y,p2x,p2y);
g2ddraw(line1);
break;
case 1:
Line2DDouble line2=new Line2DDouble(p1x,p1y,p2x,p2y);
g2ddraw(line2);
break;
case 3:
Ellipse2DDouble ellipse=new Ellipse2DDouble(p1x,p1y,Mathabs(p2x-p1x),Mathabs(p2y-p1y));
g2ddraw(ellipse);
break;
case 4:
Rectangle2DDouble rect=new Rectangle2DDouble(p1x,p1y,Mathabs(p2x-p1x),Mathabs(p2y-p1y));
g2ddraw(rect);
break;
default:
}
}
}
}
public void mouseClicked(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mousePressed(MouseEvent e) { //鼠标点下时候,将当前的点信息记录
OnePoint pp1=new OnePoint(egetX(),egetY(),flagtool,flagcolor,border);
pointsaddElement(pp1);
//repaint();
}
public void mouseReleased(MouseEvent e) {//鼠标松开时候,如果是画笔,则当前截断,是其余状态记下一枚点信息
if(flagtool==0){
pointsaddElement(new OnePoint(-1,-1,22,flagcolor,border));
}
else{
OnePoint pp2=new OnePoint(egetX(),egetY(),flagtool,flagcolor,border);
pointsaddElement(pp2);
pointsadd(new OnePoint(-1,-1,22,flagcolor,border));
}
repaint();
}
public void itemStateChanged(ItemEvent e) {
if(egetSource()==colorchoice){
String selected=colorchoicegetSelectedItem();
if(selected=="black"){
flagcolor=new Color(0,0,0);
}
else if(selected=="red"){
flagcolor=new Color(255,0,0);
}
else if(selected=="blue"){
flagcolor=new Color(0,0,255);
}
else if(selected=="green"){
flagcolor=new Color(0,255,0);
}
}
else if(egetSource()==sizechoice){
String selected=sizechoicegetSelectedItem();
if (selected=="1"){
border=1;
}
else if(selected=="2"){
border=22;
}
else if(selected=="4"){
border=42;
}
else if(selected=="6"){
border=62;
}
else if(selected=="8"){
border=82;
}
}
}
public void update(Graphics g) { //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
paint(g);
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(egetSource()==pen){
flagtool=0;
}
else if(egetSource()==line){
flagtool=1;
}
else if(egetSource()==clear){
flagtool=2;
pointsremoveAllElements();
repaint(); //此语要有,否则今生无法删除!
}
else if(egetSource()==ellipse){
flagtool=3;
}
else if(egetSource()==rect){
flagtool=4;
}
else if(egetSource()==colorboard){
/
使用 javaxswing×包中的 JColorChooser 类的静态方法showDialog(Component component,String title,Color color ),
该方法的参数,component是当前显示对话框的父框架,color是设置调色板初始的被选颜色
该方法返回被选的颜色,类型为Color
/
Color color=JColorChoosershowDialog(this, "调色板",flagcolor);
flagcolor=color;
}
else if(egetSource()==openbutton){
openfilesetVisible(true);
if(openfilegetFile()!=null){
int temp=flagtool;
flagtool=2;
repaint();
try{
pointsremoveAllElements();
File file=new File(openfilegetDirectory(),openfilegetFile());
filein=new FileInputStream(file);
objectin=new ObjectInputStream(filein);
points=(Vector)objectinreadObject();
objectinclose();
fileinclose();
flagtool=temp;
repaint();
}
catch(Exception ee){
Systemoutprintln(eetoString());
}
}
}
else if(egetSource()==storebutton){
storefilesetVisible(true);
if(storefilegetFile()!=null){
try {
File file=new File(storefilegetDirectory(),storefilegetFile());
fileout=new FileOutputStream(file);
objectout=new ObjectOutputStream(fileout);
objectoutwriteObject(points);
objectoutclose();
fileoutclose();
repaint();
}
catch (FileNotFoundException e1) {
Systemoutprintln(e1toString());
e1printStackTrace();
} catch (IOException ee) {
Systemoutprintln(eetoString());
eeprintStackTrace();
}
}
}
}
public void mouseDragged(MouseEvent e) {//鼠标拖动时候,//当且仅当 flagtool==0,或者表示为橡皮的时候
//才将拖动过程中涉及到的点全部记录下来,并且调用repain()方法,重画当前
// TODO Auto-generated method stub
if(flagtool==0){
OnePoint pp3=new OnePoint(egetX(),egetY(),flagtool,flagcolor,border);
pointsaddElement(pp3);
repaint();
}
}
public void mouseMoved(MouseEvent e) {
// TODO Auto-generated method stub
}
}
public class PaintBoard{
public static void main(String[] args){
DrawingBoard oneBorder=new DrawingBoard();
}
}
import javaapplet;
import javaawt;
import javaawtevent;
import javautil;
import javaxswing;
import javaawtgeom;
import javaio;
class Point implements Serializable
{
int x,y;
Color col;
int tool;
int boarder;
Point(int x, int y, Color col, int tool, int boarder)
{
thisx = x;
thisy = y;
thiscol = col;
thistool = tool;
thisboarder = boarder;
}
}
class paintboard extends Frame implements ActionListener,MouseMotionListener,MouseListener,ItemListener
{
int x = -1, y = -1;
int con = 1;//画笔大小
int Econ = 5;//橡皮大小
int toolFlag = 0;//toolFlag:工具标记
//toolFlag工具对应表:
//(0--画笔);(1--橡皮);(2--清除);
//(3--直线);(4--圆);(5--矩形);
Color c = new Color(0,0,0); //画笔颜色
BasicStroke size = new BasicStroke(con,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);//画笔粗细
Point cutflag = new Point(-1, -1, c, 6, con);//截断标志
Vector paintInfo = null;//点信息向量组
int n = 1;
FileInputStream picIn = null;
FileOutputStream picOut = null;
ObjectInputStream VIn = null;
ObjectOutputStream VOut = null;
// 工具面板--画笔,直线,圆,矩形,多边形,橡皮,清除/
Panel toolPanel;
Button eraser, drLine,drCircle,drRect;
Button clear ,pen;
Choice ColChoice,SizeChoice,EraserChoice;
Button colchooser;
Label 颜色,大小B,大小E;
//保存功能
Button openPic,savePic;
FileDialog openPicture,savePicture;
paintboard(String s)
{
super(s);
addMouseMotionListener(this);
addMouseListener(this);
paintInfo = new Vector();
/各工具按钮及选择项/
//颜色选择
ColChoice = new Choice();
ColChoiceadd("black");
ColChoiceadd("red");
ColChoiceadd("blue");
ColChoiceadd("green");
ColChoiceaddItemListener(this);
//画笔大小选择
SizeChoice = new Choice();
SizeChoiceadd("1");
SizeChoiceadd("3");
SizeChoiceadd("5");
SizeChoiceadd("7");
SizeChoiceadd("9");
SizeChoiceaddItemListener(this);
//橡皮大小选择
EraserChoice = new Choice();
EraserChoiceadd("5");
EraserChoiceadd("9");
EraserChoiceadd("13");
EraserChoiceadd("17");
EraserChoiceaddItemListener(this);
////////////////////////////////////////////////////
toolPanel = new Panel();
clear = new Button("清除");
eraser = new Button("橡皮");
pen = new Button("画笔");
drLine = new Button("画直线");
drCircle = new Button("画圆形");
drRect = new Button("画矩形");
openPic = new Button("打开图画");
savePic = new Button("保存图画");
colchooser = new Button("显示调色板");
//各组件事件监听
clearaddActionListener(this);
eraseraddActionListener(this);
penaddActionListener(this);
drLineaddActionListener(this);
drCircleaddActionListener(this);
drRectaddActionListener(this);
openPicaddActionListener(this);
savePicaddActionListener(this);
colchooseraddActionListener(this);
颜色 = new Label("画笔颜色",LabelCENTER);
大小B = new Label("画笔大小",LabelCENTER);
大小E = new Label("橡皮大小",LabelCENTER);
//面板添加组件
toolPaneladd(openPic);
toolPaneladd(savePic);
toolPaneladd(pen);
toolPaneladd(drLine);
toolPaneladd(drCircle);
toolPaneladd(drRect);
toolPaneladd(颜色); toolPaneladd(ColChoice);
toolPaneladd(大小B); toolPaneladd(SizeChoice);
toolPaneladd(colchooser);
toolPaneladd(eraser);
toolPaneladd(大小E); toolPaneladd(EraserChoice);
toolPaneladd(clear);
//工具面板到APPLET面板
add(toolPanel,BorderLayoutNORTH);
setBounds(60,60,900,600); setVisible(true);
validate();
//dialog for save and load
openPicture = new FileDialog(this,"打开图画",FileDialogLOAD);
openPicturesetVisible(false);
savePicture = new FileDialog(this,"保存图画",FileDialogSAVE);
savePicturesetVisible(false);
openPictureaddWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{ openPicturesetVisible(false); }
});
savePictureaddWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{ savePicturesetVisible(false); }
});
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{ Systemexit(0);}
});
}
public void paint(Graphics g)
{
Graphics2D g2d = (Graphics2D)g;
Point p1,p2;
n = paintInfosize();
if(toolFlag==2)
gclearRect(0,0,getSize()width,getSize()height);//清除
for(int i=0; i<n ;i++){
p1 = (Point)paintInfoelementAt(i);
p2 = (Point)paintInfoelementAt(i+1);
size = new BasicStroke(p1boarder,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);
g2dsetColor(p1col);
g2dsetStroke(size);
if(p1tool==p2tool)
{
switch(p1tool)
{
case 0://画笔
Line2D line1 = new Line2DDouble(p1x, p1y, p2x, p2y);
g2ddraw(line1);
break;
case 1://橡皮
gclearRect(p1x, p1y, p1boarder, p1boarder);
break;
case 3://画直线
Line2D line2 = new Line2DDouble(p1x, p1y, p2x, p2y);
g2ddraw(line2);
break;
case 4://画圆
Ellipse2D ellipse = new Ellipse2DDouble(p1x, p1y, Mathabs(p2x-p1x) , Mathabs(p2y-p1y));
g2ddraw(ellipse);
break;
case 5://画矩形
Rectangle2D rect = new Rectangle2DDouble(p1x, p1y, Mathabs(p2x-p1x) , Mathabs(p2y-p1y));
g2ddraw(rect);
break;
case 6://截断,跳过
i=i+1;
break;
default :
}//end switch
}//end if
}//end for
}
public void itemStateChanged(ItemEvent e)
{
if(egetSource()==ColChoice)//预选颜色
{
String name = ColChoicegetSelectedItem();
if(name=="black")
{c = new Color(0,0,0); }
else if(name=="red")
{c = new Color(255,0,0);}
else if(name=="green")
{c = new Color(0,255,0);}
else if(name=="blue")
{c = new Color(0,0,255);}
}
else if(egetSource()==SizeChoice)//画笔大小
{
String selected = SizeChoicegetSelectedItem();
if(selected=="1")
{
con = 1;
size = new BasicStroke(con,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);
}
else if(selected=="3")
{
con = 3;
size = new BasicStroke(con,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);
}
else if(selected=="5")
{con = 5;
size = new BasicStroke(con,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);
}
else if(selected=="7")
{con = 7;
size = new BasicStroke(con,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);
}
else if(selected=="9")
{con = 9;
size = new BasicStroke(con,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);
}
}
else if(egetSource()==EraserChoice)//橡皮大小
{
String Esize = EraserChoicegetSelectedItem();
if(Esize=="5")
{ Econ = 52; }
else if(Esize=="9")
{ Econ = 92; }
else if(Esize=="13")
{ Econ = 132; }
else if(Esize=="17")
{ Econ = 173; }
}
}
public void mouseDragged(MouseEvent e)
{
Point p1 ;
switch(toolFlag){
case 0://画笔
x = (int)egetX();
y = (int)egetY();
p1 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p1);
repaint();
break;
case 1://橡皮
x = (int)egetX();
y = (int)egetY();
p1 = new Point(x, y, null, toolFlag, Econ);
paintInfoaddElement(p1);
repaint();
break;
default :
}
}
public void mouseMoved(MouseEvent e) {}
public void update(Graphics g)
{
paint(g);
}
public void mousePressed(MouseEvent e)
{
Point p2;
switch(toolFlag){
case 3://直线
x = (int)egetX();
y = (int)egetY();
p2 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p2);
break;
case 4: //圆
x = (int)egetX();
y = (int)egetY();
p2 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p2);
break;
case 5: //矩形
x = (int)egetX();
y = (int)egetY();
p2 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p2);
break;
default :
}
}
public void mouseReleased(MouseEvent e)
{
Point p3;
switch(toolFlag){
case 0://画笔
paintInfoaddElement(cutflag);
break;
case 1: //eraser
paintInfoaddElement(cutflag);
break;
case 3://直线
x = (int)egetX();
y = (int)egetY();
p3 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p3);
paintInfoaddElement(cutflag);
repaint();
break;
case 4: //圆
x = (int)egetX();
y = (int)egetY();
p3 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p3);
paintInfoaddElement(cutflag);
repaint();
break;
case 5: //矩形
x = (int)egetX();
y = (int)egetY();
p3 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p3);
paintInfoaddElement(cutflag);
repaint();
break;
default:
}
}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
public void actionPerformed(ActionEvent e)
{
if(egetSource()==pen)//画笔
{toolFlag = 0;}
if(egetSource()==eraser)//橡皮
{toolFlag = 1;}
if(egetSource()==clear)//清除
{
toolFlag = 2;
paintInforemoveAllElements();
repaint();
}
if(egetSource()==drLine)//画线
{toolFlag = 3;}
if(egetSource()==drCircle)//画圆
{toolFlag = 4;}
if(egetSource()==drRect)//画矩形
{toolFlag = 5;}
if(egetSource()==colchooser)//调色板
{
Color newColor = JColorChoosershowDialog(this,"调色板",c);
c = newColor;
}
if(egetSource()==openPic)//打开图画
{
openPicturesetVisible(true);
if(openPicturegetFile()!=null)
{
int tempflag;
tempflag = toolFlag;
toolFlag = 2 ;
repaint();
try{
paintInforemoveAllElements();
File filein = new File(openPicturegetDirectory(),openPicturegetFile());
picIn = new FileInputStream(filein);
VIn = new ObjectInputStream(picIn);
paintInfo = (Vector)VInreadObject();
VInclose();
repaint();
toolFlag = tempflag;
}
catch(ClassNotFoundException IOe2)
{
repaint();
toolFlag = tempflag;
Systemoutprintln("can not read object");
}
catch(IOException IOe)
{
repaint();
toolFlag = tempflag;
Systemoutprintln("can not read file");
}
}
}
if(egetSource()==savePic)//保存图画
{
savePicturesetVisible(true);
try{
File fileout = new File(savePicturegetDirectory(),savePicturegetFile());
picOut = new FileOutputStream(fileout);
VOut = new ObjectOutputStream(picOut);
VOutwriteObject(paintInfo);
VOutclose();
}
catch(IOException IOe)
{
Systemoutprintln("can not write object");
}
}
}
}//end paintboard
public class pb
{
public static void main(String args[])
{ new paintboard("画图程序"); }
}
很多同学都关心Java学到什么程度才可以找到满意的工作。大家的目标都很明确,也很实在,学习Java无非就是为了找工作。
那到底要学多少Java知识,掌握多少技能,才可以找到一份满意的工作呢?
其实想要找一份小公司的开发工作不算非常难,毕竟互联网公司很多,要求也是天差地别,对技术、学历、实践能力的要求和评价标准也有很大的差距。但是进大厂的要求可就非常高了。
所以,到底Java学到什么程度才能找到第一份工作,我想应该用公司来作为变量,这样回答这个问题才有意义。
1、中小型公司
说到中小型公司,我们泛指那些500名以下员工,有稳定资金来源并且可以自我造血的公司,这类公司招聘和培训可能会有自己的一套标准。
比如学历上可能稍微做一些要求,技术上的把关更严格一点,除了Java基础知识和项目经历之外,可能还会考查你的debug能力,代码规范、异常处理能力,以及对一些Java高级特性的理解能力,以及框架的应用水平。
总而言之,这类公司选人的标准更加有体系,标准也更高。
2、二三线互联网公司
这类公司范围就很广了,比如搜狐、新浪、360、携程这类现状比较不错的企业等等,这类公司挤不到BAT TMD等一线互联网行列,但是在二三线阵容还算是比较不错的公司,它们对于人才的要求其实还是相对比较高的。
比如一般都会要求本科学历,对Java基础知识要比较熟悉,最好能够看过源码,如果没看过,那么源码方面的面试题好歹也要准备一下,除此之外,一般来说还会考察你的后端技术知识,比如数据库、网络、 *** 作系统,考察的不会太难,能把面经上的知识点掌握了就算是比较扎实了。
这类公司一般不会考太复杂的题目,更希望招一些水平能力都是中上等的人才,只要知识面能比较广,题目都能说到点子上,也可以有机会拿到offer。
3、一线互联网公司
BAT、TMD等互联网名企都属于这类公司,这类公司和二三线互联网公司的发展差距还是比较大的,体现在公司的规模、市值、甚至是股价等方面,业务以技术为基础,因此这些公司的技术往往也是业界最顶尖的,比如阿里的云计算和中间件,头条的推荐算法、腾讯的游戏技术等等。
要进这些公司,不仅要做到之前那些事情:掌握Java基础、计算机基础知识,并且是非常熟练地掌握,你需要深入理解每一个知识点,因为面试官会不断深入地向你提问,了解你的知识深度,同时,你需要对源码有所理解,在读懂源码的基础上去理解框架的实现、JDK的实现。
并且,你还需要对Java并发编程和网络编程的使用方法与底层实现原理非常熟悉,不仅仅答出NIO和BIO的区别,或者是synchronized和lock的区别,你还需要知道NIO的底层实现epoll是什么,synchronized对应的mutex lock是什么,lock和condition的实现原理又是什么,而lock本身也是通过AQS、CAS *** 作类等组件来实现的,其中的内容实在太多,绝不只是几道面试题就可以搞定的。
当然,除此之外,这些公司对数据库、缓存、分布式技术等方面的要求都会比其他公司要高得多,你最好要搞懂MySQL的存储引擎、索引和锁的实现原理,Redis缓存的数据结构、备份方式、底层实现。
同时如果你能理解负载均衡算法、CAP理论,甚至是raft和paxos算法,以及分布式常用技术如消息队列、zookeeper等等,那么无疑也是可以为你加分的技能。
分享下学习路线,按照上面的路线学习,学完后找到工作不成问题!
世上无难事,只怕有心人,只要你真的想学并努力去学,你就能成功。
另外,如果自学没有资料的话,可私聊我获取,免费提供哦~
希望能帮到你,望采纳!
以上就是关于nvenccapcontext是什么程序全部的内容,包括:nvenccapcontext是什么程序、图形学编程、用php写一个网页程序,功能是判断服务器上QQ程序运行了多长时间等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)