Package breadboards
Class GObject
- java.lang.Object
-
- breadboards.GObject
-
-
Constructor Summary
Constructors Constructor Description GObject()
(only called through constructor chaining)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addMouseListener(java.awt.event.MouseListener mouseListener)
adds a specified MouseListener to this GObjectvoid
addMouseMotionListener(java.awt.event.MouseMotionListener mouseMotionListener)
adds a specified mouseMotionListener to this GObjectabstract boolean
contains(double x, double y)
required of subclasses to determine if the point (x,y) is contained in/on the GObject in questionabstract GRectangle
getBounds()
required of subclasses to determine the bounding rectangle of the GObject in questionBreadboard
getBreadboard()
returns the breadboard associated with this GObject -- or null if there is no such breadboardGPoint
getLocation()
returns the location of the GObject as a GPointjava.lang.Iterable<java.awt.event.MouseListener>
getMouseListeners()
gets an iterable collection of all MouseListeners associated with this GObjectjava.lang.Iterable<java.awt.event.MouseMotionListener>
getMouseMotionListeners()
gets an iterable collection of all MouseMotionListeners associated with this GObjectGObjectParent
getParent()
returns the parent of the GObject - typically a GCompound or a Breadboard objectdouble
getX()
returns the x-coordinate of the GObjectdouble
getY()
returns the y-coordinate of the GObjectboolean
isVisible()
returns whether or not this GObject is visiblevoid
move(double dx, double dy)
moves this GObject dx units horizontally and dy units verticallyvoid
movePolar(double r, double theta)
moves this GObject in a polar manner, r units from its current position in the theta directionvoid
removeMouseListener(java.awt.event.MouseListener mouseListener)
removes a specified MouseListener from this GObjectvoid
removeMouseMotionListener(java.awt.event.MouseMotionListener mouseMotionListener)
removes a specified MouseMotionListener from this GObjectvoid
sendBackward()
Swaps the z-orders of this GObject and the object immediately "below" it on this GObject's parent objectvoid
sendForward()
Swaps the z-orders of this GObject and the object immediately "above" it on this GObject's parent objectvoid
sendToBack()
Moves this GObject "below" all other GObjects on this GObject's parent objectvoid
sendToFront()
Moves this GObject "on top" of all other GObjects on this GObject's parent objectvoid
setLocation(double x, double y)
sets the location of this GObject to (x,y)void
setParent(GObjectParent parent)
sets the parent for this object to be the specified parent - note: it does not tell the parent of this childvoid
setVisible(boolean isVisible)
sets whether this GObject is visible or notvoid
setX(double x)
sets the x-coordinate for this GObject to the specified x-coordinatevoid
setY(double y)
sets the y-coordinate for this GObject to the specified y-coordinatevoid
updateBreadboard()
updates display of containing breadboard (should be called when the GObject changes state)
-
-
-
Method Detail
-
contains
public abstract boolean contains(double x, double y)
required of subclasses to determine if the point (x,y) is contained in/on the GObject in question- Parameters:
x
- x-coordinate of the point in questiony
- y-coordinate of the point in question- Returns:
- true if the point is contained in the GObject, false otherwise
-
getBounds
public abstract GRectangle getBounds()
required of subclasses to determine the bounding rectangle of the GObject in question- Returns:
- the bounding rectangle of the GObject
-
getX
public double getX()
returns the x-coordinate of the GObject- Returns:
- the x-coordinate of the GObject
-
getY
public double getY()
returns the y-coordinate of the GObject- Returns:
- the y-coordinate of the GObject
-
getLocation
public GPoint getLocation()
returns the location of the GObject as a GPoint- Returns:
- the location of the GObject
-
getParent
public GObjectParent getParent()
returns the parent of the GObject - typically a GCompound or a Breadboard object- Returns:
- the parent of the GObject
-
getBreadboard
public Breadboard getBreadboard()
returns the breadboard associated with this GObject -- or null if there is no such breadboard- Returns:
- the breadboard associated with this GObject -- or null if there is no such breadboard
-
isVisible
public boolean isVisible()
returns whether or not this GObject is visible- Returns:
- true if the GObject is visible, false otherwise
-
setParent
public void setParent(GObjectParent parent)
sets the parent for this object to be the specified parent - note: it does not tell the parent of this child- Parameters:
parent
- the specified parent
-
setX
public void setX(double x)
sets the x-coordinate for this GObject to the specified x-coordinate- Parameters:
x
- the specified x-coordinate
-
setY
public void setY(double y)
sets the y-coordinate for this GObject to the specified y-coordinate- Parameters:
y
- the specified y-coordinate
-
setLocation
public void setLocation(double x, double y)
sets the location of this GObject to (x,y)- Parameters:
x
- the new x-coordinate for this GObjecty
- the new y-coordinate for this GObject
-
setVisible
public void setVisible(boolean isVisible)
sets whether this GObject is visible or not- Parameters:
isVisible
- true if the object is visible, false otherwise
-
sendForward
public void sendForward()
Swaps the z-orders of this GObject and the object immediately "above" it on this GObject's parent object
-
sendBackward
public void sendBackward()
Swaps the z-orders of this GObject and the object immediately "below" it on this GObject's parent object
-
sendToFront
public void sendToFront()
Moves this GObject "on top" of all other GObjects on this GObject's parent object
-
sendToBack
public void sendToBack()
Moves this GObject "below" all other GObjects on this GObject's parent object
-
addMouseListener
public void addMouseListener(java.awt.event.MouseListener mouseListener)
adds a specified MouseListener to this GObject- Parameters:
mouseListener
- the MouseListener specified
-
addMouseMotionListener
public void addMouseMotionListener(java.awt.event.MouseMotionListener mouseMotionListener)
adds a specified mouseMotionListener to this GObject- Parameters:
mouseMotionListener
- the MouseMotionListener specified
-
removeMouseListener
public void removeMouseListener(java.awt.event.MouseListener mouseListener)
removes a specified MouseListener from this GObject- Parameters:
mouseListener
- the specified MouseListener
-
removeMouseMotionListener
public void removeMouseMotionListener(java.awt.event.MouseMotionListener mouseMotionListener)
removes a specified MouseMotionListener from this GObject- Parameters:
mouseMotionListener
- the specified MouseMotionListener
-
getMouseListeners
public java.lang.Iterable<java.awt.event.MouseListener> getMouseListeners()
gets an iterable collection of all MouseListeners associated with this GObject- Returns:
- an iterable collection of all MouseListeners associated with this GObject
-
getMouseMotionListeners
public java.lang.Iterable<java.awt.event.MouseMotionListener> getMouseMotionListeners()
gets an iterable collection of all MouseMotionListeners associated with this GObject- Returns:
- an iterable collection of all MouseMotionListeners associated with this GObject
-
move
public void move(double dx, double dy)
moves this GObject dx units horizontally and dy units vertically- Parameters:
dx
- how much to move this GObject horizontally (positive is to the right, negative to the left)dy
- how much to move this GObject vertically (positive is down, negative is up)
-
movePolar
public void movePolar(double r, double theta)
moves this GObject in a polar manner, r units from its current position in the theta direction- Parameters:
r
- how far to move from the current positiontheta
- the direction in which this GObject is moved (expressed in radians)
-
updateBreadboard
public void updateBreadboard()
updates display of containing breadboard (should be called when the GObject changes state)
-
-