wheelsunh.users
Class ConversationBubble

java.lang.Object
  extended by wheelsunh.etc.AbstractGraphic
      extended by wheelsunh.users.AbstractShape
          extended by wheelsunh.users.Shape
              extended by wheelsunh.users.RectangularShape
                  extended by wheelsunh.users.RoundedRectangle
                      extended by wheelsunh.users.ConversationBubble
All Implemented Interfaces:
AdvancedColorable, Colorable, CustomGraphic, Locatable, Rotatable, Sizeable

public class ConversationBubble
extends RoundedRectangle

Subclass of RoundedRectangle that will display a string, like conversation bubbles in cartoon.


Field Summary
static int DEFAULT_BORDER_WIDTH
           
static int DEFAULT_WIDTH
           
static int TAIL_DIR_LEFT
           
static int TAIL_DIR_RIGHT
           
 
Fields inherited from class wheelsunh.users.Shape
_c, _dp, _shape, DEFAULT_COLOR
 
Fields inherited from class wheelsunh.users.AbstractShape
_rot
 
Constructor Summary
ConversationBubble(java.lang.String text)
          Constructs a ConversationBubble in the wheelsunh.users.Frame's DrawingPanel.
ConversationBubble(java.lang.String text, DrawingPanel dp)
          Constructs a ConversationBubble displaying the specified String in the passed-in DrawingPanel.
ConversationBubble(java.lang.String text, DrawingPanel dp, int tailDir)
          Constructs a ConversationBubble displaying the specified String in the passed-in DrawingPanel.
ConversationBubble(java.lang.String text, int tailDir)
          Constructs a ConversationBubble displaying the specified String in the wheelsunh.users.Frame's DrawingPanel.
 
Method Summary
 void actualPaint(java.awt.Graphics2D g)
          Normal users do not need to worry about this! Does the actual work to paint the conversation bubble.
 java.awt.Rectangle getBounds()
          Returns the bounds of the conversation bubble.
 void hide()
          Graphically hides the conversation bubble.
 void setBorderWidth(int width)
          Changes the size of the border of whitespace between the text area and its frame.
 void setColor(java.awt.Color c)
          Set the background and frame color of the ConversationBubble.
 void setFillColor(java.awt.Color c)
          Set the background color of the ConversationBubble.
 void setLocation(java.awt.Point p)
          Sets the location of the ConversationBubble.
 void setRotation(int degrees)
          Overridden to do nothing.
 void setSize(java.awt.Dimension d)
          Sets the size of the ConversationBubble.
 void setTail(int x, int y)
          Allows you to explicitly specify the point that the conversation bubble's "tail" extends from.
 void setTail(java.awt.Point p)
          Allows you to explicitly specify the point that the conversation bubble's "tail" extends from.
 void setTailDirection(int dir)
          Allows you to specify the direction in which the ConversationBubble's "tail"--the line that indicates the source of the conversation bubble.
 void setText(java.lang.String text)
          Makes the bubble display the passed-in string.
 void setWidth(int width)
          Sizes the ConversationBubble to the given width, but maintains full view of the contents by adjusting the height if necessary.
 void show()
          Graphically shows the conversation bubble.
 
Methods inherited from class wheelsunh.users.RectangularShape
getFillColor, getFrameColor, getFrameThickness, getHeight, getLocation, getSize, getWidth, getXLocation, getYLocation, setFrameColor, setFrameThickness, setLocation, setSize
 
Methods inherited from class wheelsunh.users.Shape
contains, getColor, getRotation, paint
 
Methods inherited from class wheelsunh.users.AbstractShape
boundsIntersects, center, distance, getCenter, getCenterX, getCenterY, getIntersection, intersects, intersects, setCenter
 
Methods inherited from class wheelsunh.etc.AbstractGraphic
mouseClicked, mouseDragged, mousePressed, mouseReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface wheelsunh.Colorable
getColor
 

Field Detail

DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
See Also:
Constant Field Values

DEFAULT_BORDER_WIDTH

public static final int DEFAULT_BORDER_WIDTH
See Also:
Constant Field Values

TAIL_DIR_LEFT

public static final int TAIL_DIR_LEFT
See Also:
Constant Field Values

TAIL_DIR_RIGHT

public static final int TAIL_DIR_RIGHT
See Also:
Constant Field Values
Constructor Detail

ConversationBubble

public ConversationBubble(java.lang.String text)
Constructs a ConversationBubble in the wheelsunh.users.Frame's DrawingPanel.


ConversationBubble

public ConversationBubble(java.lang.String text,
                          int tailDir)
