|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IRenderer
Renderer produces graphical representation of given data. Displays nodes from one namespace only. For each nametree present in transformed document a separate instance of renderer is constructed.
First the init(Source, RendererContext)
method is called to
initialize the renderer. After the initialization the renderer must be able
to provide drawing size, figures, and must be able to paint itself on a
Graphics
instance. reinit(IChangeCollector)
may be
called at any time to inform renderer of partial data change.
Renderer can support only two kinds of sources: the
DOMSource
and
ObjectSource
:
Instance of renderer is always used by a single thread - it should not be synchronized, resulting in faster execution.
Method Summary | |
---|---|
IInputPreprocessor |
createPreprocessor()
Constructs new instance of preprocessor. |
org.eclipse.draw2d.geometry.Dimension |
getCanvasSize()
Retrieves size of area where the rendering occurs. |
IEMFigure |
getFigure(Object o)
Retrieves figure that displays given data object. |
RendererInfo |
getInfo()
Returns instance of RendererInfo able to create this renderer. |
org.eclipse.draw2d.geometry.Point |
getPlacement(String id)
Returns point, relative to renderer's canvas, where canvas of child renderer will be positioned. |
IEMFigure |
getRootFigure()
Retrieves the root figure, where all figures will be placed. |
void |
init(Source transformedDoc,
RendererContext context)
Initializes the renderer. |
Object |
offerObject()
When the renderer accepts the ObjectSource but wants to provide an object as a result (for example it wants the document producer to draw something in a certain instance of Graphics), then return non-null value. |
void |
reinit(IChangeCollector changes)
Reinitialize the renderer when a partial change of the rendered document occurs. |
void |
render(org.eclipse.draw2d.Graphics g)
Paint rendered view to Graphics . |
Method Detail |
---|
void init(Source transformedDoc, RendererContext context) throws EditorException
Initializes the renderer. Called as the first method (only the
offerObject()
and getInfo()
methods may be called
before this method). Renderer should prepare IFigure
instances
for future rendering.
If an element from another namespace occurs (generef
processing instruction in case of DOMSource
- you can retrieve id
using SplittedDocHolder.getRef(org.w3c.dom.Node)
function, or a
custom object type in case of ObjectSource
), the
following steps are to be taken:
Composite
widget.getPlacement(String)
method.
transformedDoc
- fragment of document, DOMSource
or
ObjectSource
instance. This nametree is to be rendered by
the renderer. Renderer is encouraged to throw any exception including
ClassCastException
if it encounters illegal objects, to
detect invalid objects quickly and cleanly.context
- the context instance, allows you to ask for child
renderers output, etc.
EditorException
- if initialization fails.org.eclipse.draw2d.geometry.Point getPlacement(String id)
id
- the child nametree's ID.
null
if the child renderer's canvas
is not visible (not placed anywhere).void reinit(IChangeCollector changes) throws EditorException
Reinitialize the renderer when a partial change of the rendered document
occurs. Renderer should discard IFigures no longer needed, and prepare
new IFigures. This changed
object is given to an editor
when this method finishes, to allow the editor to query for new figures.
changes
- defines changed elements. Has appropriate type for
transformedDoc
parameter, i.e. DOMChangeCollector
for DOMSource
etc. Contains source with
all changes already applied.
EditorException
- if error occurs.org.eclipse.draw2d.geometry.Dimension getCanvasSize() throws EditorException
null
.
EditorException
- if error occurs.IEMFigure getFigure(Object o)
o
- the data object, may be any object instance when transformed
document is in form of ObjectSource
, or a
Node
instance otherwise.
IEMFigure getRootFigure()
void render(org.eclipse.draw2d.Graphics g) throws EditorException
Paint rendered view to Graphics
. Use the context object
to let the children renderers to paint.
g
- paint onto this graphics instance.
EditorException
- if error occurs.Object offerObject()
When the renderer accepts the ObjectSource but wants to provide an object
as a result (for example it wants the document producer to draw something
in a certain instance of Graphics), then return non-null value. If this
functionality is not needed then just return null
- if the
document producer requires some object then it can create any object as
long as it is instance of class that this exporter expects.
The consumer (the one that receives the object, i.e. this) is responsible
for freeing the object if necessary (at the end of the export method),
even if this function returned null
.
If you want producer (the one that creates the object) to create custom
instances then provide a factory object. This trick is used with
http://www.uniba.sk/euromath/holder/java.awt.Graphics
holder - a factory is returned that is able to produce
java.awt.Graphics
instances.
This method can be called anytime, and is usually called before
init(Source, RendererContext)
.
null
.RendererInfo getInfo()
RendererInfo
able to create this renderer.
IInputPreprocessor createPreprocessor()
null
then no
preprocessor is needed and will be ignored.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |