circle.java

来自「java语言实现的一个画图小程序,可以实现绘图」· Java 代码 · 共 44 行

JAVA
44
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package drawfigure;import java.awt.Color; class Circle extends Shape{//定义圆类,继承了形状类  public Circle(){}  public Circle(int sx,int sy,int x,int y,Color c,boolean f){    super(sx,sy,x,y,c);fill=f;i=2;  }  void setValue(int sx,int sy,int x,int y,Color c,boolean f){    super.setValue(sx,sy,x,y,c);fill=f;i=2;  }    @Override  void draw()  {    x0=x>sx?sx:x;y0=y>sy?sy:y;    g.setColor(c);    g.setPaintMode();    if(!fill)    {     g.drawOval(x0,y0,Math.abs(x-sx),Math.abs(y-sy));     }    else     {        g.fillOval(x0,y0,Math.abs(x-sx),Math.abs(y-sy));     }  }  void wipe()  {    x0=x>sx?sx:x;y0=y>sy?sy:y;    g.setXORMode(back);                    if(!fill)    {     g.drawOval(x0,y0,Math.abs(x-sx),Math.abs(y-sy));     }    else     {        g.fillOval(x0,y0,Math.abs(x-sx),Math.abs(y-sy));     }   }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?