import java.awt.*; import java.awt.geom.Line2D.*; import java.awt.geom.*; public abstract class ComponentView { protected Point center; // center of this component protected Color color = Color.BLACK; protected Rectangle body; // componentīs region on the screen public ComponentView() { body = null; center = null; } public abstract void paintComponent (Graphics2D g); public void setRed(){ color=Color.RED; } public void unsetRed(){ color=Color.BLACK; } public void translate(int dx, int dy) { if (center!=null) center.translate(dx,dy); } public Boolean isUnderPoint(Point p) { Point np = new Point(p); np.translate(-center.x, -center.y); if (body!=null) return (body.contains(np)); else return false; } }