< prev index next >

modules/graphics/src/main/java/com/sun/javafx/scene/text/TextLayout.java

Print this page


   1 /*
   2  * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  58 
  59     public static final int DIRECTION_LTR          = 1 << 10;
  60     public static final int DIRECTION_RTL          = 1 << 11;
  61     public static final int DIRECTION_DEFAULT_LTR  = 1 << 12;
  62     public static final int DIRECTION_DEFAULT_RTL  = 1 << 13;
  63 
  64     static final int DIRECTION_MASK = DIRECTION_LTR | DIRECTION_RTL |
  65                                       DIRECTION_DEFAULT_LTR |
  66                                       DIRECTION_DEFAULT_RTL;
  67 
  68     public static final int BOUNDS_CENTER       = 1 << 14;
  69     public static final int BOUNDS_MASK = BOUNDS_CENTER;
  70 
  71     public static final int TYPE_TEXT           = 1 << 0;
  72     public static final int TYPE_UNDERLINE      = 1 << 1;
  73     public static final int TYPE_STRIKETHROUGH  = 1 << 2;
  74     public static final int TYPE_BASELINE       = 1 << 3;
  75     public static final int TYPE_TOP            = 1 << 4;
  76     public static final int TYPE_BEARINGS       = 1 << 5;
  77 
















  78     /**
  79      * Sets the content for the TextLayout. Supports multiple spans (rich text).
  80      *
  81      * @return returns true is the call modifies the layout internal state.
  82      */
  83     public boolean setContent(TextSpan[] spans);
  84 
  85     /**
  86      * Sets the content for the TextLayout. Shorthand for single span text
  87      * (no rich text).
  88      *
  89      * @return returns true is the call modifies the layout internal state.
  90      */
  91     public boolean setContent(String string, Object font);
  92 
  93     /**
  94      * Sets the alignment for the TextLayout.
  95      *
  96      * @return returns true is the call modifies the layout internal state.
  97      */


 155     public TextLine[] getLines();
 156 
 157     /**
 158      * Returns the GlyphList of text layout.
 159      * The runs are returned order visually (rendering order), starting
 160      * from the first line.
 161      *
 162      * @return the runs
 163      */
 164     public GlyphList[] getRuns();
 165 
 166     /**
 167      * Returns the shape of the entire text layout relative to the baseline
 168      * of the first line.
 169      *
 170      * @param type the type of the shapes to include
 171      * @return the shape
 172      */
 173     public Shape getShape(int type, TextSpan filter);
 174 
 175     public HitInfo getHitInfo(float x, float y);

 176     public PathElement[] getCaretShape(int offset, boolean isLeading,
 177                                        float x, float y);
 178     public PathElement[] getRange(int start, int end, int type,
 179                                   float x, float y);
 180 }
   1 /*
   2  * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  58 
  59     public static final int DIRECTION_LTR          = 1 << 10;
  60     public static final int DIRECTION_RTL          = 1 << 11;
  61     public static final int DIRECTION_DEFAULT_LTR  = 1 << 12;
  62     public static final int DIRECTION_DEFAULT_RTL  = 1 << 13;
  63 
  64     static final int DIRECTION_MASK = DIRECTION_LTR | DIRECTION_RTL |
  65                                       DIRECTION_DEFAULT_LTR |
  66                                       DIRECTION_DEFAULT_RTL;
  67 
  68     public static final int BOUNDS_CENTER       = 1 << 14;
  69     public static final int BOUNDS_MASK = BOUNDS_CENTER;
  70 
  71     public static final int TYPE_TEXT           = 1 << 0;
  72     public static final int TYPE_UNDERLINE      = 1 << 1;
  73     public static final int TYPE_STRIKETHROUGH  = 1 << 2;
  74     public static final int TYPE_BASELINE       = 1 << 3;
  75     public static final int TYPE_TOP            = 1 << 4;
  76     public static final int TYPE_BEARINGS       = 1 << 5;
  77 
  78     public static class Hit {
  79         int charIndex;
  80         int insertionIndex;
  81         boolean leading;
  82 
  83         public Hit(int charIndex, int insertionIndex, boolean leading) {
  84             this.charIndex = charIndex;
  85             this.insertionIndex = insertionIndex;
  86             this.leading = leading;
  87         }
  88 
  89         public int getCharIndex() { return charIndex; }
  90         public int getInsertionIndex() { return insertionIndex; }
  91         public boolean isLeading() { return leading; }
  92     }
  93 
  94     /**
  95      * Sets the content for the TextLayout. Supports multiple spans (rich text).
  96      *
  97      * @return returns true is the call modifies the layout internal state.
  98      */
  99     public boolean setContent(TextSpan[] spans);
 100 
 101     /**
 102      * Sets the content for the TextLayout. Shorthand for single span text
 103      * (no rich text).
 104      *
 105      * @return returns true is the call modifies the layout internal state.
 106      */
 107     public boolean setContent(String string, Object font);
 108 
 109     /**
 110      * Sets the alignment for the TextLayout.
 111      *
 112      * @return returns true is the call modifies the layout internal state.
 113      */


 171     public TextLine[] getLines();
 172 
 173     /**
 174      * Returns the GlyphList of text layout.
 175      * The runs are returned order visually (rendering order), starting
 176      * from the first line.
 177      *
 178      * @return the runs
 179      */
 180     public GlyphList[] getRuns();
 181 
 182     /**
 183      * Returns the shape of the entire text layout relative to the baseline
 184      * of the first line.
 185      *
 186      * @param type the type of the shapes to include
 187      * @return the shape
 188      */
 189     public Shape getShape(int type, TextSpan filter);
 190 
 191     public Hit getHitInfo(float x, float y);
 192 
 193     public PathElement[] getCaretShape(int offset, boolean isLeading,
 194                                        float x, float y);
 195     public PathElement[] getRange(int start, int end, int type,
 196                                   float x, float y);
 197 }
< prev index next >