Skip to content
Snippets Groups Projects
Decorator.java 686 B
Newer Older
  • Learn to ignore specific revisions
  • MANSOUR Chadi's avatar
    MANSOUR Chadi committed
    package shape;
    
    import javafx.geometry.Point2D;
    import javafx.scene.canvas.GraphicsContext;
    
    
    public abstract class Decorator implements Shape {
        protected Shape decoratedshape;
    
    MANSOUR Chadi's avatar
    MANSOUR Chadi committed
        public Decorator(Shape decoratedShape) {
    
            this.decoratedshape = decoratedShape;
    
    MANSOUR Chadi's avatar
    MANSOUR Chadi committed
        }
        @Override
        public int pointsCount() {
    
            return decoratedshape.pointsCount();
    
    MANSOUR Chadi's avatar
    MANSOUR Chadi committed
        }
    
        @Override
        public Point2D point(int index) {
    
    Chadi's avatar
    Chadi committed
            return decoratedshape.point(index);
    
    MANSOUR Chadi's avatar
    MANSOUR Chadi committed
        }
    
        @Override
        public void draw(GraphicsContext context) {
    
    Chadi's avatar
    Chadi committed
            decoratedshape.draw(context);
            drawDecoration(context);
    
    MANSOUR Chadi's avatar
    MANSOUR Chadi committed
        }
    
        protected void drawDecoration(GraphicsContext context) {