1 |
//(c): Matti J. Katila |
//(c): Matti J. Katila |
2 |
|
|
3 |
package org.fenfire.modules.pp; |
package org.fenfire.modules.pp; |
4 |
|
import org.fenfire.vocab.*; |
5 |
|
import org.fenfire.util.*; |
6 |
import org.fenfire.view.*; |
import org.fenfire.view.*; |
7 |
import org.fenfire.view.buoy.*; |
import org.fenfire.view.buoy.*; |
8 |
import org.nongnu.libvob.*; |
import org.nongnu.libvob.*; |
18 |
|
|
19 |
private Model model; |
private Model model; |
20 |
private GraphicsAPI.Window win; |
private GraphicsAPI.Window win; |
|
private PPVocab PP = new PPVocab(); |
|
21 |
public PPCanvasNode(Model m, GraphicsAPI.Window w) { |
public PPCanvasNode(Model m, GraphicsAPI.Window w) { |
22 |
this.model = m; |
this.model = m; |
23 |
this.win = w; |
this.win = w; |
27 |
/** True if this view "owns" a certain node. |
/** True if this view "owns" a certain node. |
28 |
*/ |
*/ |
29 |
public boolean ownsNode(RDFNode node) |
public boolean ownsNode(RDFNode node) |
30 |
{ try { |
{ |
31 |
// check if node is a note |
// check if node is a note |
32 |
Selector slctr = new SelectorImpl((Resource)node, RDF.type, (RDFNode) null); |
if (ShortRDF.isNodeType(model, node, PP.noteType)) return true; |
|
StmtIterator iter = model.listStatements(slctr); |
|
|
while (iter.hasNext()) { |
|
|
Statement stmt = iter.next(); |
|
|
if (stmt.getSubject() == PP.NoteType) return true; |
|
|
} |
|
33 |
|
|
34 |
// or if node is a paper |
// or if node is a paper |
35 |
slctr = new SelectorImpl((Resource)node, RDF.type, (RDFNode) null); |
if (ShortRDF.isNodeType(model, node, PP.paperType)) return true; |
|
iter = model.listStatements(slctr); |
|
|
while (iter.hasNext()) { |
|
|
Statement stmt = iter.next(); |
|
|
if (stmt.getSubject() == PP.PaperType) return true; |
|
|
} |
|
36 |
|
|
37 |
// otherwise |
// otherwise |
38 |
return false; |
return false; |
39 |
} catch (RDFException e) { |
} |
|
pa("Exception!: "+e); |
|
|
throw new Error("Error in PPCanvas"); |
|
|
}} |
|
40 |
|
|
41 |
/** Get the ideal size for this buoy. |
/** Get the ideal size for this buoy. |
42 |
* (mudyc): Just and idea if vobscene width and height is passed in wh... |
* (mudyc): Just and idea if vobscene width and height is passed in wh... |
106 |
|
|
107 |
|
|
108 |
private int[] getCoords(RDFNode node) { |
private int[] getCoords(RDFNode node) { |
109 |
try { |
int [] ints = new int[2]; |
110 |
int [] ints = new int[2]; |
|
111 |
|
ints[0] = ShortRDF.getInt(model, node, SPATIAL.coordX); |
112 |
Selector slctr = new SelectorImpl((Resource)node, PP.CoordX, (RDFNode) null); |
ints[1] = ShortRDF.getInt(model, node, SPATIAL.coordY); |
113 |
StmtIterator iter = model.listStatements(slctr); |
return ints; |
|
if (iter.hasNext()) { |
|
|
Statement stmt = iter.next(); |
|
|
ints[0] = stmt.getInt(); |
|
|
} |
|
|
|
|
|
slctr = new SelectorImpl((Resource)node, PP.CoordY, (RDFNode) null); |
|
|
iter = model.listStatements(slctr); |
|
|
if (iter.hasNext()) { |
|
|
Statement stmt = iter.next(); |
|
|
ints[1] = stmt.getInt(); |
|
|
} |
|
|
|
|
|
return ints; |
|
|
} catch (RDFException e) { |
|
|
pa("Exception!: "+e); |
|
|
throw new Error("Error in PPCanvas"); |
|
|
} |
|
114 |
} |
} |
115 |
|
|
116 |
} |
} |