gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] fenfire ./TODO-loom org/fenfire/loom/Loom.java ...


From: Benja Fallenstein
Subject: [Gzz-commits] fenfire ./TODO-loom org/fenfire/loom/Loom.java ...
Date: Mon, 10 Mar 2003 16:54:10 -0500

CVSROOT:        /cvsroot/fenfire
Module name:    fenfire
Changes by:     Benja Fallenstein <address@hidden>      03/03/10 16:54:10

Modified files:
        .              : TODO-loom 
        org/fenfire/loom: Loom.java StatementSelector.java 

Log message:
        select way to show nodes through view menu

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/TODO-loom.diff?tr1=1.31&tr2=1.32&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/loom/Loom.java.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/loom/StatementSelector.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: fenfire/TODO-loom
diff -u fenfire/TODO-loom:1.31 fenfire/TODO-loom:1.32
--- fenfire/TODO-loom:1.31      Mon Mar 10 06:20:44 2003
+++ fenfire/TODO-loom   Mon Mar 10 16:54:09 2003
@@ -12,27 +12,25 @@
 
 
 0.1: Useful RDF browser
-    - fix bug: screen is not refreshed after an RDF file
-      has been loaded through File/Open
+    - fix bug: any event on the AWT thread does not
+      refresh the screen, even if AbstractUpdMgr.chg()
+      is called
     - fix bug: when there are two equal literals connected
       to a node, clicking on one may focus the other.
+    - fix bug: when Cursor.java has an insane rotation
+      (too high or too small), it should fix itself
+      when move() is called.
+
+    - find current bottleneck when viewing big graphs
+      like the w3c SWAD chart & fix
 
     - views proportional to window size
     - in the Wheel views, have a maximum angle, so that
       if only three nodes are shown, the angles still
-      aren't greater than 45 degs or so
-
-    - Selecting view through the PUI menu bar
+      aren't greater than 20(?) degs or so
 
-    - Separate window with a multi-selectable listbox
-      for choosing which properties are shown
-    - A way to select how resources are shown: For every
-      resource type in the graph, either "by URI" or
-      "by [property]" (one option for every property
-      with literals as objects). E.g. if rdf:label is
-      chosen for a type, resources of that type aren't
-      shown as URIs; instead, the oval contains the
-      rdf:label of that node.
+    - README update to explain property selection
+      and the View menu
 
     - JAR target; java -jar loom.jar should start the client
 
Index: fenfire/org/fenfire/loom/Loom.java
diff -u fenfire/org/fenfire/loom/Loom.java:1.23 
fenfire/org/fenfire/loom/Loom.java:1.24
--- fenfire/org/fenfire/loom/Loom.java:1.23     Mon Mar 10 14:44:01 2003
+++ fenfire/org/fenfire/loom/Loom.java  Mon Mar 10 16:54:10 2003
@@ -31,9 +31,7 @@
 import gzz.vob.vobs.*;
 
 import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseEvent;
+import java.awt.event.*;
 import java.io.*;
 import java.util.*;
 import java.util.List;
@@ -53,33 +51,117 @@
     protected ColorScheme colors;
 
     protected Model model;
+    protected Property typeProp;
     protected NamespaceMap names;
 
     protected Cursor cursor;
 
+    protected boolean isNumberProp(Property p) {
+       return p.toString().startsWith(
+            "http://www.w3.org/1999/02/22-rdf-syntax-ns#_";);
+    }
+
     public void load(File file) throws RDFException, 
                                       IOException, 
                                       org.xml.sax.SAXException {
        model = new ModelMem();
+       typeProp = 
model.createProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#";,
+                                       "type");
        model.read(new java.io.FileReader(file), "");
 
        names = new NamespaceMap();
        names.loadMappings(new java.io.FileReader(file));
 
+
+       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);
+       Set classes = new TreeSet(compareByAbbrev);
+       
+       for(StmtIterator iter = model.listStatements(); iter.hasNext();) {
+           Statement stmt = iter.next();
+           Property p = stmt.getPredicate();
+           if(!isNumberProp(p)) props.add(p);
+           if(p.toString().equals(
+               "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";) &&
+              stmt.getObject() instanceof Resource)
+               classes.add(stmt.getObject());
+       }
+       properties = new ArrayList(props);
+
+       propList.setMultipleMode(true);
+       propList.removeAll();
+       propList.add("rdf:_n properties");
+       propList.select(0);
+       int i=1;
+       for(Iterator iter=properties.iterator(); iter.hasNext();) {
+           Property p = (Property)iter.next();
+           propList.add(names.getAbbrev(p.toString()));
+           propList.select(i);
+           i++;
+       }
+
        Statement stmt = model.listStatements().next();
        cursor = 
            new Cursor(SimpleOrder.subjOrder, SimpleOrder.objOrder, 
-                      StatementSelector.simpleSelector,
+                      new StatementSelector.SimpleSelector() {
+                          protected boolean accept(Statement s) {
+                              Property p = s.getPredicate();
+                              if(isNumberProp(p))
+                                  return propList.isIndexSelected(0);
+                              int i = properties.indexOf(p);
+                              return propList.isIndexSelected(i+1);
+                          }
+                      },
                       stmt.getSubject(), 1, stmt.getObject());
