Class ReflectionBehavior
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- org.wicketstuff.minis.behavior.reflection.ReflectionBehavior
-
- All Implemented Interfaces:
Serializable,IComponentAwareEventSink,IComponentAwareHeaderContributor,IClusterable
public class ReflectionBehavior extends Behavior
Behavior for adding reflections to an image. Uses reflection.js (v1.6), licensed under a MIT license.Add this behavior to your image to generate a reflection. You can change the height and opacity of the reflection using the provided setters.
Ultimately the markup you attach this behavior to must be an image, but it need not be a Wicket
Imagecomponent, a markup container will suffice, provided the tag is an img-tag.You can also use this class to generate add and remove reflection scriptlets for use in Ajax request targets or any other place you want. All you need to do is ensure the reflection.js is added to the head of the document. You can use the
REFLECTION_JSresource reference for that.The reflection.js library and more documentation can be found here http://cow.neondragon.net/stuff/reflection/
- Author:
- Martijn Dashorst
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReflectionBehavior.JavascriptContainer for javascript calls this behavior enables
-
Field Summary
Fields Modifier and Type Field Description static ResourceReferenceREFLECTION_JSThe resource reference to the reflection.js file.
-
Constructor Summary
Constructors Constructor Description ReflectionBehavior()Default constructor, creates a reflection using the default settings from reflection.js.ReflectionBehavior(Integer height, Integer opacity)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind(Component component)Binds the component to this behavior.voidrenderHead(Component c, IHeaderResponse response)Adds the reflection.js javascript to the page.voidsetReflectionHeight(Integer height)Sets the reflection height.voidsetReflectionOpacity(Integer opacity)Sets the opacity of the reflection.-
Methods inherited from class org.apache.wicket.behavior.Behavior
afterRender, beforeRender, canCallListener, detach, getStatelessHint, isEnabled, isTemporary, onAttribute, onComponentTag, onConfigure, onEvent, onException, onRemove, onTag, unbind
-
-
-
-
Field Detail
-
REFLECTION_JS
public static final ResourceReference REFLECTION_JS
The resource reference to the reflection.js file.
-
-
Constructor Detail
-
ReflectionBehavior
public ReflectionBehavior()
Default constructor, creates a reflection using the default settings from reflection.js.
-
ReflectionBehavior
public ReflectionBehavior(Integer height, Integer opacity)
Constructor- Parameters:
height- seesetReflectionHeight(Integer)opacity- seesetReflectionOpacity(Integer)
-
-
Method Detail
-
bind
public void bind(Component component)
Binds the component to this behavior.- Overrides:
bindin classBehavior- See Also:
Behavior.bind(Component)
-
renderHead
public void renderHead(Component c, IHeaderResponse response)
Adds the reflection.js javascript to the page.- Specified by:
renderHeadin interfaceIComponentAwareHeaderContributor- Overrides:
renderHeadin classBehavior- See Also:
Behavior#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
-
setReflectionHeight
public void setReflectionHeight(Integer height)
Sets the reflection height. This is a percentage of the original image. A height of 50 means that the reflection will be half the size of the original image, increasing the image size to 150%. Set the value to null to reset to the default value.- Parameters:
height- the height of the reflection as a percentage of the original image, valid values range from 0 to 100.
-
setReflectionOpacity
public void setReflectionOpacity(Integer opacity)
Sets the opacity of the reflection.- Parameters:
opacity- the opacity. Valid values range from 0 to 100.
-
-