Class SplitterTag

  • All Implemented Interfaces:
    Composite, ConditionalTag, org.apache.commons.jelly.Tag

    public class SplitterTag
    extends ContainerTag

    A tag for implementing a splitter component.

    A splitter is an element, which separates two arbitrary elements, either vertically or horizontally. The user can drag the splitter and thus change the size of the associated elements.

    This tag expects exactly two other component tags in its body (which itself can be container tags holding arbitrary other components). These are the components whose size is controlled by the splitter. The following attributes are supported:

    Attribute Description Optional
    size Defines the size of the slider component in pixels. This is either the width or the height of the slider bar (depending on the slider's orientation). Yes
    orientation This attribute defines the slider's orientation (i.e. vertical or horizontal). Allowed values are specified by the Orientation enumeration class. Case does not matter. If this attribute is not provided, the slider will be vertical. Yes
    pos With this attribute an initial position of the slider can be specified in pixels. Yes
    resizeWeight Determines the behavior of the slider when the available space changes. This attribute can take a value between 0 and 1. A value of 0 means that only the right/bottom component is affected by the change, a value of 1 would only modify the left/top component. 0.5 means that both components are equally affected, and so on. Yes

    Version:
    $Id: SplitterTag.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Constructor Detail

      • SplitterTag

        public SplitterTag()
    • Method Detail

      • getOrientation

        public String getOrientation()
        Returns the orientation of the splitter as a string value. This is the value passed to the orientation attribute. It may not be a valid instance of the Orientation enumeration class.
        Returns:
        the orientation as string
      • setOrientation

        public void setOrientation​(String orientation)
        Set method for the orientation attribute.
        Parameters:
        orientation - the attribute's value
      • getSplitterOrientation

        public Orientation getSplitterOrientation()
        Returns the final orientation of the splitter. This value is determined based on the value of the orientation attribute when the tag is processed. If the orientation cannot be resolved, processing of the tag throws an exception.
        Returns:
        the Orientation value of the splitter
      • getPos

        public int getPos()
        Returns the initial position of the splitter.
        Returns:
        the initial position
      • setPos

        public void setPos​(int pos)
        Setter method for the pos attribute.
        Parameters:
        pos - the attribute's value
      • getResizeWeight

        public float getResizeWeight()
        Returns the splitter' resize weight. This factor determines how the associated components are affected by a change of the size.
        Returns:
        the resize weight factor
      • setResizeWeight

        public void setResizeWeight​(float resizeWeight)
        Setter method for the resizeWeight attribute.
        Parameters:
        resizeWeight - the attribute's value
      • getSize

        public int getSize()
        Returns the splitter's size. This is the width or height (depending on the orientation) of the drawn bar.
        Returns:
        the size of the splitter
      • setSize

        public void setSize​(int size)
        Setter method of the size attribute.
        Parameters:
        size - the attribute's value
      • getFirstComponent

        public Object getFirstComponent()
        Returns the first component of the splitter.
        Returns:
        the first component
      • getSecondComponent

        public Object getSecondComponent()
        Returns the second component of the splitter.
        Returns:
        the second component
      • processBeforeBody

        protected void processBeforeBody()
                                  throws org.apache.commons.jelly.JellyTagException,
                                         FormBuilderException
        Performs processing before the evaluation of this tag's body. This implementation tries to resolve the value passed to the orientation attribute.
        Overrides:
        processBeforeBody in class ContainerTag
        Throws:
        org.apache.commons.jelly.JellyTagException - if the tag is used incorrectly
        FormBuilderException - if an error occurs
      • createContainer

        protected Object createContainer​(ComponentManager manager,
                                         boolean create,
                                         Collection<Object[]> components)
                                  throws FormBuilderException,
                                         org.apache.commons.jelly.JellyTagException
        Creates the container component. This implementation will delegate to the component manager to create and initialize the splitter component.
        Specified by:
        createContainer in class ContainerTag
        Parameters:
        manager - the component manager
        create - the create flag
        components - a collection with the container's children
        Returns:
        the newly created component
        Throws:
        FormBuilderException - if the tag is incorrectly used
        org.apache.commons.jelly.JellyTagException - if the tag is incorrectly used
      • addComponents

        protected void addComponents​(ComponentManager manager,
                                     Object container,
                                     Collection<Object[]> comps)
        Adds the components to this container. This implementation is left empty because the splitter's components are handled in a different way.
        Overrides:
        addComponents in class ContainerTag
        Parameters:
        manager - the component manager
        container - the container object
        comps - a collection with the child components