dot.java

来自「Cubic Spline Interpolation」· Java 代码 · 共 62 行

JAVA
62
字号
import java.awt.*;public class Dot  implements Drawable{  public String name;  public int x, y;  public boolean xMovable;  public boolean yMovable;  public Color color;  public Drawable xSrc;  public Drawable ySrc;  public Dot( String name, int x, int y,                boolean xMovable, boolean yMovable, Color color )  {    this.name = name;    this.x = x;    this.y = y;    this.xMovable = xMovable;    this.yMovable = yMovable;    this.color = color;  }  public void paint( Graphics g )  {    if( color == null )      return;    g.setColor( color );    g.fillOval( getX() - 2, getY() - 2, 5, 5 );  }  public int getX()  {    if( xSrc != null )      x = xSrc.getX();    return x;  }  public int getY()  {    if( ySrc != null )      y = ySrc.getY();    return y;  }  public void requestMove( int x, int y )  {    if( xMovable && ( xSrc == null ) )      this.x = x;    if( yMovable && ( ySrc == null ) )      this.y = y;  }  int separation( int x, int y )  {    int dx = Math.abs( x - getX() );    int dy = Math.abs( y - getY() );    return Math.max( dx, dy );  }}

⌨️ 快捷键说明

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