Package doodlepad
Class Text
java.lang.Object
doodlepad.Shape
doodlepad.Text
A class that implements a graphical object made up of text.
Starts filled with black and no stroke.
-
Nested Class Summary
Nested classes/interfaces inherited from class doodlepad.Shape
Shape.ShapeMouseEventHandler, Shape.ShapeSelectionEventHandler
-
Field Summary
Fields inherited from class doodlepad.Shape
draggable, eventsEnabled, fillColor, filled, fontFamily, fontSize, fontStyle, height, layer, selectable, selected, shapeListener, strokeColor, stroked, strokeWidth, textFillColor, transform, visible, width, x, y
-
Constructor Summary
ConstructorDescriptionText()
Text object constructor.Text object constructor.Text object constructor.Text object constructor.Text object constructorText object constructorText object constructorText object constructor.Text object constructor.Text object constructor.Text object constructor.Text object constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(Graphics2D g) Draw the Text objectReturn the Font family name for this Text object.int
Return the font size for this Text object.int
Return the Font style code for this Text object.getText()
Return the Text object Stringvoid
setFontFamily
(String fontFamily) Update the Font family for this Text object.void
setFontSize
(int fontSize) Update the Font size for this Text object.void
setFontStyle
(int fontStyle) Update the Font style for this Text object.void
Set the internal texttoString()
Generate a representation of the Text object.Methods inherited from class doodlepad.Shape
contains, contains, drawText, getArea, getCenter, getDraggable, getEventsEnabled, getFillAlpha, getFillBlue, getFillColor, getFilled, getFillGreen, getFillRed, getHeight, getLayer, getLocation, getPad, getPadLocation, getSelectable, getSelected, getSize, getStrokeAlpha, getStrokeBlue, getStrokeColor, getStroked, getStrokeGreen, getStrokeRed, getStrokeWidth, getTransform, getVisible, getWidth, getWindowLocation, getX, getY, intersects, move, onMouseClicked, onMouseDoubleClicked, onMouseDragged, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onSelectionChanged, repaint, reset, rotate, rotate, scale, scale, scale, scale, setCenter, setCenter, setDraggable, setEventsEnabled, setFillColor, setFillColor, setFillColor, setFillColor, setFilled, setHeight, setLocation, setLocation, setMouseClickedHandler, setMouseDoubleClickedHandler, setMouseDraggedHandler, setMouseEnteredHandler, setMouseExitedHandler, setMouseMovedHandler, setMousePressedHandler, setMouseReleasedHandler, setPadLocation, setSelectable, setSelected, setSelectionChangedHandler, setSize, setSize, setStrokeColor, setStrokeColor, setStrokeColor, setStrokeColor, setStroked, setStrokeWidth, setTextColor, setTextColor, setTextColor, setTextColor, setTransform, setVisible, setWidth, setWindowLocation, setX, setY, toBack, toFront, toWindowCoords, toWindowCoords, translate
-
Constructor Details
-
Text
Text object constructor- Parameters:
text
- The String drawn as the Text objectx
- The x-coordinate of the Text object upper left corner.y
- The y-coordinate of the Text object upper left corner.size
- The Font size used to draw the Text object.style
- The Font class constant that defines the style used to draw the Text object. Example: Font.PLAINfontName
- The name of the font used to draw the Text object, Example: "Arial"layer
- The Layer object to which the Text should be added, or null if not to add to a Pad.
-
Text
Text object constructor- Parameters:
text
- The String drawn as the Text objectx
- The x-coordinate of the Text object upper left corner.y
- The y-coordinate of the Text object upper left corner.size
- The font size used to draw the Text object.style
- The Font class constant that defines the style used to draw the Text object. Example: Font.PLAINfontName
- The name of the font used to draw the Text object, Example: "Arial"
-
Text
Text object constructor- Parameters:
text
- The String drawn as the Text objectx
- The x-coordinate of the Text object upper left corner.y
- The y-coordinate of the Text object upper left corner.size
- The font size used to draw the Text object.style
- The Font class constant that defines the style used to draw the Text object. Example: Font.PLAINfontName
- The name of the font used to draw the Text object, Example: "Arial"pad
- The Pad to which the Text object should be added.
-
Text
Text object constructor. Create a Text object with an Arial font.- Parameters:
text
- The String drawn as the Text objectx
- The x-coordinate of the Text object upper left corner.y
- The y-coordinate of the Text object upper left corner.size
- The font size used to draw the Text object.style
- The Font class constant that defines the style used to draw the Text object. Example: Font.PLAIN
-
Text
Text object constructor. Create a Text object with an Arial font.- Parameters:
text
- The String drawn as the Text objectx
- The x-coordinate of the Text object upper left corner.y
- The y-coordinate of the Text object upper left corner.size
- The font size used to draw the Text object.fontName
- The name of the font used to draw the Text object, Example: "Arial"
-
Text
Text object constructor. Create a Text object with style Font.PLAIN and an Arial font.- Parameters:
text
- The String drawn as the Text objectx
- The x-coordinate of the Text object upper left corner.y
- The y-coordinate of the Text object upper left corner.size
- The font size used to draw the Text object.
-
Text
Text object constructor. Create a Text object with style Font.PLAIN and an Arial font.- Parameters:
text
- The String drawn as the Text objectx
- The x-coordinate of the Text object upper left corner.y
- The y-coordinate of the Text object upper left corner.size
- The font size used to draw the Text object.pad
- The Pad to which the Text object should be added.
-
Text
Text object constructor. Create a Text object with style Font.PLAIN and an Arial font.- Parameters:
text
- The String drawn as the Text objectx
- The x-coordinate of the Text object upper left corner.y
- The y-coordinate of the Text object upper left corner.size
- The font size used to draw the Text object.layer
- The Layer object to which the Text should be added, or null if not to add to a Pad.
-
Text
Text object constructor. Create a Text object with the default system font attributes.- Parameters:
text
- The String drawn as the Text objectx
- The x-coordinate of the Text object upper left corner.y
- The y-coordinate of the Text object upper left corner.pad
- The Pad to which the Text object should be added.
-
Text
Text object constructor. Create a Text object with the default font attributes.- Parameters:
text
- The String drawn as the Text objectx
- The x-coordinate of the Text object upper left corner.y
- The y-coordinate of the Text object upper left corner.
-
Text
Text object constructor. Create a Text object with the default system font attributes.- Parameters:
text
- The String drawn as the Text objectx
- The x-coordinate of the Text object upper left corner.y
- The y-coordinate of the Text object upper left corner.layer
- The Layer object to which the Text should be added, or null if not to add to a Pad.
-
Text
public Text()Text object constructor. Creates a randomly positioned Text object.
-
-
Method Details
-
toString
Generate a representation of the Text object. -
setText
Set the internal text -
getText
Return the Text object String -
setFontFamily
Update the Font family for this Text object.- Overrides:
setFontFamily
in classShape
- Parameters:
fontFamily
- The Font family name (ex. "Arial")
-
getFontFamily
Return the Font family name for this Text object.- Overrides:
getFontFamily
in classShape
- Returns:
- The Font family name String
-
setFontStyle
public void setFontStyle(int fontStyle) Update the Font style for this Text object.- Overrides:
setFontStyle
in classShape
- Parameters:
fontStyle
- The font style code (ex. 0 (Font.PLAIN), 1 (Font.BOLD), 2 (Font.ITALIC))
-
getFontStyle
public int getFontStyle()Return the Font style code for this Text object.- Overrides:
getFontStyle
in classShape
- Returns:
- The Font style code
-
setFontSize
public void setFontSize(int fontSize) Update the Font size for this Text object.- Overrides:
setFontSize
in classShape
- Parameters:
fontSize
- The font size (ex. 10)
-
getFontSize
public int getFontSize()Return the font size for this Text object.- Overrides:
getFontSize
in classShape
- Returns:
- the font size.
-
draw
Draw the Text object
-