Thread: [graphl-cvs] graphl/src/org/mediavirus/graphl/graph/rdf RDFNode.java RDFGraph.java
Status: Pre-Alpha
Brought to you by:
flo1
From: Flo L. <fl...@us...> - 2004-10-19 16:17:45
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17517/src/org/mediavirus/graphl/graph/rdf Modified Files: RDFNode.java RDFGraph.java Log Message: - FEATURE further commandline options to remove controls and menubar - FEATURE load url from commandline - FEATURE refresh every n seconds commandline option - FEATURE affine coordinate transformation for geo positioning on a map - FEATURE removed length property of edge, replaced by generic length calculation from any property in springEdgeLayouter - FEATURE configurable stroke for BoxNodePainter, ShapeNodePainter - FEATURE replaced rdfutils function by own implementation in ParseUtils Index: RDFNode.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf/RDFNode.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RDFNode.java 14 Oct 2004 13:03:05 -0000 1.4 --- RDFNode.java 19 Oct 2004 16:16:58 -0000 1.5 *************** *** 11,14 **** --- 11,15 ---- import org.mediavirus.graphl.graph.DefaultNode; import org.mediavirus.graphl.graph.Node; + import org.mediavirus.util.ParseUtils; import edu.unika.aifb.rdf.api.util.RDFUtil; *************** *** 53,57 **** if ( label != null) return label; else { ! label = RDFUtil.guessName(getId()); } if (label != null) return label; --- 54,58 ---- if ( label != null) return label; else { ! label = ParseUtils.guessName(getId()); } if (label != null) return label; Index: RDFGraph.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf/RDFGraph.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RDFGraph.java 14 Oct 2004 13:03:05 -0000 1.4 --- RDFGraph.java 19 Oct 2004 16:16:59 -0000 1.5 *************** *** 61,66 **** for (Iterator iter = allNodes.iterator(); iter.hasNext();) { RDFNode node = (RDFNode) iter.next(); - //writer.writeStatement(node.getId(), "http://www.mediavirus.org/graphl#hasLabel", node.getLabel(), null, null, true); - //if (node.getComment() != null) writer.writeStatement(node.getId(), "http://www.mediavirus.org/graphl#hasComment", node.getComment(), null, null, true); writer.writeStatement(node.getId(), "http://www.mediavirus.org/graphl#canvasPosition", node.getCenterX() + ":" + node.getCenterY(), null, null, true); List nodeEdges = node.getEdgesFrom(); --- 61,64 ---- |
From: Flo L. <fl...@us...> - 2005-01-11 13:27:25
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25738/src/org/mediavirus/graphl/graph/rdf Modified Files: RDFNode.java RDFGraph.java Log Message: - FEATURE: implemented generic type menu that reads from RDF vocabs - FEATURE: RDFGraph now imports files referenced with owl:imports statements - BUG: fixed saving of literal properties - BUG: fixed Swing look and feel for JDK 1.5 - CODE: GraphlPane now stores vocabularies - CODE: added first (dummy) implementation of node mainpulator - CODE: added getProperties() mehtod to PropertySet interface Index: RDFNode.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf/RDFNode.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RDFNode.java 21 Oct 2004 16:00:48 -0000 1.6 --- RDFNode.java 11 Jan 2005 13:26:40 -0000 1.7 *************** *** 6,9 **** --- 6,10 ---- + import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; *************** *** 93,97 **** } else { ! Iterator edges = getEdgesFrom().iterator(); while (edges.hasNext()) { RDFEdge e = (RDFEdge)edges.next(); --- 94,98 ---- } else { ! Iterator edges = new ArrayList(getEdgesFrom()).iterator(); while (edges.hasNext()) { RDFEdge e = (RDFEdge)edges.next(); Index: RDFGraph.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf/RDFGraph.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RDFGraph.java 30 Nov 2004 09:38:34 -0000 1.7 --- RDFGraph.java 11 Jan 2005 13:26:41 -0000 1.8 *************** *** 17,20 **** --- 17,21 ---- import java.util.Hashtable; import java.util.List; + import java.util.Map; import org.mediavirus.graphl.graph.DefaultGraph; *************** *** 53,60 **** --- 54,75 ---- RDFWriter writer = new RDFWriter(); + // TODO (2) use vocabularies from config for prefix resolution writer.addNamespacePrefix("graphl","http://www.mediavirus.org/graphl#"); + writer.addNamespacePrefix("foaf","http://xmlns.com/foaf/0.1/"); + writer.addNamespacePrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#"); + writer.addNamespacePrefix("rdfs","http://www.w3.org/2000/01/rdf-schema#"); + writer.addNamespacePrefix("owl","http://www.w3.org/2002/07/owl#"); + writer.addNamespacePrefix("map","http://fabl.net/vocabularies/geography/map/1.1/"); + writer.addNamespacePrefix("geo","http://www.w3.org/2003/01/geo/wgs84_pos#"); writer.prepareNamespaceCollection(); + writer.collectNamespace("http://www.mediavirus.org/graphl#"); + writer.collectNamespace("http://xmlns.com/foaf/0.1/"); + writer.collectNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#"); + writer.collectNamespace("http://www.w3.org/2000/01/rdf-schema#"); + writer.collectNamespace("http://www.w3.org/2002/07/owl#"); + writer.collectNamespace("http://fabl.net/vocabularies/geography/map/1.1/"); + writer.collectNamespace("http://www.w3.org/2003/01/geo/wgs84_pos#"); OutputStreamWriter owriter = new OutputStreamWriter(out); *************** *** 65,69 **** for (Iterator iter = allNodes.iterator(); iter.hasNext();) { RDFNode node = (RDFNode) iter.next(); ! writer.writeStatement(node.getId(), "http://www.mediavirus.org/graphl#canvasPosition", node.getCenterX() + ":" + node.getCenterY(), null, null, true); List nodeEdges = node.getEdgesFrom(); for (Iterator edgeIter = nodeEdges.iterator(); edgeIter.hasNext();) { --- 80,88 ---- for (Iterator iter = allNodes.iterator(); iter.hasNext();) { RDFNode node = (RDFNode) iter.next(); ! for (Iterator attrs = node.getProperties().keySet().iterator(); attrs.hasNext();) { ! String attr = (String) attrs.next(); ! writer.writeStatement(node.getId(), attr, node.getProperty(attr), null, null, true); ! } ! //writer.writeStatement(node.getId(), "http://www.mediavirus.org/graphl#canvasPosition", node.getCenterX() + ":" + node.getCenterY(), null, null, true); List nodeEdges = node.getEdgesFrom(); for (Iterator edgeIter = nodeEdges.iterator(); edgeIter.hasNext();) { *************** *** 161,164 **** --- 180,198 ---- addElements(null, Collections.singleton(edge)); if (DEBUG) System.out.println("created edge " + subject + ", " + predicate + ", " + object); + + if (predicate.equals("http://www.w3.org/2002/07/owl#imports")) { + System.out.println("#### " + object); + try { + URL oldBase = baseURL; + URL importURL = new URL(baseURL, object); + System.out.println("importing " + importURL.toString() + " ... "); + readFromURL(importURL); + // restore original base url + baseURL = oldBase; + } + catch (MalformedURLException muex) { + System.out.println("Error importing " + object); + } + } } } |
From: Flo L. <fl...@us...> - 2005-08-17 15:53:07
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16461/src/org/mediavirus/graphl/graph/rdf Modified Files: RDFNode.java RDFGraph.java Log Message: - FEATURE: added navigator thread for update-exhibition, disabled in normal operation - FEATURE: started implementation of filtering architecture - FEATURE: creating new node opens type context menu - CODE: added NS calss for easier namespace referencing in code Index: RDFNode.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf/RDFNode.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RDFNode.java 11 Jan 2005 13:26:40 -0000 1.7 --- RDFNode.java 17 Aug 2005 15:52:53 -0000 1.8 *************** *** 12,15 **** --- 12,16 ---- import org.mediavirus.graphl.graph.DefaultNode; import org.mediavirus.graphl.graph.Node; + import org.mediavirus.graphl.vocabulary.NS; import org.mediavirus.util.ParseUtils; *************** *** 50,54 **** // TODO (2, 2h) label generation mechanism has to be hooked up here public String getLabel() { ! String label = getProperty("http://www.mediavirus.org/graphl#label"); if ( label != null) return label; else { --- 51,55 ---- // TODO (2, 2h) label generation mechanism has to be hooked up here public String getLabel() { ! String label = getProperty(NS.graphl + "label"); if ( label != null) return label; else { Index: RDFGraph.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf/RDFGraph.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** RDFGraph.java 11 Jan 2005 13:26:41 -0000 1.8 --- RDFGraph.java 17 Aug 2005 15:52:53 -0000 1.9 *************** *** 7,10 **** --- 7,11 ---- import java.util.Iterator; + import java.io.File; import java.io.FileReader; import java.io.IOException; *************** *** 17,25 **** import java.util.Hashtable; import java.util.List; - import java.util.Map; import org.mediavirus.graphl.graph.DefaultGraph; import org.mediavirus.graphl.graph.Edge; import org.mediavirus.graphl.graph.Node; import org.xml.sax.InputSource; import org.xml.sax.SAXException; --- 18,26 ---- import java.util.Hashtable; import java.util.List; import org.mediavirus.graphl.graph.DefaultGraph; import org.mediavirus.graphl.graph.Edge; import org.mediavirus.graphl.graph.Node; + import org.mediavirus.graphl.vocabulary.NS; import org.xml.sax.InputSource; import org.xml.sax.SAXException; *************** *** 41,45 **** Hashtable allNodes = new Hashtable(); ! URL baseURL = null; private int loadCount = 0; --- 42,47 ---- Hashtable allNodes = new Hashtable(); ! URL loadingURL = null; ! Node sourceNode = null; private int loadCount = 0; *************** *** 55,59 **** // TODO (2) use vocabularies from config for prefix resolution ! writer.addNamespacePrefix("graphl","http://www.mediavirus.org/graphl#"); writer.addNamespacePrefix("foaf","http://xmlns.com/foaf/0.1/"); writer.addNamespacePrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#"); --- 57,61 ---- // TODO (2) use vocabularies from config for prefix resolution ! writer.addNamespacePrefix("graphl",NS.graphl); writer.addNamespacePrefix("foaf","http://xmlns.com/foaf/0.1/"); writer.addNamespacePrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#"); *************** *** 65,69 **** writer.prepareNamespaceCollection(); ! writer.collectNamespace("http://www.mediavirus.org/graphl#"); writer.collectNamespace("http://xmlns.com/foaf/0.1/"); writer.collectNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#"); --- 67,71 ---- writer.prepareNamespaceCollection(); ! writer.collectNamespace(NS.graphl); writer.collectNamespace("http://xmlns.com/foaf/0.1/"); writer.collectNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#"); *************** *** 84,88 **** writer.writeStatement(node.getId(), attr, node.getProperty(attr), null, null, true); } ! //writer.writeStatement(node.getId(), "http://www.mediavirus.org/graphl#canvasPosition", node.getCenterX() + ":" + node.getCenterY(), null, null, true); List nodeEdges = node.getEdgesFrom(); for (Iterator edgeIter = nodeEdges.iterator(); edgeIter.hasNext();) { --- 86,90 ---- writer.writeStatement(node.getId(), attr, node.getProperty(attr), null, null, true); } ! //writer.writeStatement(node.getId(), NS.graphl + "canvasPosition", node.getCenterX() + ":" + node.getCenterY(), null, null, true); List nodeEdges = node.getEdgesFrom(); for (Iterator edgeIter = nodeEdges.iterator(); edgeIter.hasNext();) { *************** *** 97,111 **** public void readFromFile(String filename) throws IOException { try { ! baseURL = new URL("file:///" + filename); } catch (MalformedURLException e) {} ! InputSource input = new InputSource(new FileReader(filename)); input.setSystemId(""); readGraph(input); } public void readFromURL(URL url){ ! baseURL = url; InputSource input; try { --- 99,123 ---- public void readFromFile(String filename) throws IOException { + File f = new File(filename); try { ! loadingURL = new URL("file:///" + f.getAbsolutePath()); } catch (MalformedURLException e) {} ! ! sourceNode = getNodeOrNew(loadingURL.toString()); ! ! InputSource input = new InputSource(new FileReader(f)); input.setSystemId(""); readGraph(input); + + loadingURL = null; + sourceNode = null; } public void readFromURL(URL url){ ! ! loadingURL = url; ! sourceNode = getNodeOrNew(loadingURL.toString()); ! InputSource input; try { *************** *** 117,121 **** e.printStackTrace(); } ! } public synchronized void readGraph(InputSource input) { --- 129,136 ---- e.printStackTrace(); } ! ! loadingURL = null; ! sourceNode = null; ! } public synchronized void readGraph(InputSource input) { *************** *** 154,158 **** */ public void statementWithResourceValue(String subject, String predicate, String object) throws SAXException { ! //if (predicate.equals("http://www.mediavirus.org/graphl#connectedTo")) { // get / create node with label subject Node snode; --- 169,173 ---- */ public void statementWithResourceValue(String subject, String predicate, String object) throws SAXException { ! //if (predicate.equals(NS.graphl + "connectedTo")) { // get / create node with label subject Node snode; *************** *** 178,181 **** --- 193,197 ---- edge = new RDFEdge(snode,onode); edge.setType(predicate); + edge.setSource(loadingURL.toString()); addElements(null, Collections.singleton(edge)); if (DEBUG) System.out.println("created edge " + subject + ", " + predicate + ", " + object); *************** *** 184,193 **** System.out.println("#### " + object); try { ! URL oldBase = baseURL; ! URL importURL = new URL(baseURL, object); System.out.println("importing " + importURL.toString() + " ... "); readFromURL(importURL); // restore original base url ! baseURL = oldBase; } catch (MalformedURLException muex) { --- 200,209 ---- System.out.println("#### " + object); try { ! URL oldBase = loadingURL; ! URL importURL = new URL(loadingURL, object); System.out.println("importing " + importURL.toString() + " ... "); readFromURL(importURL); // restore original base url ! loadingURL = oldBase; } catch (MalformedURLException muex) { *************** *** 214,221 **** node.setCenter(r*Math.sin(loadAlpha), r*Math.cos(loadAlpha)); loadCount++; - //node.setCenter(400*Math.random()-200,400*Math.random()-200); addElements(Collections.singleton(node), null); if (DEBUG) System.out.println("created node " + uri); } return node; } --- 230,251 ---- node.setCenter(r*Math.sin(loadAlpha), r*Math.cos(loadAlpha)); loadCount++; addElements(Collections.singleton(node), null); if (DEBUG) System.out.println("created node " + uri); } + if (sourceNode != null) { + boolean found = false; + for (Iterator i = node.getNeighbours(NS.graphl + "definedIn", true).iterator(); i.hasNext();) { + Node source = (Node) i.next(); + if (source.equals(sourceNode)) { + found = true; + break; + } + } + if (!found) { + Edge edge = createEdge(node, sourceNode); + edge.setSource(NS.graphl + "SYSTEM"); + edge.setType(NS.graphl + "definedIn"); + } + } return node; } *************** *** 229,232 **** --- 259,263 ---- public Edge createEdge(Node from, Node to) { RDFEdge edge = new RDFEdge(from, to); + edge.setSource(loadingURL.toString()); addElements(null, Collections.singleton(edge)); return edge; *************** *** 239,246 **** // TODO (2): for incremental loading, check if these things are already set - // in the future, all this should be properly modeled by literal nodes - // and corresponding node/edge renderer setups ! if (predicate.equals("http://www.mediavirus.org/graphl#canvasPosition")) { RDFNode snode = getNodeById(subject); if (snode != null){ --- 270,275 ---- // TODO (2): for incremental loading, check if these things are already set ! if (predicate.equals(NS.graphl + "canvasPosition")) { RDFNode snode = getNodeById(subject); if (snode != null){ *************** *** 251,255 **** } else { ! //if (predicate.equals("http://www.mediavirus.org/graphl#connectedTo")) { // get / create node with label subject Node snode; --- 280,284 ---- } else { ! //if (predicate.equals(NS.graphl + "connectedTo")) { // get / create node with label subject Node snode; *************** *** 352,358 **** } - public URL getBaseURL() { - return baseURL; - } - } --- 381,383 ---- |
From: Flo L. <fl...@us...> - 2005-09-07 12:30:16
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25832/src/org/mediavirus/graphl/graph/rdf Modified Files: RDFNode.java RDFGraph.java Log Message: - FEATURE: type menu pops up upon edge creation - BUG: fixed assignment of unique ids to new nodes - BUG: fixed in-place editor for nodes - CODE: loading graphs is now synchronized to avoid loading conflicts - CODE: restoring Graphics transform in GraphlPane after rendering Index: RDFNode.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf/RDFNode.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** RDFNode.java 5 Sep 2005 15:41:23 -0000 1.10 --- RDFNode.java 7 Sep 2005 12:29:55 -0000 1.11 *************** *** 12,15 **** --- 12,16 ---- import org.mediavirus.graphl.graph.DefaultNode; import org.mediavirus.graphl.graph.Node; + import org.mediavirus.graphl.vocabulary.NS; /** *************** *** 47,50 **** --- 48,65 ---- } + public void setId(String id) { + // if a #genid is set, set global number higher than that to avoid duplicates + if (id.contains("#genid")) { + try { + int idnum = Integer.parseInt(id.substring(id.lastIndexOf("#genid")+6)); + if (idnum >= num) num = idnum+1; + } + catch (NumberFormatException nfex) { + // do nothing + } + } + super.setId(id); + } + public String getType() { Node n = getFirstNeighbour("http://www.w3.org/1999/02/22-rdf-syntax-ns#type", true); *************** *** 71,74 **** --- 86,91 ---- RDFEdge typeEdge = new RDFEdge(this, typeNode); typeEdge.setType("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); + // TODO (3) this should probably not be hardcoded to USER + typeEdge.setSource(NS.graphl + "USER"); graph.addElements(null, Collections.singleton(typeEdge)); } catch (Exception e) { Index: RDFGraph.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf/RDFGraph.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** RDFGraph.java 5 Sep 2005 15:40:08 -0000 1.11 --- RDFGraph.java 7 Sep 2005 12:29:55 -0000 1.12 *************** *** 126,130 **** } ! public void readFromFile(String filename) throws IOException { System.out.println("reading file " + filename); File f = new File(filename); --- 126,130 ---- } ! public synchronized void readFromFile(String filename) throws IOException { System.out.println("reading file " + filename); File f = new File(filename); *************** *** 150,154 **** } ! public void readFromURL(URL url){ loadingURL = url; --- 150,154 ---- } ! public synchronized void readFromURL(URL url){ loadingURL = url; *************** *** 317,321 **** public Edge createEdge(Node from, Node to) { RDFEdge edge = new RDFEdge(from, to); ! edge.setSource(loadingURL.toString()); addElements(null, Collections.singleton(edge)); return edge; --- 317,326 ---- public Edge createEdge(Node from, Node to) { RDFEdge edge = new RDFEdge(from, to); ! if (loadingURL != null) { ! edge.setSource(loadingURL.toString()); ! } ! else { ! edge.setSource(NS.graphl + "USER"); ! } addElements(null, Collections.singleton(edge)); return edge; |