1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.vectomatic.svg.edit.client.model;
19
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import org.vectomatic.svg.edit.client.inspector.IInspectorSection;
24 import org.vectomatic.svg.edit.client.inspector.IInspectorSectionFactory;
25
26
27
28
29
30
31
32 public class ModelCategory<U> {
33 public static final String GLOBAL = "global";
34 public static final String DISPLAY = "display";
35 public static final String GEOMETRY = "geometry";
36 public static final String TRANSFORM = "transform";
37 public static final String STROKEFILL = "strokefill";
38 private String name;
39 private String description;
40 private IInspectorSectionFactory sectionFactory;
41 private List<IMetadata<?, U>> metadataList;
42 public ModelCategory(String name, String description, IInspectorSectionFactory sectionFactory) {
43 this.name = name;
44 this.description = description;
45 this.sectionFactory = sectionFactory;
46 this.metadataList = new ArrayList<IMetadata<?, U>>();
47 }
48 public String getName() {
49 return name;
50 }
51 public String getDescription() {
52 return description;
53 }
54 public IInspectorSection getInspectorSection() {
55 return sectionFactory != null ? sectionFactory.createSection(this) : null;
56 }
57 public List<IMetadata<?, U>> getMetadata() {
58 return metadataList;
59 }
60 public <T> IMetadata<T, U> getMetadata(String name) {
61 for (IMetadata<?, U> m : metadataList) {
62 if (name.equals(m.getName())) {
63 return (IMetadata<T, U>)m;
64 }
65 }
66 return null;
67 }
68 public void addMetadata(MetadataBase<?,U> metadata) {
69 metadata.category = this;
70 metadataList.add(metadata);
71 }
72 @Override
73 public String toString() {
74 StringBuilder builder = new StringBuilder("ModelCategory(");
75 builder.append(name);
76 builder.append(", ");
77 builder.append(metadataList);
78 builder.append(")");
79 return builder.toString();
80 }
81 }