51 |
protected ColorScheme colors; |
protected ColorScheme colors; |
52 |
|
|
53 |
protected Model model; |
protected Model model; |
54 |
protected Property typeProp; |
protected RDFVocab rdf; |
55 |
protected NamespaceMap names; |
protected NamespaceMap names; |
56 |
|
|
57 |
protected Cursor cursor; |
protected Cursor cursor; |
65 |
IOException, |
IOException, |
66 |
org.xml.sax.SAXException { |
org.xml.sax.SAXException { |
67 |
model = new ModelMem(); |
model = new ModelMem(); |
68 |
typeProp = model.createProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#", |
rdf = new RDFVocab(model); |
69 |
"type"); |
|
70 |
model.read(new java.io.FileReader(file), ""); |
model.read(new java.io.FileReader(file), ""); |
71 |
|
|
72 |
names = new NamespaceMap(); |
names = new NamespaceMap(); |
73 |
names.loadMappings(new java.io.FileReader(file)); |
names.loadMappings(new java.io.FileReader(file)); |
74 |
|
|
75 |
|
Comparator compareByAbbrev = names.getComparator(); |
76 |
|
|
|
Comparator compareByAbbrev = |
|
|
new Comparator() { |
|
|
public int compare(Object o1, Object o2) { |
|
|
String s1 = names.getAbbrev(o1.toString()); |
|
|
String s2 = names.getAbbrev(o2.toString()); |
|
|
return s1.compareTo(s2); |
|
|
} |
|
|
}; |
|
|
|
|
|
Set props = new TreeSet(compareByAbbrev); |
|
77 |
Set classes = new TreeSet(compareByAbbrev); |
Set classes = new TreeSet(compareByAbbrev); |
78 |
|
classes.addAll(ModelUtil.getClasses(model)); |
79 |
|
|
80 |
for(StmtIterator iter = model.listStatements(); iter.hasNext();) { |
properties = new ArrayList(ModelUtil.getProperties(model)); |
81 |
Statement stmt = iter.next(); |
Collections.sort(properties, compareByAbbrev); |
82 |
Property p = stmt.getPredicate(); |
|
83 |
if(!isNumberProp(p)) props.add(p); |
numericPropertiesAccepted = true; |
84 |
if(p.toString().equals( |
acceptedProperties = new HashSet(properties); |
|
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type") && |
|
|
stmt.getObject() instanceof Resource) |
|
|
classes.add(stmt.getObject()); |
|
|
} |
|
|
properties = new ArrayList(props); |
|
85 |
|
|
86 |
propList.setMultipleMode(true); |
propList.setMultipleMode(true); |
87 |
propList.removeAll(); |
propList.removeAll(); |
102 |
protected boolean accept(Statement s) { |
protected boolean accept(Statement s) { |
103 |
Property p = s.getPredicate(); |
Property p = s.getPredicate(); |
104 |
if(isNumberProp(p)) |
if(isNumberProp(p)) |
105 |
return propList.isIndexSelected(0); |
return numericPropertiesAccepted; |
106 |
int i = properties.indexOf(p); |
return acceptedProperties.contains(p); |
|
return propList.isIndexSelected(i+1); |
|
107 |
} |
} |
108 |
}, |
}, |
109 |
stmt.getSubject(), 1, stmt.getObject()); |
stmt.getSubject(), 1, stmt.getObject()); |
138 |
} |
} |
139 |
|
|
140 |
protected List properties; |
protected List properties; |
141 |
|
protected Set acceptedProperties; |
142 |
|
protected boolean numericPropertiesAccepted; |
143 |
|
|
144 |
protected Frame propFrame = new Frame("Properties"); |
protected Frame propFrame = new Frame("Properties"); |
145 |
protected java.awt.List propList = new java.awt.List(); |
protected java.awt.List propList = new java.awt.List(); |
146 |
|
|
225 |
propFrame.add(propList); |
propFrame.add(propList); |
226 |
propList.addItemListener(new ItemListener() { |
propList.addItemListener(new ItemListener() { |
227 |
public void itemStateChanged(ItemEvent e) { |
public void itemStateChanged(ItemEvent e) { |
228 |
|
numericPropertiesAccepted = false; |
229 |
|
acceptedProperties = new HashSet(); |
230 |
|
|
231 |
|
int[] indexes = propList.getSelectedIndexes(); |
232 |
|
for(int i=0; i<indexes.length; i++) { |
233 |
|
if(indexes[i] == 0) |
234 |
|
numericPropertiesAccepted = true; |
235 |
|
else |
236 |
|
acceptedProperties.add(properties.get(indexes[i]-1)); |
237 |
|
} |
238 |
|
|
239 |
// the rotation cannot be sanely kept |
// the rotation cannot be sanely kept |
240 |
// when properties are added or removed |
// when properties are added or removed |
241 |
cursor.rotation = 0; |
cursor.rotation = 0; |
272 |
|
|
273 |
try { |
try { |
274 |
Statement typeStmt = |
Statement typeStmt = |
275 |
((Resource)node).getProperty(typeProp); |
((Resource)node).getProperty(rdf.type); |
276 |
|
|
277 |
RDFNode type = typeStmt.getObject(); |
RDFNode type = typeStmt.getObject(); |
278 |
Property by = (Property)showClassBy.get(type); |
Property by = (Property)showClassBy.get(type); |