1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2000, 2010 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.draw2d.text;
|
12
|
|
13
|
import java.util.List;
|
14
|
|
15
|
/**
|
16
|
* @author hudsonr
|
17
|
* @since 2.1
|
18
|
*/
|
19
|
public abstract class TextLayout extends FlowFigureLayout {
|
20
|
|
21
|
/**
|
22
|
* Creates a new TextLayout with the given TextFlow
|
23
|
*
|
24
|
* @param flow
|
25
|
* The TextFlow
|
26
|
*/
|
27
|
public TextLayout(TextFlow flow) {
|
28
|
super(flow);
|
29
|
}
|
30
|
|
31
|
/**
|
32
|
* Reuses an existing <code>TextFragmentBox</code>, or creates a new one.
|
33
|
*
|
34
|
* @param i
|
35
|
* the index
|
36
|
* @param fragments
|
37
|
* the original list of fragments
|
38
|
* @return a TextFragmentBox
|
39
|
*/
|
40
|
protected TextFragmentBox getFragment(int i, List fragments) {
|
41
|
if (fragments.size() > i)
|
42
|
return (TextFragmentBox) fragments.get(i);
|
43
|
TextFragmentBox box = new TextFragmentBox((TextFlow) getFlowFigure());
|
44
|
fragments.add(box);
|
45
|
return box;
|
46
|
}
|
47
|
|
48
|
}
|