29 |
import org.nongnu.libvob.vobs.*; |
import org.nongnu.libvob.vobs.*; |
30 |
|
|
31 |
import java.awt.Color; |
import java.awt.Color; |
|
//import java.awt.event.*; |
|
|
//import java.io.*; |
|
32 |
import java.util.*; |
import java.util.*; |
33 |
import java.util.List; |
import java.util.List; |
34 |
|
|
35 |
import com.hp.hpl.mesa.rdf.jena.model.*; |
import com.hp.hpl.mesa.rdf.jena.model.*; |
|
//import com.hp.hpl.mesa.rdf.jena.mem.*; |
|
36 |
|
|
37 |
/** The default node view for Loom. |
/** The default node view for Loom. |
38 |
* Not tested at this time [XXX fix!!!]. |
* Not tested at this time [XXX fix!!!]. |
54 |
loom.colors.getCursorBorderColor()); |
loom.colors.getCursorBorderColor()); |
55 |
} |
} |
56 |
|
|
57 |
public void render(VobScene sc, int into, Nodespec spec) { |
/** Argh-- global variable because getText() |
58 |
RDFNode node = spec.node; |
* can only return one thing :-( :-( |
59 |
Property prop = spec.prop; |
*/ |
60 |
int dir = spec.dir; |
protected boolean isByClass; |
61 |
|
|
62 |
boolean selected = spec.equals(loom.cursor.getRotationNodespec(dir)); |
public String getText(RDFNode node, boolean abbreviate) { |
|
if(node instanceof Resource) { |
|
|
if(selected) |
|
|
sc.map.put(selResourceVob, into); |
|
|
else |
|
|
sc.map.put(resourceVob, into); |
|
|
} else { |
|
|
if(selected) |
|
|
sc.map.put(selLiteralVob, into); |
|
|
else |
|
|
sc.map.put(literalVob, into); |
|
|
} |
|
|
|
|
63 |
String s; |
String s; |
64 |
boolean isByClass = false; |
isByClass = false; |
65 |
if(node instanceof Literal) { |
if(node instanceof Literal) { |
66 |
try { |
try { |
67 |
s = ((Literal)node).getString(); |
s = ((Literal)node).getString(); |
71 |
} |
} |
72 |
} else { |
} else { |
73 |
s = ((Resource)node).getURI(); |
s = ((Resource)node).getURI(); |
74 |
if(s != null) |
if(s != null && abbreviate) |
75 |
s = loom.cursor.names.getAbbrev(s); |
s = loom.cursor.names.getAbbrev(s); |
76 |
else |
else if(s == null) |
77 |
s = ""; |
s = ""; |
78 |
String t = s; |
String t = s; |
79 |
|
|
93 |
Statement byStmt = ((Resource)node).getProperty(by); |
Statement byStmt = ((Resource)node).getProperty(by); |
94 |
if(byStmt.getObject() instanceof Literal) |
if(byStmt.getObject() instanceof Literal) |
95 |
s = byStmt.getString(); |
s = byStmt.getString(); |
96 |
else |
else if(abbreviate) |
97 |
s = loom.cursor.names.getAbbrev(byStmt.getObject().toString()); |
s = loom.cursor.names.getAbbrev(byStmt.getObject().toString()); |
98 |
|
else |
99 |
|
s = byStmt.getObject().toString(); |
100 |
|
|
101 |
isByClass = true; |
isByClass = true; |
102 |
} |
} |
104 |
s = t; |
s = t; |
105 |
} |
} |
106 |
} |
} |
107 |
|
|
108 |
|
return s; |
109 |
|
} |
110 |
|
|
111 |
|
public void render(VobScene sc, int into, Nodespec spec) { |
112 |
|
RDFNode node = spec.node; |
113 |
|
Property prop = spec.prop; |
114 |
|
int dir = spec.dir; |
115 |
|
|
116 |
|
boolean selected = spec.equals(loom.cursor.getRotationNodespec(dir)); |
117 |
|
if(node instanceof Resource) { |
118 |
|
if(selected) |
119 |
|
sc.map.put(selResourceVob, into); |
120 |
|
else |
121 |
|
sc.map.put(resourceVob, into); |
122 |
|
} else { |
123 |
|
if(selected) |
124 |
|
sc.map.put(selLiteralVob, into); |
125 |
|
else |
126 |
|
sc.map.put(literalVob, into); |
127 |
|
} |
128 |
|
|
129 |
|
String s = getText(node, true); |
130 |
|
|
131 |
if(s.length() > 17) { |
if(s.length() > 17) { |
132 |
if(node instanceof Literal || isByClass) |
if(node instanceof Literal || isByClass) |