Constructs a ConversationBubble displaying the specified String in the wheelsunh.users.Frame's DrawingPanel. The conversation bubble's "tail"--the line that indicates the speaker creating the conversation bubble-- will be pointing in the direction specified by tailDir.

Parameters:
text - the String to display
tailDir - the direction of the bubble's "tail." MUST be either TAIL_DIR_LEFT or TAIL_DIR_RIGHT!
Throws:
java.lang.IllegalArgumentException - if tailDir is not TAIL_DIR_LEFT or TAIL_DIR_RIGHT

ConversationBubble

public ConversationBubble(java.lang.String text,
                          DrawingPanel dp)
Constructs a ConversationBubble displaying the specified String in the passed-in DrawingPanel. The bubble's "tail"--the line that indicates the speaker creating the conversation bubble-- will be pointing to the right.


ConversationBubble

public ConversationBubble(java.lang.String text,
                          DrawingPanel dp,
                          int tailDir)
Constructs a ConversationBubble displaying the specified String in the passed-in DrawingPanel. The conversation bubble's "tail"--the line that indicates the speaker creating the conversation bubble-- will be pointing in the direction specified by tailDir.

Parameters:
text - the String to display
dp - the DrawingPanel in which the bubble will be drawn
tailDir - the direction of the bubble's "tail." MUST be either TAIL_DIR_LEFT or TAIL_DIR_RIGHT!
Throws:
java.lang.IllegalArgumentException - if tailDir is not TAIL_DIR_LEFT or TAIL_DIR_RIGHT
Method Detail

setLocation

public void setLocation(java.awt.Point p)
Sets the location of the ConversationBubble. Overridden to position the text box within the frame. (Calls to setLocation(int, int) forward to setLocation(java.awt.Point), so either one will work correctly.)

Specified by:
setLocation in interface Locatable
Overrides:
setLocation in class RectangularShape

setSize

public void setSize(java.awt.Dimension d)
Sets the size of the ConversationBubble. NOTE: setting an explicit size for the bubble may cut off some of the text. Use setWidth(int) to specify a width for the bubble while maintaining view of all the text.

Specified by:
setSize in interface Sizeable
Overrides:
setSize in class RoundedRectangle

setWidth

public void setWidth(int width)
Sizes the ConversationBubble to the given width, but maintains full view of the contents by adjusting the height if necessary.


show

public void show()
Graphically shows the conversation bubble.

Overrides:
show in class Shape

hide

public void hide()
Graphically hides the conversation bubble.

Overrides:
hide in class Shape

setBorderWidth

public void setBorderWidth(int width)
Changes the size of the border of whitespace between the text area and its frame.


setColor

public void setColor(java.awt.Color c)
Set the background and frame color of the ConversationBubble.

Specified by:
setColor in interface Colorable
Overrides:
setColor in class RectangularShape

setFillColor

public void setFillColor(java.awt.Color c)
Set the background color of the ConversationBubble.

Specified by:
setFillColor in interface AdvancedColorable
Overrides:
setFillColor in class RectangularShape

setText

public void setText(java.lang.String text)
Makes the bubble display the passed-in string. Adjusts height so the all of new string is properly displayed.


actualPaint

public void actualPaint(java.awt.Graphics2D g)
Normal users do not need to worry about this! Does the actual work to paint the conversation bubble.

Overrides:
actualPaint in class RectangularShape
Parameters:
g - the instance of java.awt.Graphics2D that should be used to paint the shape

getBounds

public java.awt.Rectangle getBounds()
Returns the bounds of the conversation bubble.

Overrides:
getBounds in class RectangularShape

setRotation

public void setRotation(int degrees)
Overridden to do nothing.

Specified by:
setRotation in interface Rotatable
Overrides:
setRotation in class Shape
Parameters:
degrees - the magnitude of the rotation in degrees

setTail

public void setTail(java.awt.Point p)
Allows you to explicitly specify the point that the conversation bubble's "tail" extends from. The tail is the line that attaches the bubble to the speaker's mouth.


setTail

public void setTail(int x,
                    int y)
Allows you to explicitly specify the point that the conversation bubble's "tail" extends from. The tail is the line that attaches the bubble to the speaker's mouth.


setTailDirection

public void setTailDirection(int dir)
Allows you to specify the direction in which the ConversationBubble's "tail"--the line that indicates the source of the conversation bubble. If you had previously specified an endpoint for the tail using setTail, the tail will now revert to its default sizing at the specified direction.

Parameters:
dir - the direction (must be TAIL_DIR_LEFT or TAIL_DIR_RIGHT)
Throws:
java.lang.IllegalArgumentException - if dir is not TAIL_DIR_LEFT or TAIL_DIR_RIGHT.