+
+       showClassMenu.removeAll();
+       showClassBy.clear();
+       for(Iterator j=classes.iterator(); j.hasNext();) {
+           final Resource cls = (Resource)j.next();
+           Menu menu = 
+               new Menu(names.getAbbrev(cls.toString()));
+           showClassMenu.add(menu);
+           
+           MenuItem byURI = new MenuItem("by URI"); menu.add(byURI);
+           byURI.addActionListener(new ActionListener() {
+                   public void actionPerformed(ActionEvent _) {
+                       showClassBy.remove(cls);
+                   }
+               });
+           MenuItem sep = new MenuItem("-"); menu.add(sep);
+           for(Iterator k=properties.iterator(); k.hasNext();) {
+               final Property prop = (Property)k.next();
+               MenuItem mi = new MenuItem("by 
"+names.getAbbrev(prop.toString()));
+               menu.add(mi);
+               mi.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent _) {
+                           showClassBy.put(cls, prop);
+                           AbstractUpdateManager.chg();
+                       }
+                   });
+           }
+       }
     }
 
+    protected List properties;
+    protected Frame propFrame = new Frame("Properties");
+    protected java.awt.List propList = new java.awt.List();
+
     public static void main(String[] args) throws RDFException, IOException,
                                                  org.xml.sax.SAXException {
        String file = null;
 
        System.err.println("Fenfire Loom starting...");
 
-       if(args.length == 1) {
+       if(args.length == 1 && !args[0].trim().equals("")) {
            file = args[0];
        } else if(args.length > 1) {
            System.err.println("You gave "+args.length+" arguments.");
@@ -96,6 +178,9 @@
     protected Frame frame;
     protected FileDialog fileDialog;
 
+    protected Map showClassBy = new HashMap();
+    protected Menu showClassMenu = new Menu("Show class");
+
     public Loom(String file, ColorScheme colors0) 
        throws RDFException, IOException, org.xml.sax.SAXException {
 
@@ -107,10 +192,12 @@
        Menu mFile = new Menu("File"); mBar.add(mFile);
        MenuItem mOpen = new MenuItem("Open..."); mFile.add(mOpen);
        MenuItem mQuit = new MenuItem("Quit"); mFile.add(mQuit);
-       /*Menu mView = new Menu("View"); mBar.add(mView);
-       MenuItem mSimple = new CheckboxMenuItem("Simple View"); 
-       MenuItem mWheel = new CheckboxMenuItem("Wheel View");
-       mView.add(mSimple); mView.add(mWheel);*/
+       Menu mView = new Menu("View"); mBar.add(mView);
+       MenuItem mSimple = new /*Checkbox*/MenuItem("Simple View"); 
+       MenuItem mWheel = new /*Checkbox*/MenuItem("Wheel View");
+       mView.add(mSimple); mView.add(mWheel);
+       mView.add(new MenuItem("-"));
+       mView.add(showClassMenu);
 
        mOpen.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent _) {
@@ -132,6 +219,31 @@
                }
            });
 
+       mSimple.addActionListener(new ActionListener() {
+               public void actionPerformed(ActionEvent _) {
+                   viewcur = 0;
+                   AbstractUpdateManager.chg();
+               }
+           });
+
+       mWheel.addActionListener(new ActionListener() {
+               public void actionPerformed(ActionEvent _) {
+                   viewcur = 1;
+                   AbstractUpdateManager.chg();
+               }
+           });
+
+       propFrame.add(propList);
+       propList.addItemListener(new ItemListener() {
+               public void itemStateChanged(ItemEvent e) {
+                   // the rotation cannot be sanely kept
+                   // when properties are added or removed
+                   cursor.rotation = 0; 
+                   AbstractUpdateManager.chg();
+               }
+           });
+       propFrame.setVisible(true);
+
        final GraphicsAPI api = GraphicsAPI.getInstance();
 
        final TextStyle style = api.getTextStyle("Serif", 0, 12);
@@ -154,7 +266,27 @@
                    }
 
                    String s = node.toString();
-                   if(node instanceof Resource) s = names.getAbbrev(s);
+                   if(node instanceof Resource) {
+                       s = names.getAbbrev(s);
+                       String t = s;
+
+                       try {
+                           Statement typeStmt =
+                               ((Resource)node).getProperty(typeProp);
+
+                           RDFNode type = typeStmt.getObject();
+                           Property by = (Property)showClassBy.get(type);
+                           if(by != null) {
+                               Statement byStmt = 
((Resource)node).getProperty(by);
+                               if(byStmt.getObject() instanceof Literal)
+                                   s = byStmt.getString();
+                               else
+                                   s = 
names.getAbbrev(byStmt.getObject().toString());
+                           }
+                       } catch(RDFException e) {
+                           s = t;
+                       }
+                   }
                    if(s.length() > 27) {
                        if(node instanceof Literal)
                            s = s.substring(0, 24) + "...";
Index: fenfire/org/fenfire/loom/StatementSelector.java
diff -u fenfire/org/fenfire/loom/StatementSelector.java:1.2 
fenfire/org/fenfire/loom/StatementSelector.java:1.3
--- fenfire/org/fenfire/loom/StatementSelector.java:1.2 Sat Mar  8 17:22:59 2003
+++ fenfire/org/fenfire/loom/StatementSelector.java     Mon Mar 10 16:54:10 2003
@@ -48,12 +48,17 @@
      *  ALL triples in the graph.
      */
     class SimpleSelector implements StatementSelector {
+       protected boolean accept(Statement s) {
+           return true;
+       }
+
        public Collection getConnections(Resource focus, int dir) {
            try {
                List nodes = new ArrayList();
                StmtIterator i = focus.getModel().listStatements();
                for(; i.hasNext();) {
                    Statement stmt = i.next();
+                   if(!accept(stmt)) continue;
                    if(dir < 0) {
                        if(stmt.getObject().equals(focus)) 
                            nodes.add(stmt);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]