Class Orientation


  • public class Orientation
    extends java.lang.Object
    Encapsulates internationalized orientation of objects. Static preinstantiated orientation objects are provided for common orientations.
    Author:
    Garret Wilson
    • Field Detail

      • LEFT_TO_RIGHT_TOP_TO_BOTTOM

        public static final Orientation LEFT_TO_RIGHT_TOP_TO_BOTTOM
        Left-to-right line, top-to-bottom page orientation (e.g. English).
      • RIGHT_TO_LEFT_TOP_TO_BOTTOM

        public static final Orientation RIGHT_TO_LEFT_TOP_TO_BOTTOM
        Right-to-left line, top-to-bottom page orientation (e.g. Arabic).
      • TOP_TO_BOTTOM_RIGHT_TO_LEFT

        public static final Orientation TOP_TO_BOTTOM_RIGHT_TO_LEFT
        Top-to-bottom line, right-to-left page orientation (e.g. Chinese).
    • Constructor Detail

      • Orientation

        public Orientation​(FlowOrientation lineOrientation,
                           FlowOrientation pageOrientation)
        Flow orientation constructor.
        Parameters:
        lineOrientation - The orientation of the line.
        pageOrientation - The orientation of the page.
        Throws:
        java.lang.NullPointerException - if the line orientation and/or page orientation is null.
        java.lang.IllegalArgumentException - if the line orientation and/or page orientation uses the Axis.Z axis.
        java.lang.IllegalArgumentException - if both flow orientations specify the same axis.
    • Method Detail

      • getOrientation

        public FlowOrientation getOrientation​(Flow flow)
        Determines the orientation for the particular flow.
        Parameters:
        flow - The flow (line or page).
        Returns:
        The orientation for the specified flow.
        Throws:
        java.lang.NullPointerException - if the given flow is null.
      • getAxis

        public Axis getAxis​(Flow flow)
        Determines the axis for the particular flow.
        Parameters:
        flow - The flow (line or page).
        Returns:
        The axis for the specified flow.
        Throws:
        java.lang.NullPointerException - if the given flow is null.
      • getFlow

        public Flow getFlow​(Axis axis)
        Determines the flow (line or page) that is aligned to the given axis.
        Parameters:
        axis - The axis for which flow should be determined.
        Returns:
        The flow that is aligned to the given axis.
        Throws:
        java.lang.NullPointerException - if the given axis is null.
      • getDirection

        public Flow.Direction getDirection​(Flow flow)
        Determines the direction of the particular flow.
        Parameters:
        flow - The flow (line or page).
        Returns:
        The direction of the specified flow.
        Throws:
        java.lang.NullPointerException - if the given flow is null.
      • getSide

        public Side getSide​(Border border)
        Determines the side for the particular border.
        Parameters:
        border - The logical border.
        Returns:
        The side for the specified border.
        Throws:
        java.lang.NullPointerException - if the given border is null.
      • getBorder

        public Border getBorder​(Side side)
        Determines the border that appears on the given side.
        Parameters:
        side - The side for which the border should be determined.
        Returns:
        The border that appears on the given side.
        Throws:
        java.lang.NullPointerException - if the given side is null.
      • getCompassPoint

        public CompassPoint getCompassPoint​(Flow flow,
                                            Flow.End end)
        Retrieves a cardinal compass point indicating the absolute direction based upon the given flow and end.
        Parameters:
        flow - The flow for which the compass point should be returned
        end - The end of the flow requested.
        Returns:
        The cardinal compass point indicating the absolute direction of the given flow end.
        Throws:
        java.lang.NullPointerException - if the given flow and/or end is null.
        See Also:
        CompassPoint.NORTH, CompassPoint.EAST, CompassPoint.SOUTH, CompassPoint.WEST
      • getOrientation

        public static Orientation getOrientation​(java.util.Locale locale)
        Retrieves the default orientation for a particular locale. This method currently supports the following locales:
        Arabic (ar)
        Right-to-left, top-to-bottom.
        Farsi (fa)
        Right-to-left, top-to-bottom.
        Hebrew (he, iw)
        Right-to-left, top-to-bottom.
        Urdu (ur)
        Right-to-left, top-to-bottom.
        All other languages will be assumed left-to-right, top-to-bottom.
        Parameters:
        locale - The locale for which an orientation should be returned.
        Returns:
        The default orientation for the given locale, or LEFT_TO_RIGHT_TOP_TO_BOTTOM by default.
      • equals

        public boolean equals​(java.lang.Object object)
        @return true if the given object is another orientation with the same line and page directions.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object