/[fenfire]/fenfire/org/fenfire/loom/Loom.java
ViewVC logotype

Diff of /fenfire/org/fenfire/loom/Loom.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.41 by benja, Fri Mar 21 14:50:32 2003 UTC revision 1.42 by benja, Sat Mar 22 20:18:55 2003 UTC
# Line 154  public class Loom { Line 154  public class Loom {
154    
155          final GraphicsAPI api = GraphicsAPI.getInstance();          final GraphicsAPI api = GraphicsAPI.getInstance();
156    
157          final TextStyle style = api.getTextStyle("Serif", 0, 12);          view = new ViewSettings(new DefaultNodeView(this));
         view = new ViewSettings(new NodeView() {  
                 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(cursor.getRotationNodespec(dir));  
                     if(node instanceof Resource) {  
                         OvalBgVob bg = new OvalBgVob(new Color(102, 255, 102), selected,  
                                                      colors.getCursorBorderColor());  
                         sc.map.put(bg, into);  
                     } else {  
                         RectBgVob bg = new RectBgVob(new Color(255, 204, 51), selected,  
                                                      colors.getCursorBorderColor());  
                         sc.map.put(bg, into);  
                     }  
   
                     String s;  
                     boolean 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)  
                             s = cursor.names.getAbbrev(s);  
                         else  
                             s = "";  
                         String t = s;  
   
                         try {  
                             Property by;  
   
                             try {  
                                 Statement typeStmt =  
                                     ((Resource)node).getProperty(rdf.type);  
                                 RDFNode type = typeStmt.getObject();  
                                 by = (Property)showClassBy.get(type);  
                             } catch(RDFException _) {  
                                 by = showNoClassBy;  
                             }  
   
                             if(by != null) {  
                                 Statement byStmt = ((Resource)node).getProperty(by);  
                                 if(byStmt.getObject() instanceof Literal)  
                                     s = byStmt.getString();  
                                 else  
                                     s = cursor.names.getAbbrev(byStmt.getObject().toString());  
                               
                                 isByClass = true;  
                             }  
                         } catch(RDFException e) {  
                             s = t;  
                         }  
                     }  
   
                     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", 0, x, y, h, h);  
                     sc.map.put(new TextVob(style, s), textCs);  
   
                     if(prop != null) {  
                         s = prop.toString();  
                         s = cursor.names.getAbbrev(s);  
                         if(s.length() > 15) s = s.substring(s.length()-15);  
                         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);  
                     }  
                 }  
             });  
158          final Shower s = new Shower() {          final Shower s = new Shower() {
159                  Screen screen;                  Screen screen;
160                  public void setScreen(Screen s) {                  public void setScreen(Screen s) {
# Line 283  public class Loom { Line 193  public class Loom {
193                  }                  }
194                  public void chg() {}                  public void chg() {}
195              };              };
196          final Binder b = new Binder() {          final Binder b = new LoomBindings(this);
                 Screen screen;  
   
                 public void keystroke(String s) {  
                     System.out.println("Keystroke: "+s);  
                     if(s.equals("Ctrl-Q"))  
                         System.exit(0);  
                     if(model == null) return;  
   
                     if(view.isWheelView()) {  
                         if(s.equals("i") || s.equals("Up") ||  
                            s.equals(",") || s.equals("Down")) return;  
                         if(s.equals("m") || s.equals("n") || s.equals("o"))  
                             s = "Up";  
                         else if(s.equals("u") || s.equals("."))  
                             s = "Down";  
                     } else if(view.isSimpleView()) {  
                         if(s.equals("u") || s.equals("o"))  
                             s = "Up";  
                         else if(s.equals("m") || s.equals("n") || s.equals("."))  
                             s = "Down";  
                     }  
   
                     if(s.equals("Ctrl-G"))  
                         showGoToDialog();  
                     else if(s.equals("i") || s.equals("Up"))  
                         cursor.rotate(-1);  
                     else if(s.equals(",") || s.equals("Down"))  
                         cursor.rotate(1);  
                     else if(s.equals("j") || s.equals("Left")) {  
                         RDFNode node = cursor.getRotationNode(-1);  
                         if(node == null || !(node instanceof Resource)) return;  
                         lastFocus = new NodeView.Nodespec(cursor.focus);  
                         List l = new ArrayList(cursor.getConnections(-1));  
                         Statement stmt =  
                             (Statement)l.get(cursor.getRotationIndex(-1));  
                         lastRotation =  
                             new NodeView.Nodespec(stmt.getSubject(),  
                                                   stmt.getPredicate(), -1);  
                         cursor.move(-1);  
                     } else if(s.equals("l") || s.equals("Right")) {  
                         RDFNode node = cursor.getRotationNode(1);  
                         if(node == null || !(node instanceof Resource)) return;  
                         lastFocus = new NodeView.Nodespec(cursor.focus);  
                         List l = new ArrayList(cursor.getConnections(1));  
                         Statement stmt =  
                             (Statement)l.get(cursor.getRotationIndex(1));  
                         lastRotation =  
                             new NodeView.Nodespec(stmt.getObject(),  
                                                   stmt.getPredicate(), 1);  
                         cursor.move(1);  
                     } else if(s.equals("PgUp")) // previous view wanted  
                         view.changeView(-1);  
                     else if(s.equals("PgDown")) // next view wanted  
                         view.changeView(1);  
   
                     AbstractUpdateManager.chg();  
                 }  
                 public void mouse(MouseEvent m) {  
                     if(m.getID() != m.MOUSE_CLICKED) return;  
   
                     VobScene vs = screen.getVobSceneForEvents();  
                     int cs = vs.coords.getCSAt(0, m.getX(), m.getY(),  
                                                null);  
                     if(cs < 0) return;  
                     Object key = vs.matcher.getKey(cs);  
                     NodeView.Nodespec spec = (NodeView.Nodespec)key;  
                     if((m.getModifiers() & m.BUTTON3_MASK) > 0 ||  
                        spec.node instanceof Literal) {  
                         cursor.set(cursor.focus, spec.dir, spec.node);  
                         AbstractUpdateManager.chg();  
                     } else {  
                         lastFocus = new NodeView.Nodespec(cursor.focus);  
                         lastRotation = spec;  
                         cursor.set((Resource)spec.node, -spec.dir, cursor.focus);  
                         AbstractUpdateManager.chg();  
                     }  
                 }  
                 public void setScreen(Screen s) { this.screen = s; }  
                 public void timeout(Object id) {}  
                 public void windowClosed() {  
                     System.exit(0);  
                 }  
             };  
197    
198          api.startUpdateManager(new Runnable() {          api.startUpdateManager(new Runnable() {
199                  public void run() {                  public void run() {

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.42

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26