Shapes 2 And Shapes 3
How to copy & paste shapes?
// bad way of doing it:
if (s instanceof Rectangle) {
x = new Rectangle(s);
}
// "proper" OOP way:
Shape x = s.clone();
The proper way depends on something in the Shape class
Shape {
Shape clone() { return null; }
}
Rectangle extends Shape {
Shape clone() {
Shape R = new Rectangle();
// stuff
return R;
}
}
Updating Attribute controls
- have a method called updateAttributeControls(Shape s)
- use getters/setters
- call the method everytime something changes
Antialiasing
// in paintComponent:
Graphics2D g2 = (Graphics2D)g;
g2.setRenderHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);