content: package com.itbulls.learnit.javacore.patterns.structural.composite;
  
  import java.awt.*;
  
  public abstract class BaseShape implements Shape {
      public int x;
      public int y;
      public Color color;
      private Boolean selected = false;
  
      BaseShape(int x, int y, Color color) {
          this.x = x;
          this.y = y;
          this.color = color;
      }
  
      @Override
      public int getX() {
          return x;
      }
  
      @Override
      public int getY() {
          return y;
      }
  
      @Override
      public int getWidth() {
          return 0;
      }
  
      @Override
      public int getHeight() {
          return 0;
      }
  
      @Override
      public void move(int x, int y) {
          this.x += x;
          this.y += y;
      }
  
      @Override
      public Boolean isInsideBounds(int x, int y) {
          return x > getX() && x < (getX() + getWidth()) &&
                  y > getY() && y < (getY() + getHeight());
      }
  
      @Override
      public void select() {
          selected = true;
      }
  
      @Override
      public void unSelect() {
          selected = false;
      }
  
      @Override
      public Boolean isSelected() {
          return selected;
      }
  
      void enableSelectionStyle(Graphics graphics) {
          graphics.setColor(Color.LIGHT_GRAY);
  
          Graphics2D g2 = (Graphics2D) graphics;
          Stroke backup = g2.getStroke();
          float dash1[] = {2.0f};
          g2.setStroke(new BasicStroke(1.0f,
                  BasicStroke.CAP_BUTT,
                  BasicStroke.JOIN_MITER,
                  2.0f, dash1, 0.0f));
      }
  
      void disableSelectionStyle(Graphics graphics) {
          graphics.setColor(color);
          Graphics2D g2 = (Graphics2D) graphics;
          g2.setStroke(new BasicStroke());
      }
  
  
      @Override
      public void paint(Graphics graphics) {
          if (isSelected()) {
              enableSelectionStyle(graphics);
          }
          else {
              disableSelectionStyle(graphics);
          }
  
          // ...
      }
  }
  