com.ephox.editlive.view
Interface ViewAnnotation


public interface ViewAnnotation

A ViewAnnotation is a component which provides additional rendering for a View, e.g. a highlight or decal. Implementations of this interface must provide a constructor with a single Object parameter, which will be used to pass the extra data on the view annotation that is registered in CustomTagController.registerViewAnnotation(String, Class, Object). A common pattern is to pass in a controller object that can be queried for relevant information.


Method Summary
 Cursor getCursorFor(MouseEvent event, int pos, Point point, Rectangle allocation)
          Allows the annotation to override the mouse cursor at certain points in the view.
 String getToolTipText(Point point, Rectangle allocation)
          Allows the annotation to display a tooltip.
 void paint(Graphics graphics, Shape shape)
          Allows additional rendering on top of the existing content a View renders.
 void setPropertiesFromAttributes(View view)
          Called after the view's attributes have been updated in response to a document event.
 

Method Detail

paint

void paint(Graphics graphics,
           Shape shape)
Allows additional rendering on top of the existing content a View renders. Called after the View has completed the default paint() method.

Parameters:
graphics - the rendering surface to use
shape - allocation bounds of this view

setPropertiesFromAttributes

void setPropertiesFromAttributes(View view)
Called after the view's attributes have been updated in response to a document event. view.getAttributes() and view.getElement() will be useful here. Avoid caching the view - instead, cache attribute values retrieved from it.

Parameters:
view - the view associated with the ViewAnnotation

getToolTipText

String getToolTipText(Point point,
                      Rectangle allocation)
Allows the annotation to display a tooltip. The mouse location is provided so the tooltip can be restricted to a certain area of the view (this is used by the Inline Accessibility plugin so the tooltip only appears over the icons it adds instead of the entire view).

Parameters:
point - location of the mouse on screen when the tooltip must be displayed
allocation - allocation bounds of this view
Returns:
tooltip text to display, or null if there should not be a tooltip

getCursorFor

Cursor getCursorFor(MouseEvent event,
                    int pos,
                    Point point,
                    Rectangle allocation)
Allows the annotation to override the mouse cursor at certain points in the view. This is used by the Image Editing plugin when cropping.

Parameters:
event - mouse motion event that caused this request for a cursor
pos - precalculated document position under the cursor
point - mouse position on screen
allocation - allocation bounds of this view
Returns:
specific cursor required by this annotation, or null if the default should be used

Copyright (c) 2005-2012 Ephox Pty Ltd. All rights reserved.