📄 boundedshape.java
字号:
//********************************************************************
// BoundedShape.java Author: Lewis and Loftus / Peter DePasquale
//
// Refinement #2
//
// Represents any shape defined by a bounding rectangle.
//********************************************************************
import java.io.*;
import java.awt.*;
abstract class BoundedShape extends Shape
{
protected Point upperLeft;
protected int width, height;
//-----------------------------------------------------------------
// Sets the color, position, and size of the shape.
//-----------------------------------------------------------------
public BoundedShape (Color color, Point corner, int wide, int high)
{
strokeColor = color;
upperLeft = corner;
width = wide;
height = high;
}
//-----------------------------------------------------------------
// Sets the upper left point and the size of the shape. Allows
// for dragging in multiple directions.
//-----------------------------------------------------------------
public void setShape (Point firstPt, Point currentPt)
{
if (firstPt.x <= currentPt.x)
if (firstPt.y <= currentPt.y)
upperLeft = firstPt;
else
upperLeft = new Point (firstPt.x, currentPt.y);
else
if (firstPt.y <= currentPt.y)
upperLeft = new Point (currentPt.x, firstPt.y);
else
upperLeft = currentPt;
width = Math.abs (currentPt.x - firstPt.x);
height = Math.abs (currentPt.y - firstPt.y);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -