01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jface.text.projection;
11:
12: import org.eclipse.jface.text.Position;
13:
14: /**
15: * Internal class. Do not use. Only public for testing purposes.
16: * <p>
17: * A segment is the image of a master document fragment in a projection
18: * document.
19: *
20: * @since 3.0
21: */
22: public class Segment extends Position {
23:
24: /** The corresponding fragment for this segment. */
25: public Fragment fragment;
26: /** A flag indicating that the segment updater should stretch this segment when a change happens at its boundaries. */
27: public boolean isMarkedForStretch;
28: /** A flag indicating that the segment updater should shift this segment when a change happens at its boundaries. */
29: public boolean isMarkedForShift;
30:
31: /**
32: * Creates a new segment covering the given range.
33: *
34: * @param offset the offset of the segment
35: * @param length the length of the segment
36: */
37: public Segment(int offset, int length) {
38: super (offset, length);
39: }
40:
41: /**
42: * Sets the stretching flag.
43: */
44: public void markForStretch() {
45: isMarkedForStretch = true;
46: }
47:
48: /**
49: * Returns <code>true</code> if the stretching flag is set, <code>false</code> otherwise.
50: * @return <code>true</code> if the stretching flag is set, <code>false</code> otherwise
51: */
52: public boolean isMarkedForStretch() {
53: return isMarkedForStretch;
54: }
55:
56: /**
57: * Sets the shifting flag.
58: */
59: public void markForShift() {
60: isMarkedForShift = true;
61: }
62:
63: /**
64: * Returns <code>true</code> if the shifting flag is set, <code>false</code> otherwise.
65: * @return <code>true</code> if the shifting flag is set, <code>false</code> otherwise
66: */
67: public boolean isMarkedForShift() {
68: return isMarkedForShift;
69: }
70:
71: /**
72: * Clears the shifting and the stretching flag.
73: */
74: public void clearMark() {
75: isMarkedForStretch = false;
76: isMarkedForShift = false;
77: }
78: }
|