01: /*
02: * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
03: *
04: * The program is provided "as is" without any warranty express or
05: * implied, including the warranty of non-infringement and the implied
06: * warranties of merchantibility and fitness for a particular purpose.
07: * IBM will not be liable for any damages suffered by you as a result
08: * of using the Program. In no event will IBM be liable for any
09: * special, indirect or consequential damages or lost profits even if
10: * IBM has been advised of the possibility of their occurrence. IBM
11: * will not be liable for any third party claims against you.
12: */
13: package com.ibm.richtext.uiimpl;
14:
15: import java.awt.Color;
16:
17: import com.ibm.richtext.uiimpl.resources.FrameResources;
18:
19: import com.ibm.richtext.styledtext.MConstText;
20: import com.ibm.richtext.styledtext.StyledText;
21: import com.ibm.richtext.styledtext.StyleModifier;
22:
23: import com.ibm.richtext.textlayout.attributes.AttributeMap;
24: import com.ibm.richtext.textlayout.attributes.TextAttribute;
25:
26: public final class AboutText {
27:
28: static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
29: private static final Color[] COLORS = { Color.red, Color.blue,
30: Color.white, Color.green };
31:
32: public static MConstText getAboutText() {
33:
34: String text = ResourceUtils
35: .getResourceString(FrameResources.ABOUT_TEXT);
36: StyledText styledText = new StyledText(text,
37: AttributeMap.EMPTY_ATTRIBUTE_MAP);
38:
39: int length = styledText.length();
40: int i = 0;
41:
42: for (int paragraphStart = 0, paragraphLimit; paragraphStart < length; paragraphStart = paragraphLimit) {
43:
44: paragraphLimit = styledText.paragraphLimit(paragraphStart);
45: StyleModifier modifier = StyleModifier.createAddModifier(
46: TextAttribute.FOREGROUND, COLORS[(i++)
47: % COLORS.length]);
48: styledText.modifyCharacterStyles(paragraphStart,
49: paragraphLimit, modifier);
50: }
51:
52: StyleModifier modifier = StyleModifier.createAddModifier(
53: TextAttribute.LINE_FLUSH, TextAttribute.FLUSH_CENTER);
54:
55: styledText.modifyParagraphStyles(0, text.length(), modifier);
56:
57: return styledText;
58: }
59: }
|