001package horstmann.ch06_scene3; 002import java.awt.Graphics2D; 003import java.awt.geom.Point2D; 004 005/** 006 A shape that is a part of a scene. 007 */ 008public interface SceneShape 009{ 010 /** 011 Draws this item. 012 @param g2 the graphics context 013 */ 014 void draw(Graphics2D g2); 015 /** 016 Draws the selection adornment of this item. 017 @param g2 the graphics context 018 */ 019 void drawSelection(Graphics2D g2); 020 /** 021 Sets the selection state of this item. 022 @param b true if this item is selected 023 */ 024 void setSelected(boolean b); 025 /** 026 Gets the selection state of this item. 027 @return true if this item is selected 028 */ 029 boolean isSelected(); 030 /** 031 Translates this item by a given amount. 032 @param dx the amount to translate in x-direction 033 @param dy the amount to translate in y-direction 034 */ 035 void translate(int dx, int dy); 036 /** 037 Tests whether this item contains a given point. 038 @param p a point 039 @return true if this item contains p 040 */ 041 boolean contains(Point2D p); 042} 043