sm
Class SMText

java.lang.Object
  extended bysm.SMShape
      extended bysm.SMText
All Implemented Interfaces:
java.lang.Cloneable, InteractiveObject

public class SMText
extends SMShape

A text shape for use with an Canvas. The text is drawn according to the fill paint and the text font1. If the shape is outlined, the bounding box of the text is drawn according to the outline paint and stroke.

Author:
Caroline Appert

Field Summary
 
Fields inherited from class sm.SMShape
cptId
 
Constructor Summary
SMText(java.awt.geom.Point2D loc, java.awt.Paint p, java.awt.Paint o, java.lang.String txt, java.awt.Font f)
          Builds a SMtext.
SMText(java.awt.geom.Point2D loc, java.awt.Paint p, java.awt.Paint o, java.awt.Stroke str, java.lang.String txt, java.awt.Font f)
          Builds a SMtext.
SMText(java.awt.geom.Point2D loc, java.awt.Paint p, java.lang.String txt, java.awt.Font f)
          Builds a SMtext.
SMText(java.awt.geom.Point2D loc, java.awt.Paint p, java.awt.Stroke str, java.lang.String txt, java.awt.Font f)
          Builds a SMtext.
SMText(java.awt.geom.Point2D loc, java.lang.String txt, java.awt.Font f)
          Builds a SMtext.
SMText(java.awt.geom.Point2D loc, java.awt.Stroke str, java.lang.String txt, java.awt.Font f)
          Builds a SMtext.
 
Method Summary
 SMShape addTo(SMCanvas c)
          Adds this shape to a canvas.
 SMShape copyTo(SMShape sms)
          Copies this shape into a destination shape.
 SMShape duplicate()
          Creates a new copy of this shape and returns it.
 SMEllipse getAbsoluteEllipse(double w, double h)
          Returns a SMEllipse that surrounds this text.
 SMRectangle getAbsoluteRectangle(double w, double h)
          Returns a CRectangle that surrounds this text.
 char getChar(double x, double y)
          Returns the nearest char from the location (x, y)
 char getChar(java.awt.geom.Point2D p)
          Returns the nearest char from the point p
 SMEllipse getEllipticalBoundingBox()
          Returns a SMEllipse filled in white that surrounds this SMText.
 java.awt.Font getFont()
          Returns the text font1.
 SMEllipse getRelativeEllipse(double ratioX, double ratioY)
          Returns a SMEllipse that surrounds this text.
 SMRectangle getRelativeRectangle(double ratioX, double ratioY)
          Returns a SMRectangle that surrounds this text.
 java.lang.String getText()
          Returns the text.
 double getX()
          Returns the x coordinate of the text.
 double getY()
          Returns the y coordinate of the text.
 void paint(java.awt.Graphics g)
          Paints the shape.
 SMText setFont(java.awt.Font f)
          Sets the text font1.
 SMText setLocation(java.awt.geom.Point2D loc)
          Sets the location of the text.
 SMText setText(java.lang.String text)
          Sets the text to be displayed.
 
Methods inherited from class sm.SMShape
above, aboveAll, addChild, addGhost, addTag, addTag, addTag, asEllipse, asImage, asPolyLine, asRectangle, asRectangularShape, asText, attachSM, below, belowAll, canvasToShape, clone, contains, contains, contains, contains, containsPoint, containsPoint, detachSM, equals, getAbsShape, getAbsTransform, getBoundingBox, getCanvas, getCenterX, getCenterY, getChildren, getClip, getFillPaint, getHeight, getHierarchy, getID, getMaxX, getMaxY, getMinX, getMinY, getOutlinePaint, getParent, getReferenceX, getReferenceY, getRotation, getScaleX, getScaleY, getShape, getStroke, getTransform, getTranslateX, getTranslateY, getTransparency, getWidth, hasTag, hasTag, intersects, intersects, isAbove, isAntialiased, isBelow, isDrawable, isEmpty, isFilled, isOnOutline, isOutlined, isPickable, remove, removeChild, removeGhost, removeTag, removeTag, rotateBy, rotateTo, scaleBy, scaleBy, scaleTo, scaleTo, setAntialiased, setClip, setDrawable, setFilled, setFillPaint, setOutlined, setOutlinePaint, setParent, setPickable, setReferencePoint, setShape, setStroke, setTransparency, shapeToCanvas, translateBy, translateTo
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMText

public SMText(java.awt.geom.Point2D loc,
              java.lang.String txt,
              java.awt.Font f)
Builds a SMtext.

Parameters:
loc - The lower left point of this SMText.
txt - The text of this SMText.
f - The font1 of this SMText.

SMText

public SMText(java.awt.geom.Point2D loc,
              java.awt.Paint p,
              java.awt.Paint o,
              java.awt.Stroke str,
              java.lang.String txt,
              java.awt.Font f)
Builds a SMtext.

Parameters:
loc - The lower left point of this SMText.
p - The paint style of this SMText.
o - The paint style of the bounding box of this SMText.
str - The stroke style the bounding box of this SMText.
txt - The text of this SMText.
f - The font1 of this SMText.

SMText

public SMText(java.awt.geom.Point2D loc,
              java.awt.Paint p,
              java.awt.Paint o,
              java.lang.String txt,
              java.awt.Font f)
Builds a SMtext.

Parameters:
loc - The lower left point of this SMText.
p - The paint style of this SMText.
o - The paint style of the bounding box of this SMText.
txt - The text of this SMText.
f - The font1 of this SMText.

