< prev index next >

src/java.desktop/share/classes/javax/swing/text/TabStop.java

Print this page




  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
  23  * questions.
  24  */
  25 package javax.swing.text;
  26 
  27 import java.io.Serializable;
  28 
  29 /**
  30  * This class encapsulates a single tab stop (basically as tab stops
  31  * are thought of by RTF). A tab stop is at a specified distance from the
  32  * left margin, aligns text in a specified way, and has a specified leader.
  33  * TabStops are immutable, and usually contained in TabSets.
  34  * <p>
  35  * <strong>Warning:</strong>
  36  * Serialized objects of this class will not be compatible with
  37  * future Swing releases. The current serialization support is
  38  * appropriate for short term storage or RMI between applications running
  39  * the same version of Swing.  As of 1.4, support for long term storage
  40  * of all JavaBeans&trade;
  41  * has been added to the <code>java.beans</code> package.
  42  * Please see {@link java.beans.XMLEncoder}.
  43  *
  44  */
  45 @SuppressWarnings("serial") // Same-version serialization only
  46 public class TabStop implements Serializable {
  47 
  48     /** Character following tab is positioned at location. */
  49     public static final int ALIGN_LEFT    = 0;
  50     /** Characters following tab are positioned such that all following
  51      * characters up to next tab/newline end at location. */
  52     public static final int ALIGN_RIGHT   = 1;
  53     /** Characters following tab are positioned such that all following
  54      * characters up to next tab/newline are centered around the tabs
  55      * location. */
  56     public static final int ALIGN_CENTER  = 2;
  57     /** Characters following tab are aligned such that next
  58      * decimal/tab/newline is at the tab location, very similar to
  59      * RIGHT_TAB, just includes decimal as additional character to look for.
  60      */
  61     public static final int ALIGN_DECIMAL = 4;


  70     /** Lead none */
  71     public static final int LEAD_NONE      = 0;
  72     /** Lead dots */
  73     public static final int LEAD_DOTS      = 1;
  74     /** Lead hyphens */
  75     public static final int LEAD_HYPHENS   = 2;
  76     /** Lead underline */
  77     public static final int LEAD_UNDERLINE = 3;
  78     /** Lead thickline */
  79     public static final int LEAD_THICKLINE = 4;
  80     /** Lead equals */
  81     public static final int LEAD_EQUALS    = 5;
  82 
  83     /** Tab type. */
  84     private int alignment;
  85     /** Location, from the left margin, that tab is at. */
  86     private float position;
  87     private int leader;
  88 
  89     /**
  90      * Creates a tab at position <code>pos</code> with a default alignment
  91      * and default leader.
  92      * @param pos position of the tab
  93      */
  94     public TabStop(float pos) {
  95         this(pos, ALIGN_LEFT, LEAD_NONE);
  96     }
  97 
  98     /**
  99      * Creates a tab with the specified position <code>pos</code>,
 100      * alignment <code>align</code> and leader <code>leader</code>.
 101      * @param pos position of the tab
 102      * @param align alignment of the tab
 103      * @param leader leader of the tab
 104      */
 105     public TabStop(float pos, int align, int leader) {
 106         alignment = align;
 107         this.leader = leader;
 108         position = pos;
 109     }
 110 
 111     /**
 112      * Returns the position, as a float, of the tab.
 113      * @return the position of the tab
 114      */
 115     public float getPosition() {
 116         return position;
 117     }
 118 
 119     /**
 120      * Returns the alignment, as an integer, of the tab.




  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
  23  * questions.
  24  */
  25 package javax.swing.text;
  26 
  27 import java.io.Serializable;
  28 
  29 /**
  30  * This class encapsulates a single tab stop (basically as tab stops
  31  * are thought of by RTF). A tab stop is at a specified distance from the
  32  * left margin, aligns text in a specified way, and has a specified leader.
  33  * TabStops are immutable, and usually contained in TabSets.
  34  * <p>
  35  * <strong>Warning:</strong>
  36  * Serialized objects of this class will not be compatible with
  37  * future Swing releases. The current serialization support is
  38  * appropriate for short term storage or RMI between applications running
  39  * the same version of Swing.  As of 1.4, support for long term storage
  40  * of all JavaBeans&trade;
  41  * has been added to the {@code java.beans} package.
  42  * Please see {@link java.beans.XMLEncoder}.
  43  *
  44  */
  45 @SuppressWarnings("serial") // Same-version serialization only
  46 public class TabStop implements Serializable {
  47 
  48     /** Character following tab is positioned at location. */
  49     public static final int ALIGN_LEFT    = 0;
  50     /** Characters following tab are positioned such that all following
  51      * characters up to next tab/newline end at location. */
  52     public static final int ALIGN_RIGHT   = 1;
  53     /** Characters following tab are positioned such that all following
  54      * characters up to next tab/newline are centered around the tabs
  55      * location. */
  56     public static final int ALIGN_CENTER  = 2;
  57     /** Characters following tab are aligned such that next
  58      * decimal/tab/newline is at the tab location, very similar to
  59      * RIGHT_TAB, just includes decimal as additional character to look for.
  60      */
  61     public static final int ALIGN_DECIMAL = 4;


  70     /** Lead none */
  71     public static final int LEAD_NONE      = 0;
  72     /** Lead dots */
  73     public static final int LEAD_DOTS      = 1;
  74     /** Lead hyphens */
  75     public static final int LEAD_HYPHENS   = 2;
  76     /** Lead underline */
  77     public static final int LEAD_UNDERLINE = 3;
  78     /** Lead thickline */
  79     public static final int LEAD_THICKLINE = 4;
  80     /** Lead equals */
  81     public static final int LEAD_EQUALS    = 5;
  82 
  83     /** Tab type. */
  84     private int alignment;
  85     /** Location, from the left margin, that tab is at. */
  86     private float position;
  87     private int leader;
  88 
  89     /**
  90      * Creates a tab at position {@code pos} with a default alignment
  91      * and default leader.
  92      * @param pos position of the tab
  93      */
  94     public TabStop(float pos) {
  95         this(pos, ALIGN_LEFT, LEAD_NONE);
  96     }
  97 
  98     /**
  99      * Creates a tab with the specified position {@code pos},
 100      * alignment {@code align} and leader {@code leader}.
 101      * @param pos position of the tab
 102      * @param align alignment of the tab
 103      * @param leader leader of the tab
 104      */
 105     public TabStop(float pos, int align, int leader) {
 106         alignment = align;
 107         this.leader = leader;
 108         position = pos;
 109     }
 110 
 111     /**
 112      * Returns the position, as a float, of the tab.
 113      * @return the position of the tab
 114      */
 115     public float getPosition() {
 116         return position;
 117     }
 118 
 119     /**
 120      * Returns the alignment, as an integer, of the tab.


< prev index next >