chemaxon.struc.graphics
Class MTextBox

java.lang.Object
  extended bychemaxon.struc.MObject
      extended bychemaxon.struc.graphics.MPolyline
          extended bychemaxon.struc.graphics.MRectangle
              extended bychemaxon.struc.graphics.MTextBox
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class MTextBox
extends MRectangle

Text box object.

Since:
Marvin 3.3, 10/20/2003
Version:
3.5.6, 04/05/2005
Author:
Peter Csizmadia
See Also:
Serialized Form

Field Summary
 
Fields inherited from class chemaxon.struc.graphics.MPolyline
ARROW_BACK_FLAG, ARROW_HALF_LEFT, ARROW_HALF_MASK, ARROW_HALF_RIGHT, CLOSED_FLAG, DEFAULT_THICKNESS, HEAD, TAIL, THICKNESS_SET_FLAG
 
Fields inherited from class chemaxon.struc.MObject
PAINT_ANTIALIAS, PAINT_FOCUSED, TRANSFORM_DISTORT
 
Constructor Summary
  MTextBox()
          Contructs an empty text box.
protected MTextBox(MTextBox t)
          Copy constructor.
 
Method Summary
 void addCdataAttributeKeys(java.util.Vector v)
          Adds attribute names to the specified vector.
 void addChar(char c)
          Adds a character to the text.
 void addString(java.lang.String s)
          Adds a string to the text.
 java.lang.Object clone()
          Creates a clone.
 void cursorDown(boolean select)
          Move the cursor down.
 void cursorUp(boolean select)
          Moves the cursor up.
 void deleteChar()
          Removes the character under the cursor.
 void deleteCharBackward()
          Removes the character before the cursor (backspace).
 int determinePosition(DPoint3 p, boolean allowExternalPoints)
           
 java.lang.String getAttribute(java.lang.String s)
          Gets the value of an attribute.
 int getCursorPos()
          Gets the cursor position.
 java.lang.String getSelectedString()
          Gets the selected substring.
 int getSelectionEndPos()
          Gets the selection's end position.
 int getSelectionStartPos()
          Gets the selection's start position.
 java.lang.String getText()
          Gets the text stored.
 boolean hasBackground()
          A text box has a background always.
 boolean hasColor()
          A text box has a text color.
 boolean hasFace()
          Is it 2 dimensional?
 boolean hasSelection()
          Checks the existence of the selection.
 boolean isEmpty()
          A text box is empty if the string contains only whitespace.
 void paint(java.awt.Graphics g, CTransform3D t, int f, java.awt.Color c, java.awt.Color selc, java.awt.Color focusc)
          Paints the object.
 void setAttribute(java.lang.String s, java.lang.String v)
          Sets the value of an attribute.
 void setAutoSize(boolean v)
          Turns on/off automatic size calculation.
 void setCursorPos(int i, boolean select)
          Sets the cursor position.
 void setPoints(MPoint[] p)
          Sets the points.
 void setSelected(boolean v)
          Selects or unselects the text box.
 void setText(java.lang.String s)
          Sets the text.
 void transform(CTransform3D t, int opts)
          Transforms all points and scales the font size.
 void unselectContents()
          Unselects text.
 
Methods inherited from class chemaxon.struc.graphics.MRectangle
getClipObject, getPointRef, getPointRefCount, removeChild, setCorners
 
Methods inherited from class chemaxon.struc.graphics.MPolyline
addAttributeKeys, calcCenter, checkValidity, containsAtom, copyProperties, distanceFrom, finishCloning, getArcAngle, getArcCenter, getArcRadius, getArrowFlags, getArrowLength, getArrowWidth, getFlags, getPoint, getPointCount, getSkip, getThickness, hasLineColor, hasOutline, isArrow, isThicknessSet, replaceAtom, setArcAngle, setArrow, setArrowFlags, setArrowLength, setArrowWidth, setFlags, setSkip, setThickness
 
Methods inherited from class chemaxon.struc.MObject
addNotify, distanceFrom, getBackground, getColor, getLineColor, isChildOf, isInternalSelectable, isSelectableNow, isSelected, isTransformable, makeColor, makeColorString, removeNotify, setBackground, setColor, setLineColor
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MTextBox

public MTextBox()
Contructs an empty text box.


MTextBox

