KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > projection > Segment


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.jface.text.projection;
12
13
14 import org.eclipse.jface.text.Position;
15
16
17 /**
18  * Internal class. Do not use. Only public for testing purposes.
19  * <p>
20  * A segment is the image of a master document fragment in a projection
21  * document.
22  *
23  * @since 3.0
24  */

25 public class Segment extends Position {
26
27     /** The corresponding fragment for this segment. */
28     public Fragment fragment;
29     /** A flag indicating that the segment updater should stretch this segment when a change happens at its boundaries. */
30     public boolean isMarkedForStretch;
31     /** A flag indicating that the segment updater should shift this segment when a change happens at its boundaries. */
32     public boolean isMarkedForShift;
33
34     /**
35      * Creates a new segment covering the given range.
36      *
37      * @param offset the offset of the segment
38      * @param length the length of the segment
39      */

40     public Segment(int offset, int length) {
41         super(offset, length);
42     }
43
44     /**
45      * Sets the stretching flag.
46      */

47     public void markForStretch() {
48         isMarkedForStretch= true;
49     }
50
51     /**
52      * Returns <code>true</code> if the stretching flag is set, <code>false</code> otherwise.
53      * @return <code>true</code> if the stretching flag is set, <code>false</code> otherwise
54      */

55     public boolean isMarkedForStretch() {
56         return isMarkedForStretch;
57     }
58
59     /**
60      * Sets the shifting flag.
61      */

62     public void markForShift() {
63         isMarkedForShift= true;
64     }
65
66     /**
67      * Returns <code>true</code> if the shifting flag is set, <code>false</code> otherwise.
68      * @return <code>true</code> if the shifting flag is set, <code>false</code> otherwise
69      */

70     public boolean isMarkedForShift() {
71         return isMarkedForShift;
72     }
73
74     /**
75      * Clears the shifting and the stretching flag.
76      */

77     public void clearMark() {
78         isMarkedForStretch= false;
79         isMarkedForShift= false;
80     }
81 }
82
Popular Tags