source: trunk/src/org/expeditee/agents/ScaleFrameset.java@ 328

Last change on this file since 328 was 328, checked in by ra33, 16 years ago
File size: 1.9 KB
Line 
1package org.expeditee.agents;
2
3import java.util.Collection;
4
5import org.expeditee.gui.Frame;
6import org.expeditee.gui.FrameIO;
7import org.expeditee.gui.FrameKeyboardActions;
8import org.expeditee.gui.Vector;
9import org.expeditee.items.Item;
10import org.expeditee.items.Line;
11import org.expeditee.items.Permission;
12
13public class ScaleFrameset extends DefaultAgent {
14 private int _firstFrame = 1;
15
16 private float _scale = 1F;
17
18 private int _maxFrame = Integer.MAX_VALUE;
19
20 public ScaleFrameset(float scale, int firstFrame, int maxFrame) {
21 super();
22 _firstFrame = firstFrame;
23 _maxFrame = maxFrame;
24 _scale = scale;
25 }
26
27 public ScaleFrameset(float scale) {
28 this(scale, 1, Integer.MAX_VALUE);
29 }
30
31 @Override
32 protected Frame process(Frame frame) {
33 String framesetName = frame.getFramesetName();
34
35 _maxFrame = Math.min(FrameIO.getLastNumber(framesetName), _maxFrame);
36
37 // Scale each of the frames
38 for (int i = _firstFrame; i <= _maxFrame; i++) {
39 Frame next = FrameIO.LoadFrame(framesetName + i);
40 if (next == null)
41 continue;
42
43 for (Vector v : next.getVectors()) {
44 v.Source.scale(_scale, 0, 0);
45 }
46
47 Collection<Item> items = next.getVisibleItems();
48
49 for (Item item : items) {
50 // This line is only needed for circles!!
51 // Need to really fix up the way this works!!
52 if (item.hasEnclosures())
53 continue;
54 if (!item.hasPermission(Permission.full))
55 continue;
56 item.invalidateAll();
57 if (!(item instanceof Line)) {
58 item.scale(_scale, 0, 0);
59 }
60 }
61
62 for (Item item : items) {
63 if (!item.hasPermission(Permission.full))
64 continue;
65 // if (!(item instanceof Line))
66 item.updatePolygon();
67
68 if (item instanceof Line) {
69 ((Line) item).refreshStroke(item.getThickness());
70 }
71
72 item.invalidateAll();
73 }
74 }
75 // TODO fix this so it actually works properly!!
76 // TODO figure out why it doesnt repaint correctly sometimes
77
78 // TODO make this thread safe!
79 FrameKeyboardActions.Refresh();
80
81 return null;
82 }
83}
Note: See TracBrowser for help on using the repository browser.