-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.java
More file actions
50 lines (48 loc) · 1.85 KB
/
Copy pathRectangle.java
File metadata and controls
50 lines (48 loc) · 1.85 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//henry bogardus
import java.awt.Graphics2D;
import java.awt.Color;
public class Rectangle extends Shape
{
public Rectangle(ShapeManager shapeManager, Point point1)
{
super(shapeManager, point1);
}
public void drawShape(Graphics2D g2)
{
int width = Math.abs(mPoint2.getX() - mPoint1.getX());
int height = Math.abs(mPoint2.getY() - mPoint1.getY());
g2.setColor(mFillColor);
if (mPoint2.getX() < mPoint1.getX() && mPoint2.getY() < mPoint1.getY())
{
if (mFillColor != Color.white)
g2.fillRect(mPoint2.getX(), mPoint2.getY(), width, height);
g2.setColor(mPenColor);
g2.setStroke(mLineThickness.getStrokeInformation());
g2.drawRect(mPoint2.getX(), mPoint2.getY(), width, height);
}
else if (mPoint2.getX() < mPoint1.getX())
{
if (mFillColor != Color.white)
g2.fillRect(mPoint2.getX(), mPoint1.getY(), width, height);
g2.setColor(mPenColor);
g2.setStroke(mLineThickness.getStrokeInformation());
g2.drawRect(mPoint2.getX(), mPoint1.getY(), width, height);
}
else if (mPoint2.getY() < mPoint1.getY())
{
if (mFillColor != Color.white)
g2.fillRect(mPoint1.getX(), mPoint2.getY(), width, height);
g2.setColor(mPenColor);
g2.setStroke(mLineThickness.getStrokeInformation());
g2.drawRect(mPoint1.getX(), mPoint2.getY(), width, height);
}
else
{
if (mFillColor != Color.white)
g2.fillRect(mPoint1.getX(), mPoint1.getY(), width, height);
g2.setColor(mPenColor);
g2.setStroke(mLineThickness.getStrokeInformation());
g2.drawRect(mPoint1.getX(), mPoint1.getY(), width, height);
}
}
}