/[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.20 by benja, Sun Mar 9 01:23:15 2003 UTC revision 1.21 by benja, Sun Mar 9 02:01:44 2003 UTC
# Line 30  import gzz.vob.*; Line 30  import gzz.vob.*;
30  import gzz.vob.impl.DefaultVobMatcher;  import gzz.vob.impl.DefaultVobMatcher;
31  import gzz.vob.vobs.*;  import gzz.vob.vobs.*;
32    
33  import java.awt.Color;  import java.awt.*;
34    import java.awt.event.ActionEvent;
35    import java.awt.event.ActionListener;
36  import java.awt.event.MouseEvent;  import java.awt.event.MouseEvent;
37  import java.io.*;  import java.io.*;
38  import java.util.*;  import java.util.*;
39    import java.util.List;
40    
41  import com.hp.hpl.mesa.rdf.jena.model.*;  import com.hp.hpl.mesa.rdf.jena.model.*;
42  import com.hp.hpl.mesa.rdf.jena.mem.*;  import com.hp.hpl.mesa.rdf.jena.mem.*;
# Line 52  public class Loom { Line 55  public class Loom {
55      protected Model model;      protected Model model;
56      protected NamespaceMap names;      protected NamespaceMap names;
57    
58      public void load(String filename) throws RDFException,      protected Cursor cursor;
59                                               IOException,  
60                                               org.xml.sax.SAXException {      public void load(File file) throws RDFException,
61                                           IOException,
62                                           org.xml.sax.SAXException {
63          model = new ModelMem();          model = new ModelMem();
64          model.read(new java.io.FileReader(filename), "");          model.read(new java.io.FileReader(file), "");
65    
66          names = new NamespaceMap();          names = new NamespaceMap();
67          names.loadMappings(new java.io.FileReader(filename));          names.loadMappings(new java.io.FileReader(file));
68    
69            Statement stmt = model.listStatements().next();
70            cursor =
71                new Cursor(SimpleOrder.subjOrder, SimpleOrder.objOrder,
72                           StatementSelector.simpleSelector,
73                           stmt.getSubject(), 1, stmt.getObject());
74      }      }
75    
76      public static void main(String[] args) throws RDFException, IOException,      public static void main(String[] args) throws RDFException, IOException,
77                                                    org.xml.sax.SAXException {                                                    org.xml.sax.SAXException {
78          String file = "";          String file = null;
79    
80          System.err.println("Fenfire Loom starting...");          System.err.println("Fenfire Loom starting...");
81    
82          if(args.length < 1) {          if(args.length == 1) {
             System.err.println("Please give as an argument a filename of "+  
                                "the RDF file to load.");  
             System.exit(1);  
         } else if(args.length == 1) {  
83              file = args[0];              file = args[0];
84          } else {          } else if(args.length > 1) {
85              System.err.println("You gave "+args.length+" arguments.");              System.err.println("You gave "+args.length+" arguments.");
86              System.err.println("Please only give one filename of an RDF file");              System.err.println("Please only give one filename of an RDF file");
87              System.exit(1);              System.exit(1);
# Line 86  public class Loom { Line 93  public class Loom {
93      protected NodeView.Nodespec lastFocus;      protected NodeView.Nodespec lastFocus;
94      protected NodeView.Nodespec lastRotation;      protected NodeView.Nodespec lastRotation;
95    
96        protected Frame frame;
97        protected FileDialog fileDialog;
98    
99      public Loom(String file, ColorScheme colors0)      public Loom(String file, ColorScheme colors0)
100          throws RDFException, IOException, org.xml.sax.SAXException {          throws RDFException, IOException, org.xml.sax.SAXException {
101    
102          load(file);          if(file != null)
103                load(new File(file));
104          this.colors = colors0;          this.colors = colors0;
105    
106          final Statement stmt = model.listStatements().next();          final MenuBar mBar = new MenuBar();
107          final GraphicsAPI api = GraphicsAPI.getInstance();          Menu mFile = new Menu("File"); mBar.add(mFile);
108            MenuItem mOpen = new MenuItem("Open..."); mFile.add(mOpen);
109            MenuItem mQuit = new MenuItem("Quit"); mFile.add(mQuit);
110            /*Menu mView = new Menu("View"); mBar.add(mView);
111            MenuItem mSimple = new CheckboxMenuItem("Simple View");
112            MenuItem mWheel = new CheckboxMenuItem("Wheel View");
113            mView.add(mSimple); mView.add(mWheel);*/
114    
115            mOpen.addActionListener(new ActionListener() {
116                    public void actionPerformed(ActionEvent _) {
117                        fileDialog.show();
118                        if(fileDialog.getFile() != null) {
119                            try {
120                                load(new File(fileDialog.getDirectory(), fileDialog.getFile()));
121                            } catch(Exception e) {
122                                e.printStackTrace();
123                            }
124                        }
125                        AbstractUpdateManager.chg();
126                    }
127                });
128    
129          final Cursor cursor =          mQuit.addActionListener(new ActionListener() {
130              new Cursor(SimpleOrder.subjOrder, SimpleOrder.objOrder,                  public void actionPerformed(ActionEvent _) {
131                         StatementSelector.simpleSelector,                      System.exit(0);
132                         stmt.getSubject(), 1, stmt.getObject());                  }
133                });
134    
135            final GraphicsAPI api = GraphicsAPI.getInstance();
136    
137          final TextStyle style = api.getTextStyle("Serif", 0, 12);          final TextStyle style = api.getTextStyle("Serif", 0, 12);
138          final NodeView nodeView = new NodeView() {          final NodeView nodeView = new NodeView() {
# Line 157  public class Loom { Line 191  public class Loom {
191                      VobScene old = this.screen.getVobSceneForEvents();                      VobScene old = this.screen.getVobSceneForEvents();
192                      VobScene sc = this.screen.window.createVobScene();                      VobScene sc = this.screen.window.createVobScene();
193                      sc.map.put(new SolidBgVob(colors.getBg()), 0);                      sc.map.put(new SolidBgVob(colors.getBg()), 0);
194    
195                        if(model == null) return sc;
196    
197                      views[viewcur].render(sc, 0, cursor);                      views[viewcur].render(sc, 0, cursor);
198    
199                      if(lastFocus != null) {                      if(lastFocus != null) {
# Line 189  public class Loom { Line 226  public class Loom {
226    
227                  public void keystroke(String s) {                  public void keystroke(String s) {
228                      System.out.println("Keystroke: "+s);                      System.out.println("Keystroke: "+s);
229                        if(model == null) return;
230                                            
231                      if(viewcur == 0) {                      if(viewcur == 0) {
232                          if(s.equals("u") || s.equals("o"))                          if(s.equals("u") || s.equals("o"))
# Line 268  public class Loom { Line 306  public class Loom {
306          api.startUpdateManager(new Runnable() {          api.startUpdateManager(new Runnable() {
307                  public void run() {                  public void run() {
308                      Screen scr = new Screen(api.createWindow(), b, s);                      Screen scr = new Screen(api.createWindow(), b, s);
309                        frame = ((gzz.client.awt.FrameScreen)scr.window)
310                            .getFrame();
311                        fileDialog = new FileDialog(frame, "Open",
312                                                    FileDialog.LOAD);
313                        frame.setMenuBar(mBar);
314                      AbstractUpdateManager.addWindow(scr);                      AbstractUpdateManager.addWindow(scr);
315                      scr.window.setLocation(0, 0, 300, 300);                      scr.window.setLocation(0, 0, 300, 300);
316                      AbstractUpdateManager.chg();                      AbstractUpdateManager.chg();

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

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