Line | |
---|
1 | package org.expeditee.agents;
|
---|
2 |
|
---|
3 | import java.util.Collection;
|
---|
4 |
|
---|
5 | import org.expeditee.gui.Frame;
|
---|
6 | import org.expeditee.items.Text;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * A simple formatting agent that aligns the Y values.
|
---|
10 | *
|
---|
11 | * @author Mike
|
---|
12 | *
|
---|
13 | */
|
---|
14 | public class HFormat extends Format {
|
---|
15 |
|
---|
16 | public HFormat() {
|
---|
17 | super();
|
---|
18 | }
|
---|
19 |
|
---|
20 | @Override
|
---|
21 | public Frame process(Frame start) {
|
---|
22 | Collection<Text> itemsToFormat = getItemsToFormat(start);
|
---|
23 |
|
---|
24 | if(itemsToFormat.size() == 0)
|
---|
25 | return null;
|
---|
26 |
|
---|
27 | float anchorY = 0F;
|
---|
28 | float yThreshold = 0F;
|
---|
29 |
|
---|
30 | for(Text t: itemsToFormat){
|
---|
31 | if(t.getY() > yThreshold + anchorY){
|
---|
32 | anchorY = t.getY();
|
---|
33 | yThreshold = t.getSize();
|
---|
34 | }else{
|
---|
35 | t.setY(anchorY);
|
---|
36 | }
|
---|
37 | }
|
---|
38 |
|
---|
39 |
|
---|
40 | return null;
|
---|
41 | }
|
---|
42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.