org.vectomatic.dom.svg.ui
Class SVGImage

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by org.vectomatic.dom.svg.ui.SVGWidget
              extended by org.vectomatic.dom.svg.ui.SVGImage
All Implemented Interfaces:
com.google.gwt.event.dom.client.HasAllMouseHandlers, com.google.gwt.event.dom.client.HasAllTouchHandlers, com.google.gwt.event.dom.client.HasClickHandlers, com.google.gwt.event.dom.client.HasLoadHandlers, com.google.gwt.event.dom.client.HasMouseDownHandlers, com.google.gwt.event.dom.client.HasMouseMoveHandlers, com.google.gwt.event.dom.client.HasMouseOutHandlers, com.google.gwt.event.dom.client.HasMouseOverHandlers, com.google.gwt.event.dom.client.HasMouseUpHandlers, com.google.gwt.event.dom.client.HasMouseWheelHandlers, com.google.gwt.event.dom.client.HasScrollHandlers, com.google.gwt.event.dom.client.HasTouchCancelHandlers, com.google.gwt.event.dom.client.HasTouchEndHandlers, com.google.gwt.event.dom.client.HasTouchMoveHandlers, com.google.gwt.event.dom.client.HasTouchStartHandlers, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.logical.shared.HasResizeHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsWidget, HasActivateHandlers, HasDocumentHandlers, HasFocusInHandlers, HasFocusOutHandlers, HasGraphicalHandlers, HasSVGZoomHandlers, ISVGStylable

@ElementParserToUse(className="org.vectomatic.dev.svg.impl.gen.SVGImageParser")
public class SVGImage
extends SVGWidget
implements HasGraphicalHandlers, com.google.gwt.event.dom.client.HasAllMouseHandlers, HasDocumentHandlers, ISVGStylable

A widget which contains a single OMSVGSVGElement. The class bridges event subscription methods and forwards them to the underlying OMSVGSVGElement. The class integrates with GWT Widget hierarchy.

You can define an SVGImage using UiBinder templates. Depending on your needs, you can either define the SVG inline. This can be convenient if you want to localize the button label, or use styles defined in the template. Or you can use an SVGResource with the resource attribute, if your SVG is large or if you want to keep your template more readable.

The following section shows a sample UiBinder template. Notice that you can bind tags inside the template to java variables. One of the <g> tag is bound to a java variable eyes of type OMSVGGElement and one of the <path> tag is bound to a java variable mouth of type OMSVGPathElement.

 <svgui:SVGImage>
  <svg width="100" height="100" viewBox="80 190 140 130" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
   <path d="m 208,146.86218 a 63,63.5 0 1 1 -126,0 63,63.5 0 1 1 126,0 z" style="fill:#ffff00;stroke:#000000;" transform="translate(3.9895924,108.83705)" />
   <g ui:field="eyes" transform="translate(10.960155,103.59114)">
    <path d="m 124,133.36218 c 0,4.97057 -4.02944,9 -9,9 -4.97056,0 -9,-4.02943 -9,-9 0,-4.97056 4.02944,-9 9,-9 4.97056,0 9,4.02944 9,9 z" class="{style.eye}" />
    <path d="m 124,133.36218 c 0,4.97057 -4.02944,9 -9,9 -4.97056,0 -9,-4.02943 -9,-9 0,-4.97056 4.02944,-9 9,-9 4.97056,0 9,4.02944 9,9 z" class="{style.eye}" transform="translate(44,0)" />
   </g>
   <path ui:field="mouth" d="m 118.88908,286.15612 5,10 10,5 30,0 10,-5 5,-10 -5,5 -10,5 -30,0 -10,-5 -5,-5 z" class="{style.mouth}" />
  </svg>
 </svgui:SVGImage>
 
Note that by default SVGImages are validated against the SVG 1.1 XSD schema. You can opt out of validation by setting the validated="false" attribute on the SVGImages.

Author:
laaglu

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
protected  OMSVGSVGElement svgElement
           
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
SVGImage()
          No-arg constructor.
SVGImage(OMSVGSVGElement svgElement)
           
