KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > custom > BidiSegmentEvent


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.swt.custom;
12
13
14 import org.eclipse.swt.events.*;
15
16 /**
17  * This event is sent to BidiSegmentListeners when a line is to
18  * be measured or rendered in a bidi locale. The segments field is
19  * used to specify text ranges in the line that should be treated as
20  * separate segments for bidi reordering. Each segment will be reordered
21  * and rendered separately.
22  * <p>
23  * The elements in the segments field specify the start offset of
24  * a segment relative to the start of the line. They must follow
25  * the following rules:
26  * <ul>
27  * <li>first element must be 0
28  * <li>elements must be in ascending order and must not have duplicates
29  * <li>elements must not exceed the line length
30  * </ul>
31  * In addition, the last element may be set to the end of the line
32  * but this is not required.
33  *
34  * The segments field may be left null if the entire line should
35  * be reordered as is.
36  * </p>
37  * A BidiSegmentListener may be used when adjacent segments of
38  * right-to-left text should not be reordered relative to each other.
39  * For example, within a Java editor, you may wish multiple
40  * right-to-left string literals to be reordered differently than the
41  * bidi algorithm specifies.
42  *
43  * Example:
44  * <pre>
45  * stored line = "R1R2R3" + "R4R5R6"
46  * R1 to R6 are right-to-left characters. The quotation marks
47  * are part of the line text. The line is 13 characters long.
48  *
49  * segments = null:
50  * entire line will be reordered and thus the two R2L segments
51  * swapped (as per the bidi algorithm).
52  * visual line (rendered on screen) = "R6R5R4" + "R3R2R1"
53  *
54  * segments = [0, 5, 8]
55  * "R1R2R3" will be reordered, followed by [blank]+[blank] and
56  * "R4R5R6".
57  * visual line = "R3R2R1" + "R6R5R4"
58  * </pre>
59  */

60 public class BidiSegmentEvent extends TypedEvent {
61     
62     /**
63      * line start offset
64      */

65     public int lineOffset;
66     
67     /**
68      * line text
69      */

70     public String JavaDoc lineText;
71     
72     /**
73      * bidi segments, see above
74      */

75     public int[] segments;
76         
77     static final long serialVersionUID = 3257846571587547957L;
78
79 BidiSegmentEvent(StyledTextEvent e) {
80     super(e);
81     lineOffset = e.detail;
82     lineText = e.text;
83 }
84 }
85
Popular Tags