Package breadboards

Class GCompound

    • Constructor Detail

      • GCompound

        public GCompound()
        constructs a new (empty) GCompound
    • Method Detail

      • getElement

        public GObject getElement​(int i)
        returns the ith element by z-order in this GCompound
        Parameters:
        i - the z-order index
        Returns:
        the ith element by z-order in this GCompound
      • getElementCount

        public int getElementCount()
        returns the number of elements that make up the GCompound
        Returns:
        the number of elements that make up the GCompound
      • getElementAt

        public GObject getElementAt​(double x,
                                    double y)
        returns the top-most element of the GCompound at the specified location (x,y)
        Parameters:
        x - the x-coordinate of the specified location
        y - the y-coordinate of the specified location
        Returns:
        the top-most element of the GCompound at the specified location (x,y)
      • getElementAt

        public GObject getElementAt​(GPoint pt)
        returns the top-most element of the GCompound at the specified point
        Parameters:
        pt - the specified point
        Returns:
        the top-most element of the GCompound at the specified point
      • getCanvasPoint

        public GPoint getCanvasPoint​(double x,
                                     double y)
        converts local coordinates associated with the GCompound to coordinates associated with the parent object
        Parameters:
        x - the local x-coordinate
        y - the local y-coordinate
        Returns:
        coordinates in GCompound's parent object
      • getLocalPoint

        public GPoint getLocalPoint​(double x,
                                    double y)
        converts coordinates associated with the parent object to local coordinates associated with the GCompound
        Parameters:
        x - the x-coordinate associated with the parent object
        y - the y-coordinate associated with the parent object
        Returns:
        the local coordinates
      • add

        public void add​(GObject gObject)
        adds a GObject to this GCompound
        Parameters:
        gObject - the GObject to be added
      • add

        public void add​(GObject gObject,
                        double x,
                        double y)
        adds a GObject to this GCompound at the specified location
        Parameters:
        gObject - the GObject to be added
        x - the x-coordinate of the specified location
        y - the y-coordiante of the specified location
      • add

        public void add​(GObject gObject,
                        GPoint pt)
        adds a GObject to this GCompound at the specified point
        Parameters:
        gObject - the GObject to be added
        pt - the specified point
      • remove

        public void remove​(GObject gObject)
        removes the specified GObject from the GCompound
        Parameters:
        gObject - the specified GObject to be removed
      • removeAll

        public void removeAll()
        removes all GObjects from this GCompound
      • draw

        public void draw​(java.awt.Graphics g)
        draws the GCompound (generally not called directly)
        Specified by:
        draw in interface Drawable
      • contains

        public boolean contains​(double x,
                                double y)
        returns true if the point (x,y) is contained in one of the elements of the GCompound
        Specified by:
        contains in class GObject
        Parameters:
        x - the x-coordinate of the point in question
        y - the y-coordinate of the point in question
        Returns:
        true if the point is contained in the GObject, false otherwise
      • getBounds

        public GRectangle getBounds()
        returns the bounding box for the union of all elements in this GCompound
        Specified by:
        getBounds in class GObject
        Returns:
        the bounding rectangle of the GObject
      • sendForward

        public void sendForward​(GObject gObj)
        Swaps the z-orders of the specified GObject and the object immediately "above" it.
        Specified by:
        sendForward in interface GObjectParent
        Parameters:
        gObj - the specified GObject
      • sendBackward

        public void sendBackward​(GObject gObj)
        Swaps the z-orders of the specified GObject and the object immediately "below" it.
        Specified by:
        sendBackward in interface GObjectParent
        Parameters:
        gObj - the specified GObject
      • sendToFront

        public void sendToFront​(GObject gObj)
        Moves the specified object "on top" of all other GObjects on the breadboard
        Specified by:
        sendToFront in interface GObjectParent
        Parameters:
        gObj - the specified GObject
      • sendToBack

        public void sendToBack​(GObject gObj)
        Moves the specified object "below" all other GObjects on the breadboard
        Specified by:
        sendToBack in interface GObjectParent
        Parameters:
        gObj - the specified GObject
      • updateDisplay

        public void updateDisplay()
        updates the display of this GCompound and all of its parents on the breadboard drawing area
        Specified by:
        updateDisplay in interface GObjectParent
      • getHeight

        public double getHeight()
        returns height of GCompound
        Returns:
        the height of GCompound
      • getWidth

        public double getWidth()