com.tensegrity.graphics.text
Class AbstractElement

java.lang.Object
  extended bycom.tensegrity.graphics.text.AbstractElement
All Implemented Interfaces:
Element
Direct Known Subclasses:
CharacterElement, Paragraph, TextSection, Title

public abstract class AbstractElement
extends java.lang.Object
implements Element

AbstractElement is a generic base class for Element based implementations. It implements the Element interface by providing the basic mechanism for nesting Elements and setting/getting the textual representation as a string.

Version:
$Id: AbstractElement.java,v 1.4 2003/04/23 08:27:33 MichaelKegel Exp $
Author:
Gilles Iachelini

Nested Class Summary
 
Nested classes inherited from class com.tensegrity.graphics.text.Element
Element.ElementIterator
 
Constructor Summary
AbstractElement()
          Constructor for AbstractElement.
AbstractElement(java.lang.String s)
          Creates a new Element from the given string by calling the setText method.
 
Method Summary
 void addElement(Element element)
          Method addElement adds an element to this Element.
abstract  java.util.List getCharacters()
          Method getCharacters should return a List with all CharacterElements of this Element implementation.
 Element getElement(int index)
          Method getElement returns the Element at position index.
 int getElementCount()
          Method getElementCount returns the number of elements contained by this Element as integer.
 FontFormat getFontFormat()
          Method getFontFormat returns the FontFormat instance associated with this element.
 java.lang.String getHtmlText()
          The default implementation of getHtmlText simply returns getText as html string.
 java.lang.String getText()
          Concats all containing Elements and returns it as String.
 boolean isEmpty()
          Method isEmpty returns true, if this Element doesn't contain any TextElements.
 java.util.Iterator iterator()
          Method iterator returns an iterator which allows to iterate through all elements of this Element.
 void remove(int index)
          Method remove removes the element at position index.
protected  void removeTextElements()
          Method removeTextElements removes all CharacterElements from the internal elements list.
 void setFontFormat(FontFormat fontFormat)
          Sets the format for this element and all subelements.
 void setText(java.lang.String text)
          Removes all TextElements from the elements list and fills the the array up with the new ones.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractElement

public AbstractElement()
Constructor for AbstractElement.


AbstractElement

public AbstractElement(java.lang.String s)
Creates a new Element from the given string by calling the setText method.

Parameters:
s - A String to create a new Element from.
Method Detail

getFontFormat

public FontFormat getFontFormat()
Description copied from interface: Element
Method getFontFormat returns the FontFormat instance associated with this element.

Specified by:
getFontFormat in interface Element
Returns:
FontFormat the FontFormat instance of this element.

setFontFormat

public void setFontFormat(FontFormat fontFormat)
Sets the format for this element and all subelements.

Specified by:
setFontFormat in interface Element
Parameters:
fontFormat - The FontFormat instance to be set.
See Also:
Element.setFontFormat(FontFormat)

addElement

public void addElement(Element element)
Description copied from interface: Element
Method addElement adds an element to this Element.

Specified by:
addElement in interface Element
Parameters:
element - the new Element to add.

getElement

public Element getElement(int index)
Description copied from interface: Element
Method getElement returns the Element at position index. within this Element.

Specified by:
getElement in interface Element
Parameters:
index - the index of the element.
Returns:
Element The Element at position index.

getElementCount

public int getElementCount()
Description copied from interface: Element
Method getElementCount returns the number of elements contained by this Element as integer.

Specified by:
getElementCount in interface Element
Returns:
int the number of Elements within this Element.

iterator

public java.util.Iterator iterator()
Description copied from interface: Element
Method iterator returns an iterator which allows to iterate through all elements of this Element.

Specified by:
iterator in interface Element
Returns:
Iterator a java.util based Iterator.

getCharacters

public abstract java.util.List getCharacters()
Method getCharacters should return a List with all CharacterElements of this Element implementation.

Returns:
List with all CharacterElements within this Element and all of its subelements.

setText

public final void setText(java.lang.String text)
Removes all TextElements from the elements list and fills the the array up with the new ones. This method is by intention final, because we dont want to allow any misinterpretation of the setText method within the whole text model.

Specified by:
setText in interface Element
Parameters:
text - the text of this Element as String.
See Also:
Element.setText(String)

getText

public java.lang.String getText()
Concats all containing Elements and returns it as String.

Specified by:
getText in interface Element
Returns:
String The text as String.
See Also:
Element.getText()

getHtmlText

public java.lang.String getHtmlText()
The default implementation of getHtmlText simply returns getText as html string. NOTE:An atomic html text element might be responsible to provide the right character encoding of its character! At this point a < character would return its specific html representation.

Specified by:
getHtmlText in interface Element
Returns:
String the text of this element as html.
See Also:
Element.getHtmlText()

remove

public void remove(int index)
Description copied from interface: Element
Method remove removes the element at position index.

Specified by:
remove in interface Element
Parameters:
index - the position of the element to remove.

isEmpty

public boolean isEmpty()
Description copied from interface: Element
Method isEmpty returns true, if this Element doesn't contain any TextElements. This method should be equal to
  return getElementCount() == 0;
 

Specified by:
isEmpty in interface Element
Returns:
boolean true, if this Element is empty.

removeTextElements

protected void removeTextElements()
Method removeTextElements removes all CharacterElements from the internal elements list.



Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.