/[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.12 by benja, Fri Mar 7 20:48:09 2003 UTC revision 1.13 by benja, Fri Mar 7 21:28:15 2003 UTC
# Line 47  public class Loom { Line 47  public class Loom {
47      protected View[] views;      protected View[] views;
48      int viewcur = 0;      int viewcur = 0;
49    
50        protected ColorScheme colors;
51    
52      public static Model load(String filename) throws RDFException,      public static Model load(String filename) throws RDFException,
53                                                       IOException {                                                       IOException {
54          Model model = new ModelMem();          Model model = new ModelMem();
# Line 71  public class Loom { Line 73  public class Loom {
73              System.exit(1);              System.exit(1);
74          }          }
75    
76          new Loom(file);          new Loom(file, blue);
77      }      }
78    
79      protected NodeView.Nodespec lastFocus;      protected NodeView.Nodespec lastFocus;
80      protected NodeView.Nodespec lastRotation;      protected NodeView.Nodespec lastRotation;
81    
82      public Loom(String file) throws RDFException, IOException {      public Loom(String file, ColorScheme colors0)
83            throws RDFException, IOException {
84    
85            this.colors = colors0;
86    
87          final Model model = load(file);          final Model model = load(file);
88          final Statement stmt = model.listStatements().next();          final Statement stmt = model.listStatements().next();
# Line 118  public class Loom { Line 123  public class Loom {
123                      Property prop = spec.prop;                      Property prop = spec.prop;
124                      int dir = spec.dir;                      int dir = spec.dir;
125    
126                      RectBgVob bg = new RectBgVob();                      if(node instanceof Resource) {
127                      if(spec.equals(cursor.getRotationNodespec(dir))) // if selected                          OvalBgVob bg = new OvalBgVob();
128                          bg.addColor(Color.red);                          if(spec.equals(cursor.getRotationNodespec(dir))) // if selected
129                      if(!(node instanceof Resource)) // if literal                              bg.addColor(colors.getCursorColor());
130                          bg.addColor(Color.yellow);                          sc.map.put(bg, into);
131                      sc.map.put(bg, into);                      } else {
132                            RectBgVob bg = new RectBgVob();
133                            if(spec.equals(cursor.getRotationNodespec(dir))) // if selected
134                                bg.addColor(colors.getCursorColor());
135                            sc.map.put(bg, into);
136                        }
137    
138                      String s = node.toString();                      String s = node.toString();
139                      if(s.length() > 25) s = s.substring(s.length()-25);                      if(s.length() > 27) s = "..." + s.substring(s.length()-24);
140    
141                      int unitSqCs = sc.unitSqCS(into, "text");                      float w = style.getWidth(s, 1);
142                      int propCs = sc.orthoCS(unitSqCs, "property",                      float h = style.getHeight(1);
143                                              0, 0, -.7f, .7f, .7f);                      float x = 125-w/2;
144                      sc.map.put(new TextVob(style, s), unitSqCs);                      float y = 10-h/2;
145    
146                        int textCs = sc.orthoCS(into, "text", 0, x, y, h, h);
147                        int propCs = sc.orthoCS(into, "property",
148                                                0, 0, -h*.8f, h*.8f, h*.8f);
149                        sc.map.put(new TextVob(style, s), textCs);
150    
151                      if(prop != null) {                      if(prop != null) {
152                          s = prop.toString();                          s = prop.toString();
# Line 150  public class Loom { Line 165  public class Loom {
165                  public VobScene generate() {                  public VobScene generate() {
166                      VobScene old = this.screen.getVobSceneForEvents();                      VobScene old = this.screen.getVobSceneForEvents();
167                      VobScene sc = this.screen.window.createVobScene();                      VobScene sc = this.screen.window.createVobScene();
168                      sc.map.put(new SolidBgVob(java.awt.Color.white), 0);                      sc.map.put(new SolidBgVob(colors.getBg()), 0);
169                      views[viewcur].render(sc, 0, cursor);                      views[viewcur].render(sc, 0, cursor);
170    
171                      if(lastFocus != null) {                      if(lastFocus != null) {
# Line 183  public class Loom { Line 198  public class Loom {
198    
199                  public void keystroke(String s) {                  public void keystroke(String s) {
200                      System.out.println("Keystroke: "+s);                      System.out.println("Keystroke: "+s);
201                      if(s.equals("m") || s.equals("n") || s.equals("o"))                      if(s.equals("m") || s.equals("n") || s.equals("o") ||
202                           s.equals("i") || s.equals("Up"))
203                          cursor.rotate(-1);                          cursor.rotate(-1);
204                      else if(s.equals(".") || s.equals("u"))                      else if(s.equals(".") || s.equals("u") ||
205                                s.equals(",") || s.equals("Down"))
206                          cursor.rotate(1);                          cursor.rotate(1);
207                      else if(s.equals("j")) {                      else if(s.equals("j") || s.equals("Left")) {
208                          RDFNode node = cursor.getRotationNode(-1);                          RDFNode node = cursor.getRotationNode(-1);
209                          if(node == null || !(node instanceof Resource)) return;                          if(node == null || !(node instanceof Resource)) return;
210                          lastFocus = new NodeView.Nodespec(cursor.focus);                          lastFocus = new NodeView.Nodespec(cursor.focus);
# Line 198  public class Loom { Line 215  public class Loom {
215                              new NodeView.Nodespec(stmt.getSubject(),                              new NodeView.Nodespec(stmt.getSubject(),
216                                                    stmt.getPredicate(), -1);                                                    stmt.getPredicate(), -1);
217                          cursor.move(-1);                          cursor.move(-1);
218                      } else if(s.equals("l")) {                      } else if(s.equals("l") || s.equals("Right")) {
219                          RDFNode node = cursor.getRotationNode(1);                          RDFNode node = cursor.getRotationNode(1);
220                          if(node == null || !(node instanceof Resource)) return;                          if(node == null || !(node instanceof Resource)) return;
221                          lastFocus = new NodeView.Nodespec(cursor.focus);                          lastFocus = new NodeView.Nodespec(cursor.focus);
# Line 254  public class Loom { Line 271  public class Loom {
271                  }                  }
272              });              });
273      }      }
274    
275        public interface ColorScheme {
276            public Color getBg();
277            public Color getCursorColor();
278        }
279    
280        public static class LightColorScheme implements ColorScheme {
281            float hue;
282            public LightColorScheme(float hue) { this.hue = hue; }
283            public Color getBg() {
284                return Color.getHSBColor(hue, 0.1f, 1f);
285            }
286            public Color getCursorColor() {
287                return Color.getHSBColor(hue, 0.5f, 1f);
288            }
289        }
290    
291        public static final ColorScheme
292            green = new LightColorScheme(0.233f),
293            blue = new LightColorScheme(0.555f);
294  }  }

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

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