org.vectomatic.dom.svg.ui
Class SVGButtonBase

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.SVGButtonBase
All Implemented Interfaces:
com.google.gwt.event.dom.client.ClickHandler, com.google.gwt.event.dom.client.HasAllMouseHandlers, com.google.gwt.event.dom.client.HasClickHandlers, 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.MouseDownHandler, com.google.gwt.event.dom.client.MouseOutHandler, com.google.gwt.event.dom.client.MouseOverHandler, com.google.gwt.event.dom.client.MouseUpHandler, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.EventHandler, 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, ISVGStylable
Direct Known Subclasses:
SVGPushButton, SVGToggleButton

public abstract class SVGButtonBase
extends SVGWidget
implements com.google.gwt.event.dom.client.HasClickHandlers, com.google.gwt.event.dom.client.HasAllMouseHandlers, com.google.gwt.event.dom.client.MouseDownHandler, com.google.gwt.event.dom.client.MouseUpHandler, com.google.gwt.event.dom.client.MouseOverHandler, com.google.gwt.event.dom.client.MouseOutHandler, com.google.gwt.event.dom.client.ClickHandler, ISVGStylable

Abstract base class for SVG buttons.

SVG buttons consists in an SVG element and a collection of six predefined faces

Each face consists in a list of changes which are applied to the main SVG element (currently, CSS style changes but other changes are possible). You do not need to specify all faces for a button. In case a face is missing, the widget will attempt to use another face for the button.

Author:
laaglu

Nested Class Summary
static class SVGButtonBase.SVGFace
          Class to represent an SVG button face.
static class SVGButtonBase.SVGFaceChange
          Base class to represent the changes occurring to an SVG button when it enters a new state.
static class SVGButtonBase.SVGFaceName
          Enum to represent the possible states of an SVG button
static class SVGButtonBase.SVGStyleChange
          Class to represent a style change as an SVG button enters a new state.
 
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  SVGButtonBase.SVGFaceName currentFaceName
          The name of the face currently displayed by this button
protected  Map<SVGButtonBase.SVGFaceName,SVGButtonBase.SVGFace> faces
          A map associating button face names to button faces
protected  OMSVGSVGElement svgElement
          The OMSVGSVGElement representing this button
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
protected SVGButtonBase()
          No-arg constructor.
protected SVGButtonBase(OMSVGSVGElement svgElement, Map<SVGButtonBase.SVGFaceName,SVGButtonBase.SVGFace> faces)
          Constructor
protected SVGButtonBase(SVGResource resource, Map<SVGButtonBase.SVGFaceName,SVGButtonBase.SVGFace> faces)
          Constructor
 
Method Summary
 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)
           
 SVGButtonBase.SVGFace addFace(SVGButtonBase.SVGFaceName faceName, SVGButtonBase.SVGFace face)
          Adds a new faces to the button
 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)
           
 OMSVGAnimatedString getClassName()
          Returns the CSS class name of this element.
 SVGButtonBase.SVGFaceName getCurrentFaceName()
          Returns the name of the face currently displayed by this button
 SVGButtonBase.SVGFace getFace(SVGButtonBase.SVGFaceName faceName)
          Returns the face associated with a face name
 OMSVGStyle getStyle()
          Returns the CSS style of this element
 OMSVGSVGElement getSvgElement()
          Returns the SVG element defining the button
 boolean isEnabled()
          Returns true if this button is enabled, false otherwise
 void onClick(com.google.gwt.event.dom.client.ClickEvent event)
           
 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 setEnabled(boolean enabled)
          Sets whether this button is enabled
 void setResource(SVGResource resource)
          Sets the SVG resource defining the button
 void setSvgElement(OMSVGSVGElement svgElement)
          Sets the SVG element defining the button
 void showFace(SVGButtonBase.SVGFaceName faceName)
          Forces the button to display the specified face
 
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
 
Methods inherited from interface com.google.gwt.event.dom.client.MouseDownHandler
onMouseDown
 
Methods inherited from interface com.google.gwt.event.dom.client.MouseUpHandler
onMouseUp
 
Methods inherited from interface com.google.gwt.event.dom.client.MouseOverHandler
onMouseOver
 
Methods inherited from interface com.google.gwt.event.dom.client.MouseOutHandler
onMouseOut
 

Field Detail

svgElement

protected OMSVGSVGElement svgElement
The OMSVGSVGElement representing this button


currentFaceName

protected SVGButtonBase.SVGFaceName currentFaceName
The name of the face currently displayed by this button


faces

protected Map<SVGButtonBase.SVGFaceName,SVGButtonBase.SVGFace> faces
A map associating button face names to button faces

Constructor Detail

SVGButtonBase

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


SVGButtonBase

protected SVGButtonBase(OMSVGSVGElement svgElement,
                        Map<SVGButtonBase.SVGFaceName,SVGButtonBase.SVGFace> faces)
Constructor

Parameters:
svgElement - The SVG element defining the button
faces - A collection of faces

SVGButtonBase

protected SVGButtonBase(SVGResource resource,
                        Map<SVGButtonBase.SVGFaceName,SVGButtonBase.SVGFace> faces)
Constructor

Parameters:
resource - An SVG resource to use for the SVG element defining the button
faces - The SVG element defining the button
Method Detail

addFace

public SVGButtonBase.SVGFace addFace(SVGButtonBase.SVGFaceName faceName,
                                     SVGButtonBase.SVGFace face)
Adds a new faces to the button

Parameters:
faceName - The face name
face - The face
Returns:
The face previously associated with this face name if there was one, null otherwise

getFace

public SVGButtonBase.SVGFace getFace(SVGButtonBase.SVGFaceName faceName)
Returns the face associated with a face name

Parameters:
faceName - The face name
Returns:
The face associated with this face name if there is one, null otherwise

setResource

public void setResource(SVGResource resource)
Sets the SVG resource defining the button

Parameters:
resource - An SVG resource

getSvgElement

public OMSVGSVGElement getSvgElement()
Returns the SVG element defining the button

Returns:
the SVG element defining the button

setSvgElement

public void setSvgElement(OMSVGSVGElement svgElement)
Sets the SVG element defining the button

Parameters:
svgElement - the SVG element defining the button

getCurrentFaceName

public SVGButtonBase.SVGFaceName getCurrentFaceName()
Returns the name of the face currently displayed by this button

Returns:
the name of the face currently displayed by this button

isEnabled

public boolean isEnabled()
Returns true if this button is enabled, false otherwise

Returns:
true if this button is enabled, false otherwise

setEnabled

public void setEnabled(boolean enabled)
Sets whether this button is enabled

Parameters:
enabled - true to enable the button, false to disable it

showFace

public void showFace(SVGButtonBase.SVGFaceName faceName)
Forces the button to display the specified face

Parameters:
faceName - The name of the face to display

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

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

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

onClick

public void onClick(com.google.gwt.event.dom.client.ClickEvent event)
Specified by:
onClick in interface com.google.gwt.event.dom.client.ClickHandler


Copyright © 2012. All Rights Reserved.