SMText

public SMText(java.awt.geom.Point2D loc,
              java.awt.Paint p,
              java.awt.Stroke str,
              java.lang.String txt,
              java.awt.Font f)
Builds a SMtext.

Parameters:
loc - The lower left point of this SMText.
p - The paint style of this SMText.
str - The stroke style the bounding box of this SMText.
txt - The text of this SMText.
f - The font1 of this SMText.

SMText

public SMText(java.awt.geom.Point2D loc,
              java.awt.Paint p,
              java.lang.String txt,
              java.awt.Font f)
Builds a SMtext.

Parameters:
loc - The lower left point of this SMText.
p - The paint style of this SMText.
txt - The text of this SMText.
f - The font1 of this SMText.

SMText

public SMText(java.awt.geom.Point2D loc,
              java.awt.Stroke str,
              java.lang.String txt,
              java.awt.Font f)
Builds a SMtext.

Parameters:
loc - The lower left point of this SMText.
str - The stroke style the bounding box of this SMText.
txt - The text of this SMText.
f - The font1 of this SMText.
Method Detail

addTo

public SMShape addTo(SMCanvas c)
Description copied from class: SMShape
Adds this shape to a canvas. Note that a number of operations do nothing until the shape is added to a canvas, e.g. adding tags, setting the parent, adding children, setting a clip.

Overrides:
addTo in class SMShape
Parameters:
c - The canvas.
Returns:
Returns this shape.

paint

public void paint(java.awt.Graphics g)
Description copied from class: SMShape
Paints the shape. Normally this method need not be called, since the canvas paints the display list automatically.

Overrides:
paint in class SMShape
Parameters:
g - The graphics with which the shape must be painted.

getChar

public char getChar(double x,
                    double y)
Returns the nearest char from the location (x, y)

Parameters:
x - The x-coordinate (in the canvas coordinate system)
y - The y-coordinate (in the canvas coordinate system)
Returns:
The nearest char.

getChar

public char getChar(java.awt.geom.Point2D p)
Returns the nearest char from the point p

Parameters:
p - The pont (in the canvas coordinate system)
Returns:
The nearest char.

getRelativeRectangle

public SMRectangle getRelativeRectangle(double ratioX,
                                        double ratioY)
Returns a SMRectangle that surrounds this text. If the bounding box of the text is a box whose width and height are respectively w and h, the result rectangle is centered at the center of the text and has a width ratioX*w and a height ratioY*h. This method does NOT add the built CRectangle to the canvas.

Parameters:
ratioX - The width ratio.
ratioY - The height ratio.
Returns:
The surrounding SMRectangle.

getRelativeEllipse

public SMEllipse getRelativeEllipse(double ratioX,
                                    double ratioY)
Returns a SMEllipse that surrounds this text. If the bounding box of the text is a box whose width and height are respectively w and h, the result ellipse is centered at the center of the text and has a width ratioX*w and a height ratioY*h. This method does NOT add the built CRectangle to the canvas.

Parameters:
ratioX - The width ratio.
ratioY - The height ratio.
Returns:
The surrounding SMEllipse.

getAbsoluteRectangle

public SMRectangle getAbsoluteRectangle(double w,
                                        double h)
Returns a CRectangle that surrounds this text. The result rectangle is centered at the center of the text and has a width w and a height h. This method does NOT add the built CRectangle to the canvas.

Parameters:
w - The width ratio.
h - The height ratio.
Returns:
The surrounding CRectangle.

getAbsoluteEllipse

public SMEllipse getAbsoluteEllipse(double w,
                                    double h)
Returns a SMEllipse that surrounds this text. The result ellipse is centered at the center of the text and has a width w and a height h. This method does NOT add the built CRectangle to the canvas.

Parameters:
w - The width ratio.
h - The height ratio.
Returns:
The surrounding CEllipse.

getText

public java.lang.String getText()
Returns the text.

Returns:
Returns the text.

setText

public SMText setText(java.lang.String text)
Sets the text to be displayed.

Parameters:
text - The text to set.
Returns:
Returns this shape.

getEllipticalBoundingBox

public SMEllipse getEllipticalBoundingBox()
Returns a SMEllipse filled in white that surrounds this SMText.

Returns:
Returns a SMEllipse filled in white that surrounds this SMText.

getX

public double getX()
Returns the x coordinate of the text.

Returns:
Returns the x coordinate of the text.

getY

public double getY()
Returns the y coordinate of the text.

Returns:
Returns the y coordinate of the text.

setLocation

public SMText setLocation(java.awt.geom.Point2D loc)
Sets the location of the text.

Parameters:
loc - The new location of the text reference point.
Returns:
Returns this shape.

getFont

public java.awt.Font getFont()
Returns the text font1.

Returns:
Returns the text font1.

setFont

public SMText setFont(java.awt.Font f)
Sets the text font1.

Parameters:
f - The font1.
Returns:
Returns this shape.

copyTo

public SMShape copyTo(SMShape sms)
Copies this shape into a destination shape.

Overrides:
copyTo in class SMShape
Parameters:
sms - The destination shape
Returns:
Returns this shape
See Also:
SMShape.copyTo(sm.SMShape)

duplicate

public SMShape duplicate()
Creates a new copy of this shape and returns it.

Overrides:
duplicate in class SMShape
Returns:
Returns the copy.