From: Peter Bernard West Date: Sun, 2 May 2004 02:56:15 +0000 (+0000) Subject: Added isHorizontal and isLeftToRight methods, mimicking methods X-Git-Tag: Defoe_export~208 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9d053440c9abb44c32862faf116dbb42e394b4e4;p=xmlgraphics-fop.git Added isHorizontal and isLeftToRight methods, mimicking methods of the same name in java.awt.ComponentOrientation git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197546 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/properties/WritingMode.java b/src/java/org/apache/fop/fo/properties/WritingMode.java index 43ce4ab50..b2670ec1b 100644 --- a/src/java/org/apache/fop/fo/properties/WritingMode.java +++ b/src/java/org/apache/fop/fo/properties/WritingMode.java @@ -314,5 +314,53 @@ public class WritingMode extends Property { return relAbsMaps[writingMode][relativeEdge]; } + /** Map of isHorizontal values for writing modes */ + private static final boolean[] horizontal = { + false + ,true // lr_tb + ,true // rl_tb + ,false // tb_rl + }; + + /** + * Mimics isHorizontal method from + * java.awt.ComponentOrientation. + * @param writingMode + * @return + * @throws PropertyException if the writing mode is invalid + */ + public static boolean isHorizontal(int writingMode) + throws PropertyException { + if (writingMode <= 0 || writingMode > MAX_WRITING_MODE) { + throw new PropertyException( + "Writing mode out of range:" + writingMode); + } + return horizontal[writingMode]; + } + + /** Map of isLeftToRight values for writing modes */ + private static final boolean[] leftToRight = { + false + ,true // lr_tb + ,false // rl_tb + ,false // tb_rl + }; + + /** + * Mimics isLeftToRight method from + * java.awt.ComponentOrientation. + * @param writingMode + * @return + * @throws PropertyException is the writing mode is invalid + */ + public static boolean isLeftToRight(int writingMode) + throws PropertyException { + if (writingMode <= 0 || writingMode > MAX_WRITING_MODE) { + throw new PropertyException( + "Writing mode out of range:" + writingMode); + } + return leftToRight[writingMode]; + } + }