- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLine.java
More file actions
Latest commit
28 lines (25 loc) · 1.02 KB
/
Copy pathLine.java
File metadata and controls
28 lines (25 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
* Name: Thomas Cheng
*
* Date: May 2, 2018
*
* Dsscription: This is the Line class that extends the Shape class.
*/
importjava.awt.Color;
importjava.awt.Graphics;
importjava.awt.Graphics2D;
publicclassLineextendsShape{
/* This is the constructor method for the Line class. This method accepts 5 parameters. x1, y1, x2, y2,
* representing the starting and ending coordinates of the line respectively, and a reference to a Color object.
*/
publicLine (intx1, inty1, intx2, inty2, ColorcolourOne, ColorcolourTwo, booleanisGradient, doublelineSize){
super(x1, y1, x2, y2, colourOne, colourTwo, isGradient, lineSize);
}
/* This method sets the colour of the line, and draws it onto the panel. This method accepts 1 parameters: a
* reference to a Graphics object. This method returns no values.
*/
publicvoiddraw( Graphicsg ){
Graphics2Dg2d = convertGraphics(g);
g2d.drawLine(getX1(), getY1(), getX2(), getY2());
}
}