-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyRectangle.java
More file actions
40 lines (34 loc) · 984 Bytes
/
MyRectangle.java
File metadata and controls
40 lines (34 loc) · 984 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package java2ddrawingapplication;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Point;
import java.awt.Stroke;
import java.awt.geom.Rectangle2D;
/**
*
* @author Ismael Youssef
*/
public class MyRectangle extends MyBoundedShapes{
public MyRectangle(Point pntA, Point pntB, Paint paint, Stroke strk, boolean filled)
{
super(pntA, pntB, paint, strk, filled);
}
@Override
public void draw(Graphics2D g2d)
{
g2d.setPaint(getPaint());
g2d.setStroke(getStroke());
if(isFilled())
{
g2d.fill(new Rectangle2D.Double(getTopLeftX(), getTopLeftY(), getWidth(), getHeight()));
}
else
{
g2d.draw(new Rectangle2D.Double(getTopLeftX(), getTopLeftY(), getWidth(), getHeight()));
}
}
}