I'm not sure of your exact usage, but .locate(int) is part of
LocationMapper, and goes with .getLocation(point)
essentially, the editor's document is both a DOM document (with
ContentNodes, -Elements and -TextNodes), indexable by 'Points' (= defined by
parent + child after)
but also an OT-aware document indexable by integers (e.g. 'insert the text
"hi" at position 4').

Location mapping helps convert between the two one when required - e.g. in
this case, the selection range is integer offsets (one for anchor, one for
node)
and here it's picking the first of the two (Math.min) then converting that
integer location to a point.
So they are two ways of describing the exact same thing - there are a few
things for which points are better (e.g. inserting an element into the tree)
and a few for which integers are (e.g. finding the first point, OT
operations, ...) so when conversion is required, that's then you use the
Location Mapper.

hope that helps!
- Pat


On 1 July 2011 18:17, Anton Starcev <[email protected]> wrote:

> Hi,
>
> Trying to insert doodad in editor, found "locate" method:
>
> final Point<ContentNode> point =
> editor.getDocument().locate(Math.min(range.getAnchor(),
> range.getFocus()));
>
> but can't understand how to use it in source code and in this tutorial:
> http://www.waveprotocol.org/code/tutorials/writing-a-doodad
>
>
> Антон Старцев
> ______________________________________________________________________
> [email protected] | www.artlebedev.ru
>

Reply via email to