📄 line.java
字号:
//********************************************************************
// Line.java Author: Lewis and Loftus / Peter DePasquale
//
// Refinement #2
//
// Represents a line shape in the PaintBox application.
//********************************************************************
import java.io.*;
import java.awt.*;
public class Line extends Shape
{
protected Point firstPoint;
protected Point secondPoint;
//-----------------------------------------------------------------
// Sets up the line with a particular position and color.
//-----------------------------------------------------------------
public Line (Color color, Point p1, Point p2)
{
strokeColor = color;
firstPoint = p1;
secondPoint = p2;
}
//-----------------------------------------------------------------
// Sets the second point of the line.
//-----------------------------------------------------------------
public void setEndPoint (Point endPoint)
{
secondPoint = endPoint;
}
//-----------------------------------------------------------------
// Draws the line.
//-----------------------------------------------------------------
public void draw (Graphics page)
{
page.setColor (strokeColor);
page.drawLine (firstPoint.x, firstPoint.y, secondPoint.x,
secondPoint.y);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -