< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 1997, 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


  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;

  62     public static final int ALIGN_BAR     = 5;
  63 
  64     /* Bar tabs (whatever they are) are actually a separate kind of tab
  65        in the RTF spec. However, being a bar tab and having alignment
  66        properties are mutually exclusive, so the reader treats barness
  67        as being a kind of alignment. */
  68 

  69     public static final int LEAD_NONE      = 0;

  70     public static final int LEAD_DOTS      = 1;

  71     public static final int LEAD_HYPHENS   = 2;

  72     public static final int LEAD_UNDERLINE = 3;

  73     public static final int LEAD_THICKLINE = 4;

  74     public static final int LEAD_EQUALS    = 5;
  75 
  76     /** Tab type. */
  77     private int alignment;
  78     /** Location, from the left margin, that tab is at. */
  79     private float position;
  80     private int leader;
  81 
  82     /**
  83      * Creates a tab at position <code>pos</code> with a default alignment
  84      * and default leader.

  85      */
  86     public TabStop(float pos) {
  87         this(pos, ALIGN_LEFT, LEAD_NONE);
  88     }
  89 
  90     /**
  91      * Creates a tab with the specified position <code>pos</code>,
  92      * alignment <code>align</code> and leader <code>leader</code>.



  93      */
  94     public TabStop(float pos, int align, int leader) {
  95         alignment = align;
  96         this.leader = leader;
  97         position = pos;
  98     }
  99 
 100     /**
 101      * Returns the position, as a float, of the tab.
 102      * @return the position of the tab
 103      */
 104     public float getPosition() {
 105         return position;
 106     }
 107 
 108     /**
 109      * Returns the alignment, as an integer, of the tab.
 110      * @return the alignment of the tab
 111      */
 112     public int getAlignment() {


   1 /*
   2  * Copyright (c) 1997, 2015, 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


  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;
  62     /** Align bar */
  63     public static final int ALIGN_BAR     = 5;
  64 
  65     /* Bar tabs (whatever they are) are actually a separate kind of tab
  66        in the RTF spec. However, being a bar tab and having alignment
  67        properties are mutually exclusive, so the reader treats barness
  68        as being a kind of alignment. */
  69 
  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.
 121      * @return the alignment of the tab
 122      */
 123     public int getAlignment() {


< prev index next >