Class ConstrainedIntProp

  • All Implemented Interfaces:
    EventListener, IGProp<java.lang.Integer>, java.lang.Cloneable

    public class ConstrainedIntProp
    extends IntProp
    This class is used to hold an integer property that has constraints imposed on it. The constraints string is in the format "token,token2,..." where a "token" can be either an integer value or a "range" in the format "min:max". An example for a horizontal position 4,5,6 for left, center, right and 0 (zero) for uninitialized would have the form "0,4-6" or "0,4,5,6".
    Author:
    Christopher Mindus
    • Constructor Detail

      • ConstrainedIntProp

        protected ConstrainedIntProp()
        Creates the component without a name and no constraints. The name and constraints must be set in all cases using the setPropertyAtom and setConstraints calls.
      • ConstrainedIntProp

        protected ConstrainedIntProp​(java.lang.String constraints)
                              throws PropException
        Creates the component without a name. The name must be set in all cases using the setPropertyAtom call.
        Parameters:
        constraints - The constraints string from the properties definition.
        Throws:
        PropException - For property constraints errors.
      • ConstrainedIntProp

        public ConstrainedIntProp​(Atom propertyAtom,
                                  java.lang.String constraints)
                           throws PropException
        Creates the component with the specified name. All system-reserved names for components begins with "$".
        Parameters:
        propertyAtom - the name of the component, unique within it's parent.
        constraints - The constraints string from the properties definition.
        Throws:
        PropException - For property constraints errors.
      • ConstrainedIntProp

        public ConstrainedIntProp​(Atom propertyAtom,
                                  java.lang.String constraints,
                                  int newValue)
                           throws PropException
        Creates the component with the specified name, initialized to contain the GProp items. All system-reserved names for components begins with "$".
        Parameters:
        propertyAtom - The name of the component, unique within it's parent.
        constraints - The constraints string from the properties definition.
        newValue - The alignment property value (1-9).
        Throws:
        PropException
    • Method Detail

      • setConstraints

        public java.lang.Object setConstraints​(java.lang.String constraints,
                                               org.w3c.dom.Element element)
                                        throws PropException
        Sets the constraints for the property.

        This method must be overridden by subclasses in order to load the constraints properly if the constraints-string is not sufficient, i.e. that additional settings must be loaded from the XML Element.

        Specified by:
        setConstraints in interface IGProp<java.lang.Integer>
        Overrides:
        setConstraints in class GProp<java.lang.Integer>
        Parameters:
        constraints - The constraints string from the properties definition.
        element - The Element that loads the property class from the properties definition. Note that Element may be null if the constructor isn't called from the PropertyFactory.
        Returns:
        The constraints object for reuse by the PropertyFactory with a subsequent setConstraints(Object) call instead of to this method.
        Throws:
        PropException - For errors in the constraints definitions.
      • setConstraints

        public void setConstraints​(java.lang.Object constraints,
                                   java.lang.String prevConstraints,
                                   org.w3c.dom.Element prevElement)
                            throws PropException
        Sets the constraints for the property previously returned from the same constraints call to setConstraints(String,Element) with the same String and Element as this instance would require.

        This method must be overridden by subclasses in order to load the constraints properly if the constraints-string is not sufficient, i.e. that additional settings must be loaded from the XML Element.

        Specified by:
        setConstraints in interface IGProp<java.lang.Integer>
        Overrides:
        setConstraints in class GProp<java.lang.Integer>
        Parameters:
        constraints - The constraints Object from the properties definition.
        prevConstraints - The previous constraints string from the properties definition.
        prevElement - The previous Element that loads the property class from the properties definition.
        Throws:
        PropException - For errors in the constraints definitions.
      • getConstraints

        public java.lang.String getConstraints()
        Gets the constraints string for this property.
        Specified by:
        getConstraints in interface IGProp<java.lang.Integer>
        Overrides:
        getConstraints in class GProp<java.lang.Integer>
        Returns:
        The constraints string used to in setConstraints to initiate the constraints for this property.
      • validatePropValue

        public void validatePropValue​(java.lang.Object newValue)
                               throws PropException
        Validates the value to set.

        Note: When this method is called, synchronization is done at the property itself, so no synchronization on the tree should be done.

        Specified by:
        validatePropValue in interface IGProp<java.lang.Integer>
        Overrides:
        validatePropValue in class GProp<java.lang.Integer>
        Parameters:
        newValue - The new value to set.
        Throws:
        PropException - when the new value doesn't validate correctly.