cdox.edit
Class TextElement

java.lang.Object
  extended bycdox.edit.Element
      extended bycdox.edit.TextElement
All Implemented Interfaces:
java.awt.datatransfer.Transferable

public class TextElement
extends Element

This class represents an element that is contained within a document. The GenericElement can contain a java.awt.Component as data.

Author:
Rutger Bezema, Andreas Schmitz

Field Summary
static java.awt.datatransfer.DataFlavor TEXTELEMENT_FLAVOR
          The DataFlavor for cut/pasting text elements.
 
Fields inherited from class cdox.edit.Element
cachedImage, cover, dashed, diagonalResizeRect, elementSize, flipHorizontal, flipVertical, horizontalResizeRect, position, quality, ratioX, ratioY, rotateBy, verticalResizeRect
 
Constructor Summary
TextElement(java.awt.Point pos, TextPane c)
          Creates new element at the specified position.
 
Method Summary
protected  java.awt.image.BufferedImage getBufferedImage()
          This method must return an untransformed image of the element.
 TextPane getTextPane()
          Returns the TextPane for this text element.
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor f)
           
 java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
           
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor f)
           
 void resetFontSizes()
          Resizes all the text-Elements to its original fontsize.
protected  void saveMyself(org.w3c.dom.Element root, java.util.zip.ZipOutputStream out)
          This method saves its data in the given parameters.
 void setSize(java.awt.Dimension dim)
          This Method overrides the Element setSize method to enlarge the text.Elements in this textPane, for better rendering.
 
Methods inherited from class cdox.edit.Element
appendChild, createCachedImage, destroyMe, drawMyself, flipElementHorizontal, flipElementVertical, getDiagonalResizeRect, getHighlight, getHorizontalResizeRect, getMatrix, getPosition, getPrintableAffineTransform, getSize, getVerticalResizeRect, isInPlace, isMaintainingRatio, isRotating, isSelected, moveToTop, registerDoAction, rotateElement, setCover, setHighlight, setMaintainRatio, setPosition, setQuality, setRatio, setResizeRects, setSelected, startRotating, stopRotating, toString, unregisterDoAction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TEXTELEMENT_FLAVOR

public static java.awt.datatransfer.DataFlavor TEXTELEMENT_FLAVOR
The DataFlavor for cut/pasting text elements.

Constructor Detail

TextElement

public TextElement(java.awt.Point pos,
                   TextPane c)
Creates new element at the specified position.

Parameters:
pos - the position.
c - the component aka the content.
See Also:
TextPane
Method Detail

setSize

public void setSize(java.awt.Dimension dim)
This Method overrides the Element setSize method to enlarge the text.Elements in this textPane, for better rendering.

Overrides:
setSize in class Element
Parameters:
dim - the new Dimension.
See Also:
TextPane.resizeRelativeAttributeSet(int), Element.setSize(java.awt.Dimension)

resetFontSizes

public void resetFontSizes()
Resizes all the text-Elements to its original fontsize. And clears the realFontSizes Array.


getTextPane

public TextPane getTextPane()
Returns the TextPane for this text element.

Returns:
the pane.

getTransferDataFlavors

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor f)

getTransferData

public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor f)
                                 throws java.awt.datatransfer.UnsupportedFlavorException
Throws:
java.awt.datatransfer.UnsupportedFlavorException

getBufferedImage

protected java.awt.image.BufferedImage getBufferedImage()
Description copied from class: Element
This method must return an untransformed image of the element. The various transformations are done on this element, so it is a good idea to base the size of this image on the size of the element to achieve best quality.

Specified by:
getBufferedImage in class Element
Returns:
the BufferedImage.

saveMyself

protected void saveMyself(org.w3c.dom.Element root,
                          java.util.zip.ZipOutputStream out)
                   throws java.io.IOException
Description copied from class: Element
This method saves its data in the given parameters. It appends a child element ("element") to the given root element and saves its file(s), if any, to the ZipOutputStream. There exists a convenience method (appendChild()) which appends the child containing all required attributes to the root element, while returning the newly created child, so you can concentrate on the content (which must be appended to the "element" element).

Specified by:
saveMyself in class Element
Parameters:
root - the root element to append the child to.
out - the ZipOutputStream to write any files to.
Throws:
java.io.IOException - if writing into the ZipStream failed.
See Also:
Element.appendChild(org.w3c.dom.Element, java.lang.String)