source: trunk/src/org/expeditee/agents/HFormat.java@ 636

Last change on this file since 636 was 427, checked in by ra33, 15 years ago
File size: 688 bytes
Line 
1package org.expeditee.agents;
2
3import java.util.Collection;
4
5import org.expeditee.gui.Frame;
6import org.expeditee.items.Text;
7
8/**
9 * A simple formatting agent that aligns the Y values.
10 *
11 * @author Mike
12 *
13 */
14public 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.