gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] CVSROOT: /cvsroot/loom


From: Benja Fallenstein
Subject: [Gzz-commits] CVSROOT: /cvsroot/loom
Date: Sat, 05 Jul 2003 16:40:42 -0400

Module name:    loom
Branch:         benja_2003-04-29_loommatcher_untested
Changes by:     Benja Fallenstein <address@hidden>      03/07/05 16:40:42
Reply-to: address@hidden

CVSROOT:        /cvsroot/loom
Module name:    loom
Branch:         benja_2003-04-29_loommatcher_untested
Changes by:     Benja Fallenstein <address@hidden>      03/07/05 16:40:42

Modified files:
        org/fenfire/loom: DefaultNodeView.java WheelView.java 

Log message:
        show new text during animation

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/loom/loom/org/fenfire/loom/DefaultNodeView.java.diff?only_with_tag=benja_2003-04-29_loommatcher_untested&tr1=1.3&tr2=1.3.2.1&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/loom/loom/org/fenfire/loom/WheelView.java.diff?only_with_tag=benja_2003-04-29_loommatcher_untested&tr1=1.8.2.1&tr2=1.8.2.2&r1=text&r2=text

Patches:
Index: loom/org/fenfire/loom/DefaultNodeView.java
diff -u /dev/null loom/org/fenfire/loom/DefaultNodeView.java:1.3.2.1
--- /dev/null   Sat Jul  5 16:40:42 2003
+++ loom/org/fenfire/loom/DefaultNodeView.java  Sat Jul  5 16:40:42 2003
@@ -0,0 +1,181 @@
+/*
+DefaultNodeView.java
+ *
+ *    Copyright (c) 2003 by Benja Fallenstein
+ *
+ *    This file is part of Fenfire.
+ *    
+ *    Fenfire is free software; you can redistribute it and/or modify it under
+ *    the terms of the GNU Lesser General Public License as published by
+ *    the Free Software Foundation; either version 2 of the License, or
+ *    (at your option) any later version.
+ *    
+ *    Fenfire is distributed in the hope that it will be useful, but WITHOUT
+ *    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ *    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
+ *    Public License for more details.
+ *    
+ *    You should have received a copy of the GNU Lesser General
+ *    Public License along with Fenfire; if not, write to the Free
+ *    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ *    MA  02111-1307  USA
+ *
+ */
+/*
+ * Written by Benja Fallenstein
+ */
+package org.fenfire.loom;
+import org.nongnu.libvob.*;
+import org.nongnu.libvob.vobs.*;
+
+import java.awt.Color;
+import java.util.*;
+import java.util.List;
+
+import com.hp.hpl.mesa.rdf.jena.model.*;
+
+/** The default node view for Loom.
+ *  Not tested at this time [XXX fix!!!].
+ */
+public class DefaultNodeView implements NodeView {
+    protected Loom loom;
+    protected TextStyle style;
+
+    protected Color resourceColor = new Color(102, 255, 102);
+    protected Color literalColor = new Color(255, 204, 51);
+
+    protected OvalBgVob resourceVob;
+    protected RectBgVob literalVob;
+
+    public static final Object TEXT_CS_KEY = "text";
+    
+    public DefaultNodeView(Loom loom) {
+       this.loom = loom;
+       style = GraphicsAPI.getInstance()
+           .getTextStyle("Serif", 0, 12);
+       resourceVob = new OvalBgVob(Color.white, false, null);
+       resourceVob.addColor(resourceColor);
+        literalVob = new RectBgVob(Color.white, false, null);
+       literalVob.addColor(literalColor);
+    }
+
+    protected Vob getBgVob(boolean isResource, boolean isSelected,
+                          boolean isMarked) {
+       if(!isSelected && !isMarked)
+           return isResource ? (Vob)resourceVob : (Vob)literalVob;
+
+       Color bg = isSelected ? loom.colors.getCursorBorderColor() : null;
+       if(isResource) {
+           OvalBgVob vob = new OvalBgVob(Color.white, isSelected, bg);
+           vob.addColor(resourceColor);
+           if(isMarked) vob.addColor(Color.red);
+           return vob;
+       } else {
+           RectBgVob vob = new RectBgVob(Color.white, isSelected, bg);
+           vob.addColor(literalColor);
+           if(isMarked) vob.addColor(Color.red);
+           return vob;
+       }
+    }
+                          
+
+    /** Argh-- global variable because getText()
+     *  can only return one thing :-( :-(
+     */
+    protected boolean isByClass;
+
+    public String getText(RDFNode node, boolean abbreviate) {
+       String s;
+       isByClass = false;
+       if(node instanceof Literal) {
+           try {
+               s = ((Literal)node).getString();
+           } catch(RDFException e) {
+               System.out.println(e);
+               s = "<Error>";
+           }
+       } else {
+           s = ((Resource)node).getURI();
+           if(s != null && abbreviate)
+               s = loom.cursor.names.getAbbrev(s);
+           else if(s == null)
+               s = "";
+           String t = s;
+           
+           try {
+               Property by;
+               
+               try {
+                   Statement typeStmt =
+                       ((Resource)node).getProperty(loom.rdf.type);
+                   RDFNode type = typeStmt.getObject();
+                   by = (Property)loom.showClassBy.get(type);
+               } catch(RDFException _) {
+                   by = loom.showNoClassBy;
+               }
+               
+               if(by != null) {
+                   Statement byStmt = ((Resource)node).getProperty(by);
+                   if(byStmt.getObject() instanceof Literal)
+                       s = byStmt.getString();
+                   else if(abbreviate)
+                       s = 
loom.cursor.names.getAbbrev(byStmt.getObject().toString());
+                   else
+                       s = byStmt.getObject().toString();
+                   
+                   isByClass = true;
+               }
+           } catch(RDFException e) {
+               s = t;
+           }
+       }
+
+       return s;
+    }
+
+    public void render(VobScene sc, int into, Nodespec spec) {
+       RDFNode node = spec.node;
+       Property prop = spec.prop;
+       int dir = spec.dir;
+       
+       boolean selected = spec.equals(loom.cursor.getRotationNodespec(dir));
+       sc.map.put(getBgVob(node instanceof Resource, selected,
+                           loom.markedNodes.contains(node)), into);
+                           
+       String s = getText(node, true);
+       
+       if(s.length() > 17) {
+           if(node instanceof Literal || isByClass)
+               s = s.substring(0, 14) + "...";
+           else
+               s = "..." + s.substring(s.length()-14);
+       }
+       
+       float w = style.getWidth(s, 1);
+       float h = style.getHeight(1);
+       float x = 75-w/2;
+       float y = 10-h/2;
+       
+       int textCs = sc.orthoCS(into, TEXT_CS_KEY, 0, x, y, h, h);
+       sc.map.put(new TextVob(style, s), textCs);
+       
+       if(prop != null) {
+           s = prop.toString();
+           s = loom.cursor.names.getAbbrev(s);
+           if(s.length() > 15) s = s.substring(s.length()-15);
+           if(dir < 0)
+               s = "has "+s;
+           else
+               s = "is "+s;
+
+           if(dir > 0)
+               x = 0;
+           else
+               x = 150 - style.getWidth(s, .8f);
+           h = style.getHeight(.8f);
+           int propCs = sc.orthoCS(into, "property", 
+                                   0, x, -h, h, h);
+           sc.map.put(new TextVob(style, s), propCs);
+       }
+    }
+}
Index: loom/org/fenfire/loom/WheelView.java
diff -u loom/org/fenfire/loom/WheelView.java:1.8.2.1 
loom/org/fenfire/loom/WheelView.java:1.8.2.2
--- loom/org/fenfire/loom/WheelView.java:1.8.2.1        Tue Apr 29 14:07:15 2003
+++ loom/org/fenfire/loom/WheelView.java        Sat Jul  5 16:40:42 2003
@@ -122,6 +122,7 @@
                    if(dir > 0) stub = posStub;
                    else stub = negStub;
                    sc.map.put(stub, focusCs, cs2);
+                   sc.orthoCS(cs2, DefaultNodeView.TEXT_CS_KEY, 0, 0, 0, 1, 1);
                } else if (depth < maxDepth) {
                    sc.coords.activate(cs2);
                    nodeView.render(sc, cs2, spec);




reply via email to

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