SVGImage(SVGResource resource)
           
 
Method Summary
 com.google.gwt.event.shared.HandlerRegistration addActivateHandler(ActivateHandler handler)
          Adds a ActivateHandler handler.
 void addClassNameBaseVal(String className)
          Adds the specified class name to the baseVal CSS class name of this element
 com.google.gwt.event.shared.HandlerRegistration addClickHandler(com.google.gwt.event.dom.client.ClickHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addFocusInHandler(FocusInHandler handler)
          Adds a FocusInHandler handler.
 com.google.gwt.event.shared.HandlerRegistration addFocusOutHandler(FocusOutHandler handler)
          Adds a FocusOutHandler handler.
 com.google.gwt.event.shared.HandlerRegistration addLoadHandler(com.google.gwt.event.dom.client.LoadHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addMouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addMouseMoveHandler(com.google.gwt.event.dom.client.MouseMoveHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addMouseOutHandler(com.google.gwt.event.dom.client.MouseOutHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addMouseOverHandler(com.google.gwt.event.dom.client.MouseOverHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addMouseUpHandler(com.google.gwt.event.dom.client.MouseUpHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addMouseWheelHandler(com.google.gwt.event.dom.client.MouseWheelHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addScrollHandler(com.google.gwt.event.dom.client.ScrollHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addSVGZoomHandler(SVGZoomHandler handler)
          Adds a SVGZoomHandler handler.
 com.google.gwt.event.shared.HandlerRegistration addTouchCancelHandler(com.google.gwt.event.dom.client.TouchCancelHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addTouchEndHandler(com.google.gwt.event.dom.client.TouchEndHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addTouchMoveHandler(com.google.gwt.event.dom.client.TouchMoveHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addTouchStartHandler(com.google.gwt.event.dom.client.TouchStartHandler handler)
           
 OMSVGAnimatedString getClassName()
          Returns the CSS class name of this element.
 OMSVGStyle getStyle()
          Returns the CSS style of this element
 OMSVGSVGElement getSvgElement()
           
 void removeClassNameBaseVal(String className)
          Removes the specified class name from the baseVal CSS class name of this element
 void replaceClassNameBaseVal(String oldClassName, String newClassName)
          Replaces the specified class name in the baseVal CSS class name of this element with a new class name
 void setClassNameBaseVal(String className)
          Sets the baseVal CSS class name of this element to the specified value
 void setResource(SVGResource resource)
           
 void setSvgElement(OMSVGSVGElement svgElement)
           
 
Methods inherited from class org.vectomatic.dom.svg.ui.SVGWidget
getUiBinderField
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Field Detail

svgElement

protected OMSVGSVGElement svgElement
Constructor Detail

SVGImage

public SVGImage()
No-arg constructor. You must call setResource(SVGResource) or setSvgElement(OMSVGSVGElement) before using the widget.


SVGImage

public SVGImage(SVGResource resource)

SVGImage

public SVGImage(OMSVGSVGElement svgElement)
Method Detail

getSvgElement

public OMSVGSVGElement getSvgElement()

setResource

public void setResource(SVGResource resource)

setSvgElement

public void setSvgElement(OMSVGSVGElement svgElement)

addMouseDownHandler

public com.google.gwt.event.shared.HandlerRegistration addMouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler handler)
Specified by:
addMouseDownHandler in interface com.google.gwt.event.dom.client.HasMouseDownHandlers

addMouseUpHandler

public com.google.gwt.event.shared.HandlerRegistration addMouseUpHandler(com.google.gwt.event.dom.client.MouseUpHandler handler)
Specified by:
addMouseUpHandler in interface com.google.gwt.event.dom.client.HasMouseUpHandlers

addMouseOutHandler

public com.google.gwt.event.shared.HandlerRegistration addMouseOutHandler(com.google.gwt.event.dom.client.MouseOutHandler handler)
Specified by:
addMouseOutHandler in interface com.google.gwt.event.dom.client.HasMouseOutHandlers

addMouseOverHandler

public com.google.gwt.event.shared.HandlerRegistration addMouseOverHandler(com.google.gwt.event.dom.client.MouseOverHandler handler)
Specified by:
addMouseOverHandler in interface com.google.gwt.event.dom.client.HasMouseOverHandlers

addMouseMoveHandler

public com.google.gwt.event.shared.HandlerRegistration addMouseMoveHandler(com.google.gwt.event.dom.client.MouseMoveHandler handler)
Specified by:
addMouseMoveHandler in interface com.google.gwt.event.dom.client.HasMouseMoveHandlers

addTouchCancelHandler

public final com.google.gwt.event.shared.HandlerRegistration addTouchCancelHandler(com.google.gwt.event.dom.client.TouchCancelHandler handler)
Specified by:
addTouchCancelHandler in interface com.google.gwt.event.dom.client.HasTouchCancelHandlers

addTouchEndHandler

public final com.google.gwt.event.shared.HandlerRegistration addTouchEndHandler(com.google.gwt.event.dom.client.TouchEndHandler handler)
Specified by:
addTouchEndHandler in interface com.google.gwt.event.dom.client.HasTouchEndHandlers

addTouchMoveHandler

public final com.google.gwt.event.shared.HandlerRegistration addTouchMoveHandler(com.google.gwt.event.dom.client.TouchMoveHandler handler)
Specified by:
addTouchMoveHandler in interface com.google.gwt.event.dom.client.HasTouchMoveHandlers

addTouchStartHandler

public final com.google.gwt.event.shared.HandlerRegistration addTouchStartHandler(com.google.gwt.event.dom.client.TouchStartHandler handler)
Specified by:
addTouchStartHandler in interface com.google.gwt.event.dom.client.HasTouchStartHandlers

addClickHandler

public com.google.gwt.event.shared.HandlerRegistration addClickHandler(com.google.gwt.event.dom.client.ClickHandler handler)
Specified by:
addClickHandler in interface com.google.gwt.event.dom.client.HasClickHandlers

addLoadHandler

public com.google.gwt.event.shared.HandlerRegistration addLoadHandler(com.google.gwt.event.dom.client.LoadHandler handler)
Specified by:
addLoadHandler in interface com.google.gwt.event.dom.client.HasLoadHandlers

addResizeHandler

public com.google.gwt.event.shared.HandlerRegistration addResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler handler)
Specified by:
addResizeHandler in interface com.google.gwt.event.logical.shared.HasResizeHandlers

addScrollHandler

public com.google.gwt.event.shared.HandlerRegistration addScrollHandler(com.google.gwt.event.dom.client.ScrollHandler handler)
Specified by:
addScrollHandler in interface com.google.gwt.event.dom.client.HasScrollHandlers

addSVGZoomHandler

public com.google.gwt.event.shared.HandlerRegistration addSVGZoomHandler(SVGZoomHandler handler)
Description copied from interface: HasSVGZoomHandlers
Adds a SVGZoomHandler handler.

Specified by:
addSVGZoomHandler in interface HasSVGZoomHandlers
Parameters:
handler - the zoom handler
Returns:
HandlerRegistration used to remove this handler

addFocusInHandler

public com.google.gwt.event.shared.HandlerRegistration addFocusInHandler(FocusInHandler handler)
Description copied from interface: HasFocusInHandlers
Adds a FocusInHandler handler.

Specified by:
addFocusInHandler in interface HasFocusInHandlers
Parameters:
handler - the focusin handler
Returns:
HandlerRegistration used to remove this handler

addFocusOutHandler

public com.google.gwt.event.shared.HandlerRegistration addFocusOutHandler(FocusOutHandler handler)
Description copied from interface: HasFocusOutHandlers
Adds a FocusOutHandler handler.

Specified by:
addFocusOutHandler in interface HasFocusOutHandlers
Parameters:
handler - the focusout handler
Returns:
HandlerRegistration used to remove this handler

addActivateHandler

public com.google.gwt.event.shared.HandlerRegistration addActivateHandler(ActivateHandler handler)
Description copied from interface: HasActivateHandlers
Adds a ActivateHandler handler.

Specified by:
addActivateHandler in interface HasActivateHandlers
Parameters:
handler - the activate handler
Returns:
HandlerRegistration used to remove this handler

addMouseWheelHandler

public com.google.gwt.event.shared.HandlerRegistration addMouseWheelHandler(com.google.gwt.event.dom.client.MouseWheelHandler handler)
Specified by:
addMouseWheelHandler in interface com.google.gwt.event.dom.client.HasMouseWheelHandlers

getStyle

public OMSVGStyle getStyle()
Description copied from interface: ISVGStylable
Returns the CSS style of this element

Specified by:
getStyle in interface ISVGStylable

getClassName

public final OMSVGAnimatedString getClassName()
Description copied from interface: ISVGStylable
Returns the CSS class name of this element. Note that in SVG, this class name can change over the time (there is a baseVal and an animVal).

Specified by:
getClassName in interface ISVGStylable
Returns:
the CSS class name of this element

addClassNameBaseVal

public final void addClassNameBaseVal(String className)
Description copied from interface: ISVGStylable
Adds the specified class name to the baseVal CSS class name of this element

Specified by:
addClassNameBaseVal in interface ISVGStylable
Parameters:
className - the class name to add

removeClassNameBaseVal

public final void removeClassNameBaseVal(String className)
Description copied from interface: ISVGStylable
Removes the specified class name from the baseVal CSS class name of this element

Specified by:
removeClassNameBaseVal in interface ISVGStylable
Parameters:
className - the class name to remove

replaceClassNameBaseVal

public final void replaceClassNameBaseVal(String oldClassName,
                                          String newClassName)
Description copied from interface: ISVGStylable
Replaces the specified class name in the baseVal CSS class name of this element with a new class name

Specified by:
replaceClassNameBaseVal in interface ISVGStylable
Parameters:
oldClassName - the class name to replace
newClassName - the replacement class name

setClassNameBaseVal

public final void setClassNameBaseVal(String className)
Description copied from interface: ISVGStylable
Sets the baseVal CSS class name of this element to the specified value

Specified by:
setClassNameBaseVal in interface ISVGStylable
Parameters:
className - the class name


Copyright © 2012. All Rights Reserved.