Polygon クラス
- [内容]
- 多角形を表すクラスです.
- [主な変数]
- public int npoints
- 点(頂点)の数
- public int[] xpoints
- 各点(頂点)の x 座標
- public int[] ypoints
- 各点(頂点)の y 座標
- [コンストラクタ]
- public Polygon()
- public Polygon(int[] xpoints, int[] ypoints, int npoints)
- Polygon オブジェクトを生成する
- [主なメソッド]
- public void addPoint(int x, int y)
- 点を後ろに加える.
- public boolean contains(int x, int y)
- public boolean contains(double x, double y)
- public boolean contains(Point p)
- public boolean contains(Point2D p)
- public boolean contains(double x, double y, double w, double h)
- public boolean contains(Rectangle2D r)
- 指定された点または矩形が,多角形に含まれているか否かを返す
- public Rectangle getBounds()
- public Rectangle2D getBounds2D()
- 多角形を含む最小の矩形オブジェクトを返す
- public boolean intersects(double x, double y, double w, double h)
- public boolean intersects(Rectangle2D r)
- 指定された矩形と共通部分があるか否かを返す
- public void translate(int deltaX, int deltaY)
- x 軸及び y 軸に沿って平行移動する
- [使用例]
- プログラム例は,Polygon クラスの各メソッド等の使用例です.
- [参照]
- Point, Rectangle