接口的使用
com.example.graphics.model.Shape
使用Shape的程序包
程序包
说明
-
com.example.graphics中Shape的使用
声明为Shape的com.example.graphics中的字段类型参数类型为Shape的com.example.graphics中的字段返回变量类型为Shape的类型的com.example.graphics中的方法参数类型为Shape的com.example.graphics中的方法修饰符和类型方法说明void
Add a shape to the drawing using the Command patternprivate String
SwingGraphicsApp.getShapeTypeName
(Shape shape) private boolean
SwingGraphicsApp.isPointOnShape
(Shape shape, Point point) void
Move a shape to a new position using the Command patternvoid
Drawing.removeShape
(Shape shape) Remove a shape from the drawing using the Command pattern -
com.example.graphics.command中Shape的使用
修饰符和类型字段说明private final Shape
AddShapeCommand.shape
private final Shape
MoveShapeCommand.shape
private final Shape
RemoveShapeCommand.shape
类型参数类型为Shape的com.example.graphics.command中的字段参数类型为Shape的com.example.graphics.command中的构造器限定符构造器说明AddShapeCommand
(List<Shape> shapes, Shape shape) Constructor for the AddShapeCommandMoveShapeCommand
(Shape shape, int newX, int newY) Constructor for the MoveShapeCommandRemoveShapeCommand
(List<Shape> shapes, Shape shape) Constructor for the RemoveShapeCommand类型变量类型为Shape的com.example.graphics.command中的构造器参数限定符构造器说明AddShapeCommand
(List<Shape> shapes, Shape shape) Constructor for the AddShapeCommandRemoveShapeCommand
(List<Shape> shapes, Shape shape) Constructor for the RemoveShapeCommand -
com.example.graphics.factory中Shape的使用
修饰符和类型方法说明ShapeFactory.createCircle
(int x, int y, int radius) Create a circle with the specified parametersShapeFactory.createLine
(int x1, int y1, int x2, int y2) Create a line with the specified endpointsShapeFactory.createRectangle
(int x, int y, int width, int height) Create a rectangle with the specified parametersShapeFactory.createTriangle
(int x1, int y1, int x2, int y2, int x3, int y3) Create a triangle with the specified vertices -
com.example.graphics.model中Shape的使用
修饰符和类型类说明class
Circle implementation of the Shape interface.class
Line implementation of the Shape interface.class
Rectangle implementation of the Shape interface.class
Triangle implementation of the Shape interface. -
com.example.graphics.observer中Shape的使用
参数类型为Shape的com.example.graphics.observer中的方法修饰符和类型方法说明void
ShapeSubject.notifyShapeAdded
(Shape shape) Notify all observers that a shape was addedvoid
ShapeSubject.notifyShapeModified
(Shape shape) Notify all observers that a shape was modifiedvoid
ShapeSubject.notifyShapeRemoved
(Shape shape) Notify all observers that a shape was removedvoid
ConsoleLogger.onShapeAdded
(Shape shape) void
ShapeObserver.onShapeAdded
(Shape shape) Called when a shape is addedvoid
ConsoleLogger.onShapeModified
(Shape shape) void
ShapeObserver.onShapeModified
(Shape shape) Called when a shape is modifiedvoid
ConsoleLogger.onShapeRemoved
(Shape shape) void
ShapeObserver.onShapeRemoved
(Shape shape) Called when a shape is removed -
com.example.graphics.util中Shape的使用
返回变量类型为Shape的类型的com.example.graphics.util中的方法修饰符和类型方法说明FileManager.loadDrawingBinary
(String filePath) 从二进制文件加载图形FileManager.loadDrawingJson
(String filePath) 从JSON文件加载图形