1 | package org.honours.CollectionSpace;
|
---|
2 |
|
---|
3 | import java.io.BufferedReader;
|
---|
4 | import java.io.File;
|
---|
5 | import java.io.FileReader;
|
---|
6 | import java.util.ArrayList;
|
---|
7 | import java.util.List;
|
---|
8 |
|
---|
9 | import org.expeditee.actions.Navigation;
|
---|
10 | import org.expeditee.gui.Frame;
|
---|
11 | import org.expeditee.gui.FrameIO;
|
---|
12 | import org.expeditee.gui.MessageBay;
|
---|
13 | import org.expeditee.items.ItemParentStateChangedEvent;
|
---|
14 | import org.expeditee.items.Picture;
|
---|
15 | import org.expeditee.items.Text;
|
---|
16 | import org.honours.collection.Collection;
|
---|
17 | import org.honours.gui.HonoursFrameIO;
|
---|
18 | import org.honours.items.PictureInformation;
|
---|
19 |
|
---|
20 | public class CollectionSpace {
|
---|
21 |
|
---|
22 | //the collection this collection space is associated with
|
---|
23 | private Collection _associatedCollection;
|
---|
24 |
|
---|
25 | private String _name;
|
---|
26 |
|
---|
27 | //FOr storing thumbnails for the collection space
|
---|
28 | private String _thumbnailsDirectory;
|
---|
29 |
|
---|
30 | private List<Picture> _thumbnails = new ArrayList<Picture>();
|
---|
31 |
|
---|
32 | private int _startX = 150;
|
---|
33 | private int _startY = 150;
|
---|
34 |
|
---|
35 | public static final int _gap = 20;
|
---|
36 | public static final int _columns = 4;
|
---|
37 | public static final int _imageSize = 150;
|
---|
38 | public static final int _rows = 3;
|
---|
39 |
|
---|
40 | public CollectionSpace(){
|
---|
41 |
|
---|
42 | }
|
---|
43 |
|
---|
44 | public CollectionSpace(Collection associatedCollection){
|
---|
45 | _associatedCollection = associatedCollection;
|
---|
46 | _name = "collectionspace-" + _associatedCollection.getName();
|
---|
47 | _thumbnailsDirectory = FrameIO.IMAGES_FOLDER + "thumbnails-" +
|
---|
48 | _associatedCollection.getName();
|
---|
49 | }
|
---|
50 |
|
---|
51 | public void setAssociatedCollection(Collection assocCollection){
|
---|
52 | _associatedCollection = assocCollection;
|
---|
53 | }
|
---|
54 |
|
---|
55 | public Collection getAssociatedCollection(){
|
---|
56 | return _associatedCollection;
|
---|
57 | }
|
---|
58 |
|
---|
59 | public void setName(String name){
|
---|
60 | _name = name;
|
---|
61 | }
|
---|
62 |
|
---|
63 | public String getName(){
|
---|
64 | return _name;
|
---|
65 | }
|
---|
66 |
|
---|
67 | public void setThumbnailsDirectory(String dir){
|
---|
68 |
|
---|
69 | _thumbnailsDirectory = dir;
|
---|
70 |
|
---|
71 | }
|
---|
72 |
|
---|
73 | public String getThumbnailsDirectory(){
|
---|
74 | return _thumbnailsDirectory;
|
---|
75 | }
|
---|
76 |
|
---|
77 | public void generate(){
|
---|
78 |
|
---|
79 |
|
---|
80 | }
|
---|
81 |
|
---|
82 | /** Method to output thumbnails into collection space **/
|
---|
83 | private void writeThumbnails(){
|
---|
84 |
|
---|
85 | Frame currFrame = null;
|
---|
86 | int currX = _startX;
|
---|
87 | int currY = _startY;
|
---|
88 |
|
---|
89 | int frameIter = 1;
|
---|
90 |
|
---|
91 | generateNavigationLinks(frameIter);
|
---|
92 | generateDropBox(frameIter);
|
---|
93 |
|
---|
94 | for(int i = 0; i < _thumbnails.size(); i++)
|
---|
95 | {
|
---|
96 | Picture currPic = _thumbnails.get(i);
|
---|
97 |
|
---|
98 | if(i % _columns ==0 && i == 0){
|
---|
99 |
|
---|
100 | }else if(i % _columns == 0 && i > 0){
|
---|
101 | currX = _startX;
|
---|
102 | currY += _gap + _imageSize;
|
---|
103 | }else{
|
---|
104 | currX += _gap + _imageSize;
|
---|
105 | }
|
---|
106 |
|
---|
107 | //Create a new frame to display next lot of items.
|
---|
108 | if(i % (_columns * _rows) == 0 && i < _columns * _rows){
|
---|
109 | currFrame = FrameIO.LoadFrame(_name + frameIter);
|
---|
110 |
|
---|
111 | }else if(i % (_columns * _rows) == 0 && i >= _columns * _rows){
|
---|
112 | frameIter++;
|
---|
113 | Frame check = FrameIO.LoadFrame(_name + frameIter);
|
---|
114 | if(check == null){
|
---|
115 | //create new frame
|
---|
116 | HonoursFrameIO.generateFrame(frameIter, _name);
|
---|
117 | currFrame = FrameIO.LoadFrame(_name + frameIter);
|
---|
118 |
|
---|
119 | currX = _startX;
|
---|
120 | currY = _startY;
|
---|
121 | generateNavigationLinks(frameIter);
|
---|
122 | generateDropBox(frameIter);
|
---|
123 | }
|
---|
124 |
|
---|
125 | }
|
---|
126 |
|
---|
127 | currFrame.addText(currX, currY, currPic.getSource().getText(),
|
---|
128 | null, currPic.getLink());
|
---|
129 | currFrame.setSaved();
|
---|
130 | }
|
---|
131 |
|
---|
132 | _associatedCollection.setCollectionSpace(this);
|
---|
133 | }
|
---|
134 |
|
---|
135 | private void generateNavigationLinks(int frameIter){
|
---|
136 |
|
---|
137 | String backText = "<<";
|
---|
138 | String forwardText = ">>";
|
---|
139 |
|
---|
140 | int backButtonX = _startX/2;
|
---|
141 | int forwardButtonX = _startX + (_columns*_gap)+(_columns*_imageSize);
|
---|
142 | int buttonPosY = ((_rows*_imageSize) + (_rows*_gap))/2;
|
---|
143 |
|
---|
144 | Frame currFrame = FrameIO.LoadFrame(_name+frameIter);
|
---|
145 | currFrame.addText(backButtonX,buttonPosY,backText,"RotateBack");
|
---|
146 | currFrame.addText(forwardButtonX,buttonPosY,forwardText,"RotateNext");
|
---|
147 | currFrame.setSaved();
|
---|
148 | }
|
---|
149 |
|
---|
150 | private void generateDropBox(int frameIter){
|
---|
151 |
|
---|
152 | }
|
---|
153 |
|
---|
154 | private void createCollectionSpace(){
|
---|
155 | Frame check = FrameIO.LoadFrame(_name + "1");
|
---|
156 |
|
---|
157 | if(check != null){
|
---|
158 | FrameIO.deleteFrameset(_name);
|
---|
159 | }
|
---|
160 |
|
---|
161 | try{
|
---|
162 | FrameIO.CreateNewFrameset(_name);
|
---|
163 | }catch(Exception e){
|
---|
164 | e.printStackTrace();
|
---|
165 | }
|
---|
166 | }
|
---|
167 | }
|
---|