net.sourceforge.jeuclid.layout
Class JEuclidView

java.lang.Object
  extended by net.sourceforge.jeuclid.layout.JEuclidView
All Implemented Interfaces:
LayoutView, EventListener, org.w3c.dom.views.AbstractView

public class JEuclidView
extends Object
implements org.w3c.dom.views.AbstractView, LayoutView, EventListener

Version:
$Revision: 371548310efa $

Nested Class Summary
static class JEuclidView.NodeRect
          Data structure for storing a Node along with its rendering boundary (Rectangle2D).
 
Constructor Summary
JEuclidView(Node node, LayoutContext layoutContext, Graphics2D layoutGraphics)
          Default Constructor.
 
Method Summary
 void draw(Graphics2D g, float x, float y)
          Draw this view onto a Graphics context.
 float getAscentHeight()
           
 float getDescentHeight()
           
 org.w3c.dom.views.DocumentView getDocument()
          
 Graphics2D getGraphics()
          
 LayoutInfo getInfo(LayoutableNode node)
          Retrieve the Info object for a given child.
 List<JEuclidView.NodeRect> getNodesAt(float x, float y, float offsetX, float offsetY)
          Get the node and rendering information from a mouse position.
 Rectangle2D getRect(float offsetX, float offsetY, LayoutableNode node)
          Gets the absolute Bounds for a given node and offset.
 float getWidth()
           
 void handleEvent(Event evt)
          
static DocumentElement replaceNodes(DocumentElement jDocOld, Node oldNode, Node newNode)
          replace old node with new node in JEuclid document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JEuclidView

public JEuclidView(Node node,
                   LayoutContext layoutContext,
                   Graphics2D layoutGraphics)
Default Constructor.

Parameters:
node - document to layout.
layoutGraphics - Graphics context to use for layout calculations. This should be compatible to the context used for painting, but does not have to be the same. If it is null, a default Graphics context is created.
layoutContext - layoutContext to use.
Method Detail

replaceNodes

public static DocumentElement replaceNodes(DocumentElement jDocOld,
                                           Node oldNode,
                                           Node newNode)
replace old node with new node in JEuclid document.

Parameters:
jDocOld - old JEuclid document
oldNode - Node to remove
newNode - Node to insert
Returns:
new JEuclid Document

getDocument

public org.w3c.dom.views.DocumentView getDocument()

Specified by:
getDocument in interface org.w3c.dom.views.AbstractView

draw

public void draw(Graphics2D g,
                 float x,
                 float y)
Draw this view onto a Graphics context.

Parameters:
x - x-offset for left edge
y - y-offset for baseline
g - Graphics context for painting. Should be compatible to the context used during construction, but does not have to be the same.

getInfo

public LayoutInfo getInfo(LayoutableNode node)
Retrieve the Info object for a given child.

Specified by:
getInfo in interface LayoutView
Parameters:
node - the node
Returns:
an LayoutInfo object.

getWidth

public float getWidth()
Returns:
width of this view.

getAscentHeight

public float getAscentHeight()
Returns:
ascent height.

getDescentHeight

public float getDescentHeight()
Returns:
descent height.

getGraphics

public Graphics2D getGraphics()

Specified by:
getGraphics in interface LayoutView
Returns:
the Layout Graphics Context.

handleEvent

public void handleEvent(Event evt)

Specified by:
handleEvent in interface EventListener

getNodesAt

public List<JEuclidView.NodeRect> getNodesAt(float x,
                                             float y,
                                             float offsetX,
                                             float offsetY)
Get the node and rendering information from a mouse position.

Parameters:
x - x-coord
y - y-coord
offsetX - starting x position offset
offsetY - starting y position offset
Returns:
list of nodes with rendering information

getRect

public Rectangle2D getRect(float offsetX,
                           float offsetY,
                           LayoutableNode node)
Gets the absolute Bounds for a given node and offset. May return null if the node could not be found.

Parameters:
offsetX - x position offset to node
offsetY - y position offset to node
node - A layoutable node which was layouted in the current view.
Returns:
the rectangle with the absolute bounds or null if the given node was not layouted in this view.


Copyright © 2002-2010 The JEuclid project. All Rights Reserved.