src/java.desktop/share/classes/java/awt/ComponentOrientation.java

Print this page




 137      * HorizontalLines: Do items run left-to-right?<br>
 138      * Vertical Lines:  Do lines run left-to-right?<br>
 139      * This will return true for horizontal, left-to-right writing
 140      * systems such as Roman.
 141      *
 142      * @return {@code true} if this orientation is left-to-right
 143      */
 144     public boolean isLeftToRight() {
 145         return (orientation & LTR_BIT) != 0;
 146     }
 147 
 148     /**
 149      * Returns the orientation that is appropriate for the given locale.
 150      *
 151      * @param locale the specified locale
 152      * @return the orientation for the locale
 153      */
 154     public static ComponentOrientation getOrientation(Locale locale) {
 155         // A more flexible implementation would consult a ResourceBundle
 156         // to find the appropriate orientation.  Until pluggable locales
 157         // are introduced however, the flexiblity isn't really needed.
 158         // So we choose efficiency instead.
 159         String lang = locale.getLanguage();
 160         if( "iw".equals(lang) || "ar".equals(lang)
 161             || "fa".equals(lang) || "ur".equals(lang) )
 162         {
 163             return RIGHT_TO_LEFT;
 164         } else {
 165             return LEFT_TO_RIGHT;
 166         }
 167     }
 168 
 169     /**
 170      * Returns the orientation appropriate for the given ResourceBundle's
 171      * localization.  Three approaches are tried, in the following order:
 172      * <ol>
 173      * <li>Retrieve a ComponentOrientation object from the ResourceBundle
 174      *      using the string "Orientation" as the key.
 175      * <li>Use the ResourceBundle.getLocale to determine the bundle's
 176      *      locale, then return the orientation for that locale.
 177      * <li>Return the default locale's orientation.




 137      * HorizontalLines: Do items run left-to-right?<br>
 138      * Vertical Lines:  Do lines run left-to-right?<br>
 139      * This will return true for horizontal, left-to-right writing
 140      * systems such as Roman.
 141      *
 142      * @return {@code true} if this orientation is left-to-right
 143      */
 144     public boolean isLeftToRight() {
 145         return (orientation & LTR_BIT) != 0;
 146     }
 147 
 148     /**
 149      * Returns the orientation that is appropriate for the given locale.
 150      *
 151      * @param locale the specified locale
 152      * @return the orientation for the locale
 153      */
 154     public static ComponentOrientation getOrientation(Locale locale) {
 155         // A more flexible implementation would consult a ResourceBundle
 156         // to find the appropriate orientation.  Until pluggable locales
 157         // are introduced however, the flexibility isn't really needed.
 158         // So we choose efficiency instead.
 159         String lang = locale.getLanguage();
 160         if( "iw".equals(lang) || "ar".equals(lang)
 161             || "fa".equals(lang) || "ur".equals(lang) )
 162         {
 163             return RIGHT_TO_LEFT;
 164         } else {
 165             return LEFT_TO_RIGHT;
 166         }
 167     }
 168 
 169     /**
 170      * Returns the orientation appropriate for the given ResourceBundle's
 171      * localization.  Three approaches are tried, in the following order:
 172      * <ol>
 173      * <li>Retrieve a ComponentOrientation object from the ResourceBundle
 174      *      using the string "Orientation" as the key.
 175      * <li>Use the ResourceBundle.getLocale to determine the bundle's
 176      *      locale, then return the orientation for that locale.
 177      * <li>Return the default locale's orientation.