]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/richtext/swingui/JTabRuler.java
icu4jsrc
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / richtext / swingui / JTabRuler.java
1 /*\r
2  * (C) Copyright IBM Corp. 1998-2007.  All Rights Reserved.\r
3  *\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
12  */\r
13 package com.ibm.richtext.swingui;\r
14 \r
15 import java.awt.Color;\r
16 import java.awt.Dimension;\r
17 import java.awt.Graphics;\r
18 \r
19 import javax.swing.JComponent;\r
20 \r
21 import com.ibm.richtext.textpanel.MTextPanel;\r
22 import com.ibm.richtext.styledtext.MTabRuler;\r
23 \r
24 import com.ibm.richtext.uiimpl.TabRulerImpl;\r
25 import com.ibm.richtext.awtui.MTabRulerComponent;\r
26 \r
27 /**\r
28  * JTabRuler is an implementation of MTabRulerComponent in a Swing component.\r
29  */\r
30 public final class JTabRuler extends JComponent implements MTabRulerComponent {\r
31     \r
32     /**\r
33      * For serialization\r
34      */\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
39     \r
40     /**\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
48      */\r
49     public JTabRuler(int baseline, int origin, MTextPanel textPanel) {\r
50         \r
51         fImpl = new TabRulerImpl(baseline, origin, textPanel, this);\r
52     }\r
53     \r
54     /**\r
55      * Listen to the given MTextPanel and reflect its changes,\r
56      * and update its paragraph styles when TabRuler is\r
57      * manipulated.\r
58      * @param textPanel the MTextPanel to listen to\r
59      */\r
60     public void listenToTextPanel(MTextPanel textPanel) {\r
61 \r
62         fImpl.listenToTextPanel(textPanel);\r
63     }\r
64     \r
65     /**\r
66      * Return the background color of this TabRuler.\r
67      * @return the background color of this TabRuler\r
68      */\r
69     public Color getBackColor() {\r
70 \r
71         return fImpl.getBackColor();\r
72     }\r
73     \r
74     /**\r
75      * Set the background color of this TabRuler.\r
76      * @param backColor the new background color of this TabRuler\r
77      */\r
78     public void setBackColor(Color backColor) {\r
79 \r
80         fImpl.setBackColor(backColor);\r
81     }\r
82     \r
83     /**\r
84      * Return the MTabRuler represented by this TabRuler.\r
85      * @return the MTabRuler represented by this TabRuler\r
86      */\r
87     public MTabRuler getRuler() {\r
88         \r
89         return fImpl.getRuler();\r
90     }\r
91 \r
92     /**\r
93      * Return the leading margin of this TabRuler.\r
94      * @return the leading margin of this TabRuler\r
95      */\r
96     public int getLeadingMargin() {\r
97         \r
98         return fImpl.getLeadingMargin();\r
99     }\r
100 \r
101     /**\r
102      * Return the first line indent of this TabRuler.\r
103      * @return the first line indent of this TabRuler\r
104      */\r
105     public int getFirstLineIndent() {\r
106         \r
107         return fImpl.getFirstLineIndent();\r
108     }\r
109 \r
110     /**\r
111      * Return the trailing margin of this TabRuler.\r
112      * @return the trailing margin of this TabRuler\r
113      */\r
114     public final int getTrailingMargin() {\r
115         \r
116         return fImpl.getTrailingMargin();\r
117     }\r
118     \r
119     // The following are Component methods which need to be delegated to\r
120     // the implementation:\r
121     \r
122     public void paint(Graphics g) {\r
123         \r
124         fImpl.paint(g);\r
125     }\r
126     \r
127     public Dimension getPreferredSize() {\r
128         \r
129         return fImpl.getPreferredSize();\r
130     }\r
131 \r
132     public Dimension getMinimumSize() {\r
133         \r
134         return fImpl.getMinimumSize();\r
135     }\r
136 }\r