/[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.1 by benja, Fri Feb 28 17:41:28 2003 UTC revision 1.2 by benja, Tue Mar 4 10:50:43 2003 UTC
# Line 43  import com.hp.hpl.mesa.rdf.jena.mem.*; Line 43  import com.hp.hpl.mesa.rdf.jena.mem.*;
43   */   */
44  public class Loom {  public class Loom {
45    
46      protected Class[] viewclasses = {      protected View[] views;
         SimpleView.class,  
         WheelView.class  
     };  
47      int viewcur = 0;      int viewcur = 0;
48    
49      public static Model load(String filename) throws RDFException,      public static Model load(String filename) throws RDFException,
# Line 93  public class Loom { Line 90  public class Loom {
90          final TextStyle style = api.getTextStyle("Serif", 0, 12);          final TextStyle style = api.getTextStyle("Serif", 0, 12);
91          final NodeView nodeView = new NodeView() {          final NodeView nodeView = new NodeView() {
92                  public void render(VobScene sc, int into, RDFNode node,                  public void render(VobScene sc, int into, RDFNode node,
93                                     int dir) {                                     Property prop, int dir) {
94                      RectBgVob bg = new RectBgVob();                      RectBgVob bg = new RectBgVob();
95                      if(node.equals(cursor.getRotationNode(dir))) // if selected                      if(node.equals(cursor.getRotationNode(dir))) // if selected
96                          bg.addColor(Color.red);                          bg.addColor(Color.red);
97                      if(!(node instanceof Resource)) // if literal                      if(!(node instanceof Resource)) // if literal
98                          bg.addColor(Color.yellow);                          bg.addColor(Color.yellow);
99                      sc.map.put(bg, into);                      sc.map.put(bg, into);
100    
101                      String s = node.toString();                      String s = node.toString();
102                      if(s.length() > 25) s = s.substring(s.length()-25);                      if(s.length() > 25) s = s.substring(s.length()-25);
103                      sc.map.put(new TextVob(style, s),  
104                                 sc.unitSqCS(into, "text"));                      int unitSqCs = sc.unitSqCS(into, "text");
105                        int propCs = sc.orthoCS(unitSqCs, "property",
106                                                0, 0, -.7f, .7f, .7f);
107                        sc.map.put(new TextVob(style, s), unitSqCs);
108    
109                        if(prop != null) {
110                            s = prop.toString();
111                            if(s.length() > 25) s = s.substring(s.length()-25);
112                            sc.map.put(new TextVob(style, s), propCs);
113                        }
114                  }                  }
115              };              };
116            views = new View[] { new SimpleView(nodeView),
117                                 new WheelView(nodeView) };
118          final Shower s = new Shower() {          final Shower s = new Shower() {
119                  Screen screen;                  Screen screen;
120                  public void setScreen(Screen s) {                  public void setScreen(Screen s) {
# Line 114  public class Loom { Line 123  public class Loom {
123                  public VobScene generate() {                  public VobScene generate() {
124                      VobScene sc = this.screen.window.createVobScene();                      VobScene sc = this.screen.window.createVobScene();
125                      sc.map.put(new SolidBgVob(java.awt.Color.white), 0);                      sc.map.put(new SolidBgVob(java.awt.Color.white), 0);
126                      View view;                      views[viewcur].render(sc, 0, cursor);
                     try {  
                         view = (View) viewclasses[viewcur]  
                             .getConstructor(new Class[] {NodeView.class})  
                             .newInstance(new Object[] {nodeView});  
                     } catch (Exception e) {  
                         e.printStackTrace();  
                         return null;  
                     }  
   
                     view.render(sc, 0, cursor);  
127                      return sc;                      return sc;
128                  }                  }
129                  public void chg() {}                  public void chg() {}
# Line 141  public class Loom { Line 140  public class Loom {
140                      else if(s.equals("Right"))                      else if(s.equals("Right"))
141                          cursor.move(1);                          cursor.move(1);
142                      else if(s.equals("PgUp")) // previous view wanted                      else if(s.equals("PgUp")) // previous view wanted
143                          viewcur = (viewcur-1+viewclasses.length)                          viewcur = (viewcur-1+views.length)
144                              % viewclasses.length;                              % views.length;
145                      else if(s.equals("PgDown")) // next view wanted                      else if(s.equals("PgDown")) // next view wanted
146                          viewcur = (viewcur+1) % viewclasses.length;                          viewcur = (viewcur+1) % views.length;
147    
148                      AbstractUpdateManager.chg();                      AbstractUpdateManager.chg();
149                  }                  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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