1 | package org.honours.collection;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 | import java.util.concurrent.CopyOnWriteArrayList;
|
---|
5 |
|
---|
6 | import org.expeditee.gui.Frame;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Stores all the information about an individual
|
---|
10 | * item in a collection (including the actual
|
---|
11 | * frame that this item is displayed on).
|
---|
12 | * @author Korii
|
---|
13 | *
|
---|
14 | */
|
---|
15 | public class CollectionItem {
|
---|
16 |
|
---|
17 | private Frame _frame;
|
---|
18 |
|
---|
19 | //Path location of the file associated with this item (e.g. HASH017.dir).
|
---|
20 | private String _assocfilepath;
|
---|
21 |
|
---|
22 | //file associated with this particular item.
|
---|
23 | private String _associatedFile;
|
---|
24 |
|
---|
25 | //doc.xml file associated with this item.
|
---|
26 | private String _docXML;
|
---|
27 |
|
---|
28 | private CopyOnWriteArrayList<ContentLayer> _layers;
|
---|
29 |
|
---|
30 | //At this stage a CollectionItem can only have ONE NoteLayer object.
|
---|
31 | private NoteLayer _noteLayer;
|
---|
32 |
|
---|
33 | public CollectionItem(){
|
---|
34 | _layers = new CopyOnWriteArrayList<ContentLayer>();
|
---|
35 | }
|
---|
36 |
|
---|
37 | public void setFrame(Frame f){
|
---|
38 | _frame = f;
|
---|
39 | }
|
---|
40 |
|
---|
41 | public Frame getFrame(){
|
---|
42 | return _frame;
|
---|
43 | }
|
---|
44 |
|
---|
45 | public void setNoteLayer(NoteLayer nl){
|
---|
46 | _noteLayer = nl;
|
---|
47 | }
|
---|
48 |
|
---|
49 | public NoteLayer getNoteLayer(){
|
---|
50 | return _noteLayer;
|
---|
51 | }
|
---|
52 |
|
---|
53 | public void addLayer(ContentLayer layer){
|
---|
54 | _layers.add(layer);
|
---|
55 | }
|
---|
56 |
|
---|
57 | public List<ContentLayer> getLayers(){
|
---|
58 | return _layers;
|
---|
59 | }
|
---|
60 |
|
---|
61 | public void setAssocfilePath(String assocfilepath){
|
---|
62 | _assocfilepath = assocfilepath;
|
---|
63 | }
|
---|
64 |
|
---|
65 | public String getAssocFilePath()
|
---|
66 | {
|
---|
67 | return _assocfilepath;
|
---|
68 | }
|
---|
69 |
|
---|
70 | public void setAssociatedFile(String associatedFile){
|
---|
71 | _associatedFile = associatedFile;
|
---|
72 | }
|
---|
73 |
|
---|
74 | public String getAssociatedFile(){
|
---|
75 | return _associatedFile;
|
---|
76 | }
|
---|
77 |
|
---|
78 | public void setDocXML(String docXML){
|
---|
79 | _docXML = docXML;
|
---|
80 | }
|
---|
81 |
|
---|
82 | public String getDocXML(){
|
---|
83 | return _docXML;
|
---|
84 | }
|
---|
85 |
|
---|
86 | public static CollectionItem findCollectionItem(Frame frame,Collection collect){
|
---|
87 |
|
---|
88 | if(collect == null)
|
---|
89 | return null;
|
---|
90 |
|
---|
91 | for(CollectionItem ci : collect.getItems()){
|
---|
92 | if(ci.getFrame().getName().equals(frame.getName()))
|
---|
93 | return ci;
|
---|
94 | }
|
---|
95 |
|
---|
96 | return null;
|
---|
97 | }
|
---|
98 |
|
---|
99 | public static int getPositionInCollection(CollectionItem ci,Collection collect){
|
---|
100 |
|
---|
101 | if(ci == null)
|
---|
102 | return -1;
|
---|
103 |
|
---|
104 | for(int i = 0; i < collect.getItems().size(); i++){
|
---|
105 | CollectionItem currCI = collect.getItems().get(i);
|
---|
106 | if(currCI == ci)
|
---|
107 | return i;
|
---|
108 | }
|
---|
109 |
|
---|
110 | return -1;
|
---|
111 | }
|
---|
112 | }
|
---|