org.wicketstuff.minis.reflection
Class ReflectionBehavior

java.lang.Object
  extended by org.apache.wicket.behavior.AbstractBehavior
      extended by org.wicketstuff.minis.reflection.ReflectionBehavior
All Implemented Interfaces:
java.io.Serializable, org.apache.wicket.behavior.IBehavior, org.apache.wicket.IClusterable, org.apache.wicket.markup.html.IHeaderContributor

public class ReflectionBehavior
extends org.apache.wicket.behavior.AbstractBehavior

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 Image component, 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_JS resource 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
static class ReflectionBehavior.Javascript
          Container for javascript calls this behavior enables
 
Field Summary
static org.apache.wicket.ResourceReference REFLECTION_JS
          The resource reference to the reflection.js file.
 
Constructor Summary
ReflectionBehavior()
          Default constructor, creates a reflection using the default settings from reflection.js.
ReflectionBehavior(java.lang.Integer height, java.lang.Integer opacity)
          Constructor
 
Method Summary
 void bind(org.apache.wicket.Component component)
          Binds the component to this behavior.
 void renderHead(org.apache.wicket.markup.html.IHeaderResponse response)
          Adds the reflection.js javascript to the page.
 void setReflectionHeight(java.lang.Integer height)
          Sets the reflection height.
 void setReflectionOpacity(java.lang.Integer opacity)
          Sets the opacity of the reflection.
 
Methods inherited from class org.apache.wicket.behavior.AbstractBehavior
afterRender, beforeRender, cleanup, detach, detachModel, exception, getStatelessHint, isEnabled, isTemporary, onComponentTag, onException, onRendered, rendered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REFLECTION_JS

public static final org.apache.wicket.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(java.lang.Integer height,
                          java.lang.Integer opacity)
Constructor

Parameters:
height - see setReflectionHeight(Integer)
opacity - see setReflectionOpacity(Integer)
Method Detail

bind

public void bind(org.apache.wicket.Component component)
Binds the component to this behavior.

Specified by:
bind in interface org.apache.wicket.behavior.IBehavior
Overrides:
bind in class org.apache.wicket.behavior.AbstractBehavior
See Also:
IBehavior.bind(Component)

setReflectionHeight

public void setReflectionHeight(java.lang.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(java.lang.Integer opacity)
Sets the opacity of the reflection.

Parameters:
opacity - the opacity. Valid values range from 0 to 100.

renderHead

public void renderHead(org.apache.wicket.markup.html.IHeaderResponse response)
Adds the reflection.js javascript to the page.

Specified by:
renderHead in interface org.apache.wicket.markup.html.IHeaderContributor
Overrides:
renderHead in class org.apache.wicket.behavior.AbstractBehavior
See Also:
AbstractBehavior.renderHead(org.apache.wicket.markup.html.IHeaderResponse)


Copyright © 2010. All Rights Reserved.