protected MTextBox(MTextBox t)
Copy constructor.

Parameters:
t - the original text box
Method Detail

clone

public java.lang.Object clone()
Description copied from class: MObject
Creates a clone.

Overrides:
clone in class MRectangle

getText

public java.lang.String getText()
Gets the text stored.

Returns:
the text

setText

public void setText(java.lang.String s)
Sets the text.

Parameters:
s - the text
Since:
Marvin 3.5, 07/14/2004

setAutoSize

public void setAutoSize(boolean v)
Turns on/off automatic size calculation.

Parameters:
v - turn on (true) or off (false)

isEmpty

public boolean isEmpty()
A text box is empty if the string contains only whitespace.

Overrides:
isEmpty in class MPolyline
Returns:
true if empty, false otherwise

addCdataAttributeKeys

public void addCdataAttributeKeys(java.util.Vector v)
Adds attribute names to the specified vector. Only CDATA attributes are added.

Overrides:
addCdataAttributeKeys in class MObject
Parameters:
v - the vector

getAttribute

public java.lang.String getAttribute(java.lang.String s)
Gets the value of an attribute.
Supported attributes:

Overrides:
getAttribute in class MPolyline
Parameters:
s - the attribute name
Returns:
the value or null

setAttribute

public void setAttribute(java.lang.String s,
                         java.lang.String v)
Sets the value of an attribute.
Supported attributes:

Overrides:
setAttribute in class MPolyline
Parameters:
s - the attribute name
v - the attribute value

hasSelection

public boolean hasSelection()
Checks the existence of the selection.

Returns:
true if selection exists, false otherwise

getSelectedString

public java.lang.String getSelectedString()
Gets the selected substring.

Returns:
the selection if it exists, null otherwise

deleteCharBackward

public void deleteCharBackward()
Removes the character before the cursor (backspace).


deleteChar

public void deleteChar()
Removes the character under the cursor.


addChar

public void addChar(char c)
Adds a character to the text.

Parameters:
c - the character

addString

public void addString(java.lang.String s)
Adds a string to the text.

Parameters:
s - the string

getCursorPos

public int getCursorPos()
Gets the cursor position.

Returns:
the position

setCursorPos

public void setCursorPos(int i,
                         boolean select)
Sets the cursor position.

Parameters:
i - the new position
select - select text while moving the cursor

cursorUp

public void cursorUp(boolean select)
Moves the cursor up.

Parameters:
select - select text while moving the cursor

cursorDown

public void cursorDown(boolean select)
Move the cursor down.

Parameters:
select - select text while moving the cursor

getSelectionStartPos

public int getSelectionStartPos()
Gets the selection's start position.

Returns:
the start index

getSelectionEndPos

public int getSelectionEndPos()
Gets the selection's end position.

Returns:
the end index

setPoints

public void setPoints(MPoint[] p)
Sets the points.

Overrides:
setPoints in class MPolyline
Parameters:
p - the points

hasColor

public boolean hasColor()
A text box has a text color.

Overrides:
hasColor in class MPolyline
Returns:
true

hasBackground

public boolean hasBackground()
A text box has a background always.

Overrides:
hasBackground in class MPolyline
Returns:
true if closed

hasFace

public boolean hasFace()
Is it 2 dimensional?

Overrides:
hasFace in class MPolyline
Returns:
true always

transform

public void transform(CTransform3D t,
                      int opts)
Transforms all points and scales the font size.

Overrides:
transform in class MPolyline
Parameters:
t - the transformation matrix
opts - transform options or 0
Since:
Marvin 3.5, 07/14/2004

paint

public void paint(java.awt.Graphics g,
                  CTransform3D t,
                  int f,
                  java.awt.Color c,
                  java.awt.Color selc,
                  java.awt.Color focusc)
Paints the object.

Overrides:
paint in class MPolyline
Parameters:
g - the graphics context
t - the transformation matrix
f - flags
c - the color to use or null
selc - the selection color
focusc - the focus color

setSelected

public void setSelected(boolean v)
Selects or unselects the text box.

Overrides:
setSelected in class MObject
Parameters:
v - true to select, false to unselect

unselectContents

public void unselectContents()
Unselects text.

Overrides:
unselectContents in class MPolyline

determinePosition

public int determinePosition(DPoint3 p,
                             boolean allowExternalPoints)