| java.lang.Object org.netbeans.modules.visualweb.css2.ModelViewMapper
ModelViewMapper | final public class ModelViewMapper (Code) | | Class responsible for mapping between the DOM (jsp document and
rendered html fragments) and the view (boxes and pixel coordinates).
It also handles caret motion. Note that methods which return positions
never return null, they return Position.NONE in that case.
author: Tor Norbye |
Method Summary | |
public static DomPosition | computeArrowDown(WebForm webform, DomPosition sourcePos) Given a caret position, return the caret position to "below" it; e.g. | public static DomPosition | computeArrowLeft(WebForm webform, DomPosition sourcePos) Given a caret position, return the caret position to its left. | public static DomPosition | computeArrowRight(WebForm webform, DomPosition sourcePos) Given a caret position, return the caret position to its right. | public static DomPosition | computeArrowUp(WebForm webform, DomPosition sourcePos) Given a caret position, return the caret position to "above" it; e.g. | public static CssBox | findBox(CssBox root, Node target, int offset) Find the box whose corresponding node matches the given node, starting
at the given root box. | public static CssBox | findBox(PageBox pageBox, Element element) Try to find the box corresponding to the given element. | public static CssBox | findBox(PageBox pageBox, int x, int y) | public static CssBox | findBoxForComponentRootElement(PageBox pageBox, Element componentRootElement) | public static Element | findClosestComponentRootElement(WebForm webForm, Node node) Finds closes parent (including itself) component root element. | public static Element | findComponentRootElement(CssBox box) Locates component root element in the visible view given the box. | public static Element | findElement(CssBox box) Locates element in the visible view given the box. | public static Element | findElement(PageBox pageBox, int x, int y) | public static Rectangle | findShape(PageBox pageBox, Element componentRootElement) | public static DomPosition | findValidPosition(WebForm webForm, DomPosition pos, boolean adjust, InlineEditor inline) Given a position in the DOM, find the closest valid position.
In particular, the position is not allowed to be inside any
"renders children" nodes. | public static Rectangle | getComponentBounds(PageBox pageBox, Element componentRootElement) | public static List<Rectangle> | getComponentRectangles(PageBox pageBox, Element componentRootElement) | public static DomPosition | getFirstDocumentPosition(WebForm webform, boolean create) Return the first caret position in the document. | public static DomPosition | getLastDocumentPosition(WebForm webform, boolean create) Return the last caret position in the document. | public static DomPosition | getLineBegin(WebForm webform, DomPosition sourcePos) | public static DomPosition | getLineEnd(WebForm webform, DomPosition sourcePos) | public static DomPosition | getWordEnd(PageBox pageBox, DomPosition sourcePos) | public static DomPosition | getWordStart(PageBox pageBox, DomPosition sourcePos) | public static boolean | isValidPosition(WebForm webForm, DomPosition pos, boolean adjust, InlineEditor inline) | public static Rectangle | modelToView(PageBox pageBox, DomPosition sourcePos) For the given caret position, compute the visible caret rectangle
on the screen. | public static DomPosition | viewToModel(WebForm webform, int x, int y) Provides a mapping from the view coordinate space to the logical
coordinate space of the model. |
computeArrowDown | public static DomPosition computeArrowDown(WebForm webform, DomPosition sourcePos)(Code) | | Given a caret position, return the caret position to "below" it; e.g. the
position we should move the caret to if the user presses the down arrow key.
Parameters: pos - The caret position in the DOM The next visual position below the given pos, or Position.NONE ifthere is no such position in the document (e.g. when you're on the last linein the document.) |
computeArrowLeft | public static DomPosition computeArrowLeft(WebForm webform, DomPosition sourcePos)(Code) | | Given a caret position, return the caret position to its left. This
may not actually be the left on the screen, e.g. if you press left at the
beginning of a line you may end up on the right side of the previous
line.
Parameters: pos - The caret position in the DOM The next visual position to the "left" of pos, or Position.NONE ifthere is no such position in the document (e.g. when you're at thefirst visual position in the document.) |
computeArrowRight | public static DomPosition computeArrowRight(WebForm webform, DomPosition sourcePos)(Code) | | Given a caret position, return the caret position to its right. This
may not actually be the right on the screen, e.g. if you press right at the
end of a line you may end up on the left side of the next
line.
Parameters: pos - The caret position in the DOM The next visual position to the "right" of pos, or Position.NONE ifthere is no such position in the document (e.g. when you're at thelast visual position in the document.) |
computeArrowUp | public static DomPosition computeArrowUp(WebForm webform, DomPosition sourcePos)(Code) | | Given a caret position, return the caret position to "above" it; e.g. the
position we should move the caret to if the user presses the up arrow key.
Parameters: pos - The caret position in the DOM The next visual position above the given pos, or Position.NONE ifthere is no such position in the document (e.g. when you're on the first linein the document.) |
findBox | public static CssBox findBox(CssBox root, Node target, int offset)(Code) | | Find the box whose corresponding node matches the given node, starting
at the given root box. The offset is only relevant when we're dealing with
a text box, where the node is split into many boxes.
|
findBox | public static CssBox findBox(PageBox pageBox, Element element)(Code) | | Try to find the box corresponding to the given element.
|
findBoxForComponentRootElement | public static CssBox findBoxForComponentRootElement(PageBox pageBox, Element componentRootElement)(Code) | | |
findClosestComponentRootElement | public static Element findClosestComponentRootElement(WebForm webForm, Node node)(Code) | | Finds closes parent (including itself) component root element.
|
findComponentRootElement | public static Element findComponentRootElement(CssBox box)(Code) | | Locates component root element in the visible view given the box.
Element or null if there is not such |
findElement | public static Element findElement(CssBox box)(Code) | | Locates element in the visible view given the box.
Element or null if there is not such |
findValidPosition | public static DomPosition findValidPosition(WebForm webForm, DomPosition pos, boolean adjust, InlineEditor inline)(Code) | | Given a position in the DOM, find the closest valid position.
In particular, the position is not allowed to be inside any
"renders children" nodes. It also doesn't allow positions
that are "adjacent" (before, after) an absolutely positioned
element.
Parameters: pos - Position to be checked Parameters: adjust - If true, adjust the position to the nearest (above)position that is valid. Parameters: inline - inlineEditor which is in the game in the designer or null. Parameters: dom - The JSPX document DOM |
getFirstDocumentPosition | public static DomPosition getFirstDocumentPosition(WebForm webform, boolean create)(Code) | | Return the first caret position in the document. If create is true,
create one if necessary.
|
getLastDocumentPosition | public static DomPosition getLastDocumentPosition(WebForm webform, boolean create)(Code) | | Return the last caret position in the document. If create is true,
create one if necessary.
|
getLineBegin | public static DomPosition getLineBegin(WebForm webform, DomPosition sourcePos)(Code) | | Return the position at the beginning of the line containing the given position
|
getLineEnd | public static DomPosition getLineEnd(WebForm webform, DomPosition sourcePos)(Code) | | Return the position at the end of the line containing the given position
|
getWordEnd | public static DomPosition getWordEnd(PageBox pageBox, DomPosition sourcePos)(Code) | | Find the end of the word from the given position
|
getWordStart | public static DomPosition getWordStart(PageBox pageBox, DomPosition sourcePos)(Code) | | Find the beginning of the word from the given position
|
isValidPosition | public static boolean isValidPosition(WebForm webForm, DomPosition pos, boolean adjust, InlineEditor inline)(Code) | | |
modelToView | public static Rectangle modelToView(PageBox pageBox, DomPosition sourcePos)(Code) | | For the given caret position, compute the visible caret rectangle
on the screen. Note that the position must fit certain criteria:
it needs to point inside a LineBox (e.g. be a valid caret position).
Parameters: A - position in the source dom (where carets live for example) |
viewToModel | public static DomPosition viewToModel(WebForm webform, int x, int y)(Code) | | Provides a mapping from the view coordinate space to the logical
coordinate space of the model.
The returned position is always a position in the source DOM,
not a position in the rendered DOM (unless it is Position.NONE
which means the position does not correlate to a position in the document.)
Parameters: x - the X coordinate >= 0 Parameters: y - the Y coordinate >= 0 the location within the model that best represents thegiven point in the view >= 0. |
|
|