2 * (C) Copyright IBM Corp. 1998-2007. 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.swingui;
\r
15 import java.awt.Color;
\r
16 import java.awt.Dimension;
\r
17 import java.awt.Graphics;
\r
19 import javax.swing.JComponent;
\r
21 import com.ibm.richtext.textpanel.MTextPanel;
\r
22 import com.ibm.richtext.styledtext.MTabRuler;
\r
24 import com.ibm.richtext.uiimpl.TabRulerImpl;
\r
25 import com.ibm.richtext.awtui.MTabRulerComponent;
\r
28 * JTabRuler is an implementation of MTabRulerComponent in a Swing component.
\r
30 public final class JTabRuler extends JComponent implements MTabRulerComponent {
\r
35 private static final long serialVersionUID = 8547581956295504028L;
\r
36 //static final String COPYRIGHT =
\r
37 // "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
\r
38 private TabRulerImpl fImpl;
\r
41 * Create a new TabRuler.
\r
42 * @param baseline the y-coordinate of the ruler's baseline
\r
43 * @param origin the x-coordinate in this Component where
\r
44 * the left margin appears
\r
45 * @param textPanel the MTextPanel to listen to. This TabRuler
\r
46 * will reflect the MTextPanel's paragraph styles, and update
\r
47 * the paragraph styles when manipulated.
\r
49 public JTabRuler(int baseline, int origin, MTextPanel textPanel) {
\r
51 fImpl = new TabRulerImpl(baseline, origin, textPanel, this);
\r
55 * Listen to the given MTextPanel and reflect its changes,
\r
56 * and update its paragraph styles when TabRuler is
\r
58 * @param textPanel the MTextPanel to listen to
\r
60 public void listenToTextPanel(MTextPanel textPanel) {
\r
62 fImpl.listenToTextPanel(textPanel);
\r
66 * Return the background color of this TabRuler.
\r
67 * @return the background color of this TabRuler
\r
69 public Color getBackColor() {
\r
71 return fImpl.getBackColor();
\r
75 * Set the background color of this TabRuler.
\r
76 * @param backColor the new background color of this TabRuler
\r
78 public void setBackColor(Color backColor) {
\r
80 fImpl.setBackColor(backColor);
\r
84 * Return the MTabRuler represented by this TabRuler.
\r
85 * @return the MTabRuler represented by this TabRuler
\r
87 public MTabRuler getRuler() {
\r
89 return fImpl.getRuler();
\r
93 * Return the leading margin of this TabRuler.
\r
94 * @return the leading margin of this TabRuler
\r
96 public int getLeadingMargin() {
\r
98 return fImpl.getLeadingMargin();
\r
102 * Return the first line indent of this TabRuler.
\r
103 * @return the first line indent of this TabRuler
\r
105 public int getFirstLineIndent() {
\r
107 return fImpl.getFirstLineIndent();
\r
111 * Return the trailing margin of this TabRuler.
\r
112 * @return the trailing margin of this TabRuler
\r
114 public final int getTrailingMargin() {
\r
116 return fImpl.getTrailingMargin();
\r
119 // The following are Component methods which need to be delegated to
\r
120 // the implementation:
\r
122 public void paint(Graphics g) {
\r
127 public Dimension getPreferredSize() {
\r
129 return fImpl.getPreferredSize();
\r
132 public Dimension getMinimumSize() {
\r
134 return fImpl.getMinimumSize();
\r