2 * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
\r
4 * The program is provided "as is" without any warranty express or
\r
5 * implied, including the warranty of non-infringement and the implied
\r
6 * warranties of merchantibility and fitness for a particular purpose.
\r
7 * IBM will not be liable for any damages suffered by you as a result
\r
8 * of using the Program. In no event will IBM be liable for any
\r
9 * special, indirect or consequential damages or lost profits even if
\r
10 * IBM has been advised of the possibility of their occurrence. IBM
\r
11 * will not be liable for any third party claims against you.
\r
13 package com.ibm.richtext.styledtext;
\r
16 * This interface represents a sequence of TabStops, ordered by position.
\r
18 * TabStop in the ruler can be obtained with the <code>firstTab</code>
\r
19 * method; subsequent TabStops are obtained with the <code>nextTab</code>
\r
22 * If a TabStop with type <code>TabStop.kAuto</code> is returned, all tabs
\r
23 * after that TabStop will also have type <code>TabStop.kAuto</code>, and
\r
24 * their positions will be multiples of <code>autoSpacing</code>.
\r
27 public abstract class MTabRuler
\r
29 static final String COPYRIGHT =
\r
30 "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
\r
32 * Return first tab in the ruler. If an autoTab, it is at position zero, and
\r
33 * all subsequent tabs will be autotabs at autoSpacing intervals.
\r
35 public abstract TabStop firstTab();
\r
38 * Return the first tab in the ruler with fPosition > position. If it is an
\r
39 * autotab, it is at an increment of autoSpacing, and all subsequent tabs will be
\r
40 * autotabs at autoSpacing intervals.
\r
42 public abstract TabStop nextTab(int position);
\r
45 * Return the interval for autotabs.
\r
47 public abstract int autoSpacing();
\r
50 * Compute the hashCode for this ruler. The hashCode is the
\r
51 * hashCode of the first tab multiplied by the autoSpacing
\r
54 public final int hashCode() {
\r
56 return firstTab().hashCode() * autoSpacing();
\r
60 * Return true if this tab ruler contains the given tab.
\r
61 * @param tabToTest the tab to search for
\r
62 * @return true if this tab ruler contains <code>tabToTest</code>
\r
64 public boolean containsTab(TabStop tabToTest) {
\r
66 for (TabStop tab = firstTab();
\r
67 tab.getType() != TabStop.kAuto;
\r
68 tab = nextTab(tab.getPosition())) {
\r
69 if (tab.getPosition() >= tabToTest.getPosition()) {
\r
70 return tabToTest.equals(tab);
\r
78 * Return a tab ruler identical to this ruler, except with the
\r
79 * given tab added. This ruler is not modified.
\r
80 * @param tabToAdd the tab to add to the new tab ruler
\r
81 * @return an MTabRuler resulting from this operation
\r
83 public MTabRuler addTab(TabStop tabToAdd) {
\r
85 return StandardTabRuler.addTabToRuler(this, tabToAdd);
\r
89 * Return a tab ruler identical to the given ruler, except with the
\r
90 * tab at the given position removed. This ruler is not modified.
\r
91 * @param position the position of the tab to remove from the new tab ruler
\r
92 * @return an MTabRuler resulting from this operation
\r
94 public MTabRuler removeTab(int position) {
\r
96 return StandardTabRuler.removeTabFromRuler(this, position);
\r
100 * Return a tab ruler identical to this ruler, except with the
\r
101 * tab at position <code>fromPosition</code> moved to position
\r
102 * <code>toPosition</code>. This ruler is not modified.
\r
103 * @param fromPosition the position of the tab to move
\r
104 * @param toPosition the new position of the tab
\r
105 * @return an MTabRuler resulting from this operation
\r
107 public MTabRuler moveTab(int fromPosition, int toPosition) {
\r
109 return StandardTabRuler.moveTabOnRuler(this, fromPosition, toPosition);
\r