
package tmcm.xLogicCircuits;

import java.awt.*;
import java.util.Vector;

abstract class CircuitItem {
   boolean on, selected;
   FloatRect boundingBox = new FloatRect();
   boolean hit(int x, int y) { return boundingBox.inside(x,y); }
   void reshape(float x, float y, float width, float height) { boundingBox.reshape(x,y,width,height); }
   void drawWithLines(Graphics g) { draw(g); }
   void selectConnectedLines(boolean select) { }
   void powerOff() { on = false; }
   IONub getLineSource(int x, int y) { return null; }
   IONub getLineDestination(int x, int y) { return null; }
   boolean compute() { return false; };  // returns true if anything visible element changed
   void dragTo(float x, float y, FloatRect circuitBounds) { // called ONLY when dragging item that is on circuit (not in scroller)
      if (x + boundingBox.width > circuitBounds.x + circuitBounds.width - 10)
         x = circuitBounds.x + circuitBounds.width - 5 - boundingBox.width;
      if (y + boundingBox.height > circuitBounds.y + circuitBounds.height - 10)
         y = circuitBounds.y + circuitBounds.height - 5 - boundingBox.height;
      x = Math.max(x, circuitBounds.x + 5);
      y = Math.max(y, circuitBounds.y + 5);
      reshape(x,y,boundingBox.width,boundingBox.height);
   }
   abstract Rectangle getCopyOfBoundingBox(boolean addInLines);
   abstract void draw(Graphics g);
   abstract CircuitItem copy();
   abstract void delete(Circuit owner);
   abstract void unDelete(Circuit owner);
}


