gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] fenfire ./build.xml org/fenfire/demo/buoyoing.p...


From: Matti Katila
Subject: [Gzz-commits] fenfire ./build.xml org/fenfire/demo/buoyoing.p...
Date: Wed, 07 May 2003 00:08:06 -0400

CVSROOT:        /cvsroot/fenfire
Module name:    fenfire
Changes by:     Matti Katila <address@hidden>   03/05/07 00:08:05

Modified files:
        .              : build.xml 
        org/fenfire/demo: buoyoing.py 
        org/fenfire/modules/pp: RSTActions.java RSTActionsImpl.java 
                                RSTActionsImpl.test 
        org/fenfire/util: AlphContent.java RDFUtil.java 
        org/fenfire/view: FenPDFContext.java TextNodeView.java 
        org/fenfire/vocab: RST.java 
Added files:
        org/fenfire/modules/pp: RSTUtil.java RSTUtilImpl.java 
        org/fenfire/view: RSTText.java 

Log message:
        more text editability

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/build.xml.diff?tr1=1.35&tr2=1.36&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/demo/buoyoing.py.diff?tr1=1.42&tr2=1.43&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/modules/pp/RSTUtil.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/modules/pp/RSTUtilImpl.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/modules/pp/RSTActions.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/modules/pp/RSTActionsImpl.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/modules/pp/RSTActionsImpl.test.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/util/AlphContent.java.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/util/RDFUtil.java.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/RSTText.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/FenPDFContext.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/TextNodeView.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/vocab/RST.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: fenfire/build.xml
diff -u fenfire/build.xml:1.35 fenfire/build.xml:1.36
--- fenfire/build.xml:1.35      Thu May  1 20:22:40 2003
+++ fenfire/build.xml   Wed May  7 00:08:04 2003
@@ -32,7 +32,7 @@
 
     <target name="compilermi" depends="compilejava">
        <rmic base="${build}" includes="**/PPActionsImpl*.class"/>
-       <rmic base="${build}" includes="**/RSTActionsImpl*.class"/>
+       <rmic base="${build}" includes="**/RST*Impl*.class"/>
     </target>
 
     <target name="test" depends="test-awt,test-gl"/>
Index: fenfire/org/fenfire/demo/buoyoing.py
diff -u fenfire/org/fenfire/demo/buoyoing.py:1.42 
fenfire/org/fenfire/demo/buoyoing.py:1.43
--- fenfire/org/fenfire/demo/buoyoing.py:1.42   Sun May  4 21:38:49 2003
+++ fenfire/org/fenfire/demo/buoyoing.py        Wed May  7 00:08:04 2003
@@ -98,7 +98,7 @@
     ppAct.assocNotes(noteB1, 1, noteA1)
 
     canvas = rst.newRSTCanvas()
-    parag = rst.newParagraph(canvas, 10,10)
+    parag = rst.newParagraph(canvas, 200, 10,10)
     senten = rst.newSentence(parag,0)
     note = ff.swamp.Nodes.N()
     ff.util.AlphContent(fen).setText(note, 'This is rst canvas test', 1)
@@ -110,7 +110,7 @@
 
 vob.view.FisheyeState.dbg = 1
 textstyle = vob.GraphicsAPI.getInstance().getTextStyle("sans", 0, 24)
-textnodeview = ff.view.TextNodeView(fen.txtfunc, textstyle, 1)
+textnodeview = ff.view.RSTText(fen.txtfunc, textstyle, 1)
 pagenodeview = ff.view.PageNodeView(fen.txtfunc)
 dispnodeview = ff.view.DispatchingNodeView(fen.txtfunc,
                                            textnodeview,
@@ -124,12 +124,15 @@
 ff.view.buoy.NodeType2D.effigy = 0
 ff.view.buoy.NodeType2DFull.effigy = 0
 
-rst.generateBasicSpatialCoords(canvas, nodeview)
 context = ff.view.FenPDFContext(fen, rst, nodeview)
+textnodeview.setContext(context)
 context.setAccursed(note)
+context.setCursorOffset(5)
 context.setRSTNode(senten)
 ff.view.buoy.MainNode2D.fen = fen
 ff.view.buoy.AbstractMainNode2D.context = context
+rst.util.generateBasicSpatialCoords(canvas, nodeview)
+
 
 
 
Index: fenfire/org/fenfire/modules/pp/RSTActions.java
diff -u fenfire/org/fenfire/modules/pp/RSTActions.java:1.2 
fenfire/org/fenfire/modules/pp/RSTActions.java:1.3
--- fenfire/org/fenfire/modules/pp/RSTActions.java:1.2  Sun May  4 21:38:49 2003
+++ fenfire/org/fenfire/modules/pp/RSTActions.java      Wed May  7 00:08:04 2003
@@ -23,14 +23,20 @@
 
     /** Create a new paragraph to canvas.
      * @param canvas canvas where you like to create the paragraph.
+     * @param width width of paragraph. 
      * @param x x-coordinate
      * @param y y-coordinate
      * @return created sentence
      */
-    Object newParagraph(Object canvas, int x, int y) throws RemoteException;
+    Object newParagraph(Object canvas, int width, int x, int y) 
+       throws RemoteException;
     void deleteParagraph(Object paragraph) throws RemoteException;
 
-    Object newSentence(Object paragraph, int num) throws RemoteException;
+    /** Create a new sentence to paragraph and creates also 
+     * empty node into itself.
+     */
+    Object newSentence(Object paragraph, int num) 
+       throws RemoteException;
     void deleteSentence(Object sentence) throws RemoteException;
 
 
@@ -43,19 +49,4 @@
     void deleteNode(Object sentence, Object node)
        throws RemoteException;
 
-    /** Generate the nodes' coordinates.
-     */
-    void generateBasicSpatialCoords(Object rstCanvas, 
-                                   NodeFunction nodef) 
-       throws RemoteException;
-
-
-
-    // gets
-    Object getSentence(Object node)
-       throws RemoteException;
-    Object getParagraph(Object sentence)
-       throws RemoteException;
-    Object getRSTCanvas(Object paragraph)
-       throws RemoteException;
 }
Index: fenfire/org/fenfire/modules/pp/RSTActionsImpl.java
diff -u fenfire/org/fenfire/modules/pp/RSTActionsImpl.java:1.3 
fenfire/org/fenfire/modules/pp/RSTActionsImpl.java:1.4
--- fenfire/org/fenfire/modules/pp/RSTActionsImpl.java:1.3      Sun May  4 
22:37:38 2003
+++ fenfire/org/fenfire/modules/pp/RSTActionsImpl.java  Wed May  7 00:08:04 2003
@@ -16,7 +16,7 @@
 /** The implementation of RSTActions.
  */
 public class RSTActionsImpl extends UnicastRemoteObject implements RSTActions {
-public static final String rcsid = "$Id: RSTActionsImpl.java,v 1.3 2003/05/05 
02:37:38 mudyc Exp $";
+public static final String rcsid = "$Id: RSTActionsImpl.java,v 1.4 2003/05/07 
04:08:04 mudyc Exp $";
     public static final boolean dbg = false;
     protected static void p(String s) { System.out.println("RSTActionsImpl: 
"+s); }
 
@@ -25,9 +25,12 @@
        this.fen = fen; 
     }
 
+    public RSTUtil util;
+
     public RSTActionsImpl(Fen fen)  throws RemoteException {
        super();
        setFen(fen);
+       util = new RSTUtilImpl(fen);
     }
 
 
@@ -44,7 +47,7 @@
        return canvas;
     }}
 
-    public Object newParagraph(Object canvas, int x, int y) 
+    public Object newParagraph(Object canvas, int width, int x, int y) 
        throws RemoteException
     { synchronized(fen) {
        if (! RDFUtil.isNodeType(fen, canvas, RST.Canvas)) 
@@ -52,6 +55,8 @@
        if (canvas == null) throw new Error("canvas is null!");
        Object parag = RDFUtil.N(fen, RST.Paragraph);
 
+       fen.graph.set1_11X(parag, RST.width, Nodes.getStringLiteral(""+width) );
+
        // set coords
        fen.graph.set1_11X(parag, SPATIAL.coordX, Nodes.getStringLiteral(""+x) 
);
        fen.graph.set1_11X(parag, SPATIAL.coordY, Nodes.getStringLiteral(""+y) 
);
@@ -100,6 +105,7 @@
            if (next != null)
                fen.graph.set1_11X(senten, RST.nextSentence, next);
        }           
+       // No! - insertNode(senten, Nodes.N(), 0);
        return senten;
     }}
 
@@ -108,49 +114,6 @@
        return;
     }}
 
-    public Object getRSTCanvas(Object paragraph)
-    { synchronized(fen) {
-       if (! RDFUtil.isNodeType(fen, paragraph, RST.Paragraph)) 
-           throw new Error("paragraph is not paragraph! "+paragraph);
-
-       Object canvas = fen.graph.find1_X11(RST.beginParagraph, paragraph);
-       if (RDFUtil.isNodeType(fen, canvas, RST.Canvas)) 
-           return canvas;
-       else throw new Error("Big mistake, canvas isn't canvas!"+ canvas);
-    }}
-    public Object getParagraph(Object sentence)
-    { synchronized(fen) {
-       if (! RDFUtil.isNodeType(fen, sentence, RST.Sentence)) 
-           throw new Error("sentence is not sentence! "+sentence);
-
-       Object curr = sentence;
-       Object prev = fen.graph.find1_X11(RST.nextSentence, sentence);
-       while (prev != null) {
-           curr = prev;
-           prev = fen.graph.find1_X11(RST.nextNode, curr);
-       }
-       p("curr: "+curr);
-       Object parag = fen.graph.find1_X11(RST.firstSentence, curr);
-       if (RDFUtil.isNodeType(fen, parag, RST.Paragraph)) 
-           return parag;
-       else throw new Error("paragraph is not paragraph! "+parag);
-    }}
-    public Object getSentence(Object node)
-    { synchronized(fen) {
-       if (node == null) throw new Error("node is null!"+ node);
-       if (! RDFUtil.isNodeType(fen, node, RST.Node)) 
-           throw new Error("node is not a node! "+node);
-
-       Object sentence = fen.graph.find1_X11(RST.nextNode, node);
-       Object prev = sentence;
-       while (prev != null) {
-           sentence = prev;
-           prev = fen.graph.find1_X11(RST.nextNode, sentence);
-       }
-       if (RDFUtil.isNodeType(fen, sentence, RST.Sentence)) 
-           return sentence;
-       else throw new Error("sentence is not sentence! "+sentence);
-    }}
 
     public void insertNode(Object sentence, Object node, int offset)
        throws RemoteException 
@@ -190,7 +153,9 @@
        if (! RDFUtil.isNodeType(fen, node, RST.Node)) 
            fen.graph.add(node, RDF.type, RST.Node);
 
-       Object canvas = getRSTCanvas(getParagraph(getSentence(node)));
+       Object canvas = util.getCanvas(
+           util.getParagraph(util.getSentence(node))
+           );
        fen.graph.add(canvas, PAPER.contains, node);
     }}
 
@@ -199,51 +164,6 @@
     { synchronized(fen) {
        return;
     }}
-
-
-    /** Generate the nodes' coordinates.
-     */
-    public void generateBasicSpatialCoords(Object rstCanvas, NodeFunction 
nodef) 
-       throws RemoteException
-    { synchronized(fen) {
-       if (! RDFUtil.isNodeType(fen, rstCanvas, RST.Canvas)) 
-           throw new Error("canvas is not canvas! "+rstCanvas);
-
-       if (dbg) p("generate");
-
-       Iterator iter = fen.constgraph.findN_11X_Iter(rstCanvas, 
RST.beginParagraph);
-       while (iter.hasNext() ) {
-           if (dbg) p("paragraph");
-           Object parag = iter.next();
-           int paragX = RDFUtil.getInt(fen, parag, SPATIAL.coordX);
-           int paragY = RDFUtil.getInt(fen, parag, SPATIAL.coordY);
-           Object senten = fen.graph.find1_11X(parag, RST.firstSentence);
-           for (int iy=0; senten != null; iy++) {
-               if (dbg) p("senten, "+iy);
-               Object node = fen.graph.find1_11X(senten, RST.nextNode);
-               int x = paragX;
-               while (node != null) {
-                   if (dbg) p("node");
-                   int y = paragY + iy*30;
-
-                   // set coords
-                   fen.graph.set1_11X(node, SPATIAL.coordX, 
Nodes.getStringLiteral(""+x) );
-                   fen.graph.set1_11X(node, SPATIAL.coordY, 
Nodes.getStringLiteral(""+y) );
-
-                   Placeable p = (Placeable)nodef.f(fen.constgraph, node);
-                   p("x before: "+x);
-                   x += p.getWidth();
-                   p("x: "+x+", w: "+p.getWidth()+" x+w: "+(x+p.getWidth()));
-
-                   node = fen.graph.find1_11X(node, RST.nextNode);
-               }
-               senten = fen.graph.find1_11X(senten, RST.nextSentence);
-           }
-       }
-       if (dbg) p("generate..DONE");
-       return;
-    }}
-
 
 
 }
Index: fenfire/org/fenfire/modules/pp/RSTActionsImpl.test
diff -u fenfire/org/fenfire/modules/pp/RSTActionsImpl.test:1.1 
fenfire/org/fenfire/modules/pp/RSTActionsImpl.test:1.2
--- fenfire/org/fenfire/modules/pp/RSTActionsImpl.test:1.1      Thu May  1 
20:22:40 2003
+++ fenfire/org/fenfire/modules/pp/RSTActionsImpl.test  Wed May  7 00:08:04 2003
@@ -37,8 +37,8 @@
 def testNewParagraph():
     canv = act.newRSTCanvas()
 
-    parag1 = act.newParagraph(canv, 12,12)
-    parag2 = act.newParagraph(canv, -12,-12)
+    parag1 = act.newParagraph(canv, 200, 12,12)
+    parag2 = act.newParagraph(canv, 200, -12,-12)
 
     iter = fen.graph.findN_11X_Iter(canv, RST.beginParagraph)
     obj = iter.next()
@@ -54,7 +54,7 @@
     
 def testNewSentence():
     canv = act.newRSTCanvas()
-    parag = act.newParagraph(canv, 12,12)
+    parag = act.newParagraph(canv, 200, 12,12)
 
     sent1 = act.newSentence(parag, 0)  # 1
     sent2 = act.newSentence(parag, 0)  # 2, 1
@@ -67,7 +67,7 @@
 
 def testNodeInsert():
     canv = act.newRSTCanvas()
-    parag = act.newParagraph(canv, 12,12)
+    parag = act.newParagraph(canv, 200, 12,12)
     sent = act.newSentence(parag, 0)
     foo = 'test'
     node = act.insertNode(sent, foo, 0)
Index: fenfire/org/fenfire/util/AlphContent.java
diff -u fenfire/org/fenfire/util/AlphContent.java:1.10 
fenfire/org/fenfire/util/AlphContent.java:1.11
--- fenfire/org/fenfire/util/AlphContent.java:1.10      Fri May  2 20:57:00 2003
+++ fenfire/org/fenfire/util/AlphContent.java   Wed May  7 00:08:05 2003
@@ -1,7 +1,6 @@
 // (c) Matti J. Katila and Tuomas J. Lukka
 
 package org.fenfire.util;
-import org.fenfire.vocab.ALPH;
 import org.fenfire.*;
 import org.nongnu.alph.*;
 import org.nongnu.alph.xml.*;
@@ -13,7 +12,7 @@
 /** Help class to work with Alph
  */
 public class AlphContent {
-public static final String rcsid = "$Id: AlphContent.java,v 1.10 2003/05/03 
00:57:00 mudyc Exp $";
+public static final String rcsid = "$Id: AlphContent.java,v 1.11 2003/05/07 
04:08:05 mudyc Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.out.println("AlphContent:: "+s); 
}
 
Index: fenfire/org/fenfire/util/RDFUtil.java
diff -u fenfire/org/fenfire/util/RDFUtil.java:1.8 
fenfire/org/fenfire/util/RDFUtil.java:1.9
--- fenfire/org/fenfire/util/RDFUtil.java:1.8   Fri Apr 25 07:19:39 2003
+++ fenfire/org/fenfire/util/RDFUtil.java       Wed May  7 00:08:05 2003
@@ -4,11 +4,14 @@
 import org.fenfire.*;
 import org.fenfire.swamp.*;
 import org.fenfire.vocab.*;
+
+import org.nongnu.alph.*;
+
 import java.util.Iterator;
 
 public class RDFUtil {
     public static boolean dbg = false;
-    static private void pa(String s) { System.out.println("RDFUtil: "+s); }
+    static private void p(String s) { System.out.println("RDFUtil: "+s); }
 
     /** Create a new resource with given type.
      */
@@ -16,7 +19,7 @@
        Object obj = Nodes.N();
        fen.graph.add(obj, RDF.type, type);
 
-       if(dbg) pa("N: "+fen+" "+fen.graph+" "+fen.constgraph+
+       if(dbg) p("N: "+fen+" "+fen.graph+" "+fen.constgraph+
          " "+obj+" "+type);
 
        if (!isNodeType(fen, obj, type)) throw new Error("Impossible!");
@@ -28,14 +31,14 @@
     /** Check if node is the type which is asked.
      */
     static public boolean isNodeType(Fen fen, Object node, Object type) {
-       if(dbg) pa("Isnodetype: "+node+" "+type);
+       if(dbg) p("Isnodetype: "+node+" "+type);
        Iterator it = fen.constgraph.findN_11X_Iter(node, RDF.type);
        while(it.hasNext()) {
            Object obj = it.next();
-           if(dbg) pa(" entry: "+ obj);
+           if(dbg) p(" entry: "+ obj);
            if ( obj.equals(type) ) return true;
        }
-       if(dbg) pa("None matched");
+       if(dbg) p("None matched");
        return false;
     }
 
@@ -46,5 +49,40 @@
        return Integer.parseInt(lit.getTextString() );
     }
 
+
+    /** Split node to two nodes. Enfilade is splitted in ind,
+     * i.e. (node, [foobar]) will be with ind 2 be splitted to
+     * (node, [foo]) and (split, [bar]). All properties will 
+     * be copied to split.
+     *
+     * @return the new node
+     */
+    static public Object splitNode(Fen fen, Object node, int ind) {
+       Object split = Nodes.N();
+
+       Enfilade1D enf = (Enfilade1D)fen.txtfunc.f(fen.constgraph, node);
+       if (ind < 0 || ind >= enf.length())
+           throw new Error("Ind is too short or long! "+ind);
+
+       Enfilade1D toEnf = enf.sub(ind, enf.length());
+       Enfilade1D fromEnf = enf.sub(0, ind);
+       fen.txt.set(node, fromEnf);
+       fen.txt.set(split, toEnf);
+
+       Iterator iter = fen.graph.findN_1XA_Iter(node); 
+       while (iter.hasNext()) {
+           Object predicate = iter.next();
+           if (predicate != FF.content) {
+               Iterator it = fen.graph.findN_11X_Iter(node, predicate);
+               while (it.hasNext()) {
+                   Object object = it.next();
+                   if (dbg) p("Pred: " + predicate);
+                   if (dbg) p("   Obj: "+object);
+                   fen.graph.add(split, predicate, object);
+               }
+           }
+       }
+       return split;
+    }
 }
 
Index: fenfire/org/fenfire/view/FenPDFContext.java
diff -u fenfire/org/fenfire/view/FenPDFContext.java:1.2 
fenfire/org/fenfire/view/FenPDFContext.java:1.3
--- fenfire/org/fenfire/view/FenPDFContext.java:1.2     Sun May  4 22:37:39 2003
+++ fenfire/org/fenfire/view/FenPDFContext.java Wed May  7 00:08:05 2003
@@ -7,10 +7,15 @@
 import org.fenfire.util.*;
 import org.fenfire.vocab.*;
 
+import org.nongnu.alph.*;
+
 import java.rmi.RemoteException;
 
 /** FenPDF context what handles keystrokes and 
- * accursed node at least.
+ * accursed node at least. 
+ * <p>
+ * RULE!: context must be always left so that inserting 
+ * text can be done easily. 
  */
 public class FenPDFContext {
     public static boolean dbg = true;
@@ -18,17 +23,20 @@
 
     private Fen fen;
     private AlphContent alphContent;
-    private RSTActions rst;
+    private RSTActionsImpl rst;
     private NodeFunction nodef;
     public FenPDFContext(Fen fen, RSTActions rst, NodeFunction nodef) {
        this.fen = fen;
-       this.rst = rst;
+       this.rst = (RSTActionsImpl)rst;
        this.nodef = nodef;
        this.alphContent = new AlphContent(fen);
     }
 
 
-    private Object accursed;
+    private int cursorOffset = -1;
+    public void setCursorOffset(int offset) { cursorOffset = offset; }
+
+    private Object accursed = null;
     public void setAccursed(Object node) { accursed=node; }
 
     
@@ -38,14 +46,17 @@
            RDFUtil.isNodeType(fen, node, RST.Paragraph) ||
            RDFUtil.isNodeType(fen, node, RST.Sentence) ||
            RDFUtil.isNodeType(fen, node, RST.Node))
-           rstNode = node; // do nothing
+           rstNode = node; // do nothing else
        else throw new Error("No rst node to set!");
     }
 
     public void handleKeyStroke(String stroke, View2D view)
     { try {
+       // synchronized(fen) XXX
        if (accursed == null)
            throw new Error("no accursed set!");
+       if (cursorOffset < 0)
+           throw new Error("no cursoroffset!! "+ cursorOffset);
        p("s: "+stroke+", v: "+view);
 
        if (RDFUtil.isNodeType(fen, rstNode, RST.Sentence)) {
@@ -56,45 +67,87 @@
            if (stroke.equals(" ")) {
                p("space pressed!");
 
-               // check if two spaces one after other XXX
-               // and make a new sentence
-
-               Object node = RDFUtil.N(fen, RST.Node);
-               alphContent.setText(node, stroke, true);
-               rst.insertNode(sentence, node,  
-                              getNodeNumInSentence(getLastNode(sentence)) + 1);
-               rst.generateBasicSpatialCoords(
-                    rst.getRSTCanvas(rst.getParagraph(rstNode)), 
-                   nodef);
-
+               if (needForNewSentence(stroke, view))
+                   ;
+               else {
+                   int num = getNodeNumInSentence(accursed);
+                   Object split = accursed;
+                   /*
+                   p("content: `"+((Enfilade1D)fen.txtfunc.f(fen.constgraph, 
accursed)).makeString()+"`");
+
+                   Object prev = fen.graph.find1_X11(RST.nextNode, accursed);
+                   String spaceTest = ((Enfilade1D)fen.txtfunc.
+                                       f(fen.constgraph, prev)).makeString();
+                   */
+                   if (cursorOffset == 0) {
+                       p("No pre nodes!");
+                       alphContent.insertText(accursed, 0, " ", true);
+                   } else {
+                       split = RDFUtil.splitNode(fen, accursed, cursorOffset);
+                       alphContent.insertText(split, 0, " ", true);
+                       Object next = fen.graph.find1_11X(split, RST.nextNode);
+                       if (next != null) {
+                           fen.graph.rm_111(split, RST.nextNode, next);
+                       }
+                       rst.insertNode(sentence, split, num + 1);
+                   }
+                   num = getNodeNumInSentence(split);
+                   Object split2 = RDFUtil.splitNode(fen, split, 1);
+                   rst.insertNode(sentence, split2, num + 1);
+
+                   // set correct attributes after changes
+                   accursed = split2;
+                   rstNode = sentence;
+                   cursorOffset = 0;
+                   generateCoords(split2);
+               }
                return;
            }
            else if (stroke.equals("Return")) {
                p("enter makes a new sentence.");
-               p("...if implemented ;)");
-
                int num = getSentenceNum(sentence);
-               Object para = rst.getParagraph(sentence);
-               rstNode = sentence = rst.newSentence(para, num+1);
-
-               Object node = RDFUtil.N(fen, RST.Node);
-               alphContent.setText(node, " ", true);
-               rst.insertNode(sentence, node, 0);
-               rst.generateBasicSpatialCoords(
-                    rst.getRSTCanvas(rst.getParagraph(rstNode)), 
-                   nodef);
-               
+               Object para = rst.util.getParagraph(sentence);
+               Object prev = accursed;
+               sentence = rst.newSentence(para, num+1);
+
+               int spaces = getPrevIntend(sentence);
+
+               Object split = accursed;
+               if (cursorOffset > 0) {
+                   split = RDFUtil.splitNode(fen, accursed, cursorOffset);
+                   rst.insertNode(sentence, split, 0);
+               }
+               Object next = fen.graph.find1_11X(accursed, RST.nextNode);
+               // synchronized(fen) XXX
+               if (next != null)
+                   fen.graph.rm_111(accursed, RST.nextNode, next);
+
+               rst.insertNode(rstNode, RST.NewLine, 
+                              getNodeNumInSentence(prev)+1);
+
+               // set correct attributes after changes
+               accursed = split;
+               rstNode = sentence;
+               cursorOffset = 0;
+
+               // XXX ReturnPressed()... indent or smth
+               for (int i=0; i<spaces; i++) 
+                   handleKeyStroke(" ", view);
+               generateCoords(accursed);
                return;
            }
-           
+           else if (stroke.equals("Backspace") ||
+                    stroke.equals("Tab")) {
+               p("not implemented. "+stroke);
+           }
+           else if (stroke.equals("Left") ||
+                    stroke.equals("Right")) {
+               p("not implemented. "+stroke);
+           }
            else if (stroke.length() == 1) {
-               Object node = RDFUtil.N(fen, RST.Node);
-               alphContent.setText(node, stroke, true);
-               rst.insertNode(sentence, node,  
-                              getNodeNumInSentence(getLastNode(sentence)) + 1);
-               rst.generateBasicSpatialCoords(
-                    rst.getRSTCanvas(rst.getParagraph(rstNode)), 
-                   nodef);
+               alphContent.insertText(accursed, cursorOffset, stroke, true);
+               cursorOffset++;
+               generateCoords(accursed);
                return;
            }
        } else  p("No keystroke defined!");
@@ -103,6 +156,32 @@
        return;
     }} 
 
+    protected boolean needForNewSentence(String stroke, View2D view) {
+       return false; }
+
+    protected int getPrevIntend(Object sentence) {
+       return 0;
+    }
+
+
+    private void generateCoords(Object node)
+       throws RemoteException 
+    {
+       Object canvas = node;
+       if (! RDFUtil.isNodeType(fen, canvas, RST.Canvas)) {
+           if (! RDFUtil.isNodeType(fen, canvas, RST.Paragraph)){
+               if (! RDFUtil.isNodeType(fen, canvas, RST.Sentence)){
+                   if (RDFUtil.isNodeType(fen, canvas, RST.Node))
+                       canvas = rst.util.getSentence(canvas);
+                   else throw new Error("Not RST node!"+ node);
+               }
+               canvas = rst.util.getParagraph(canvas);
+           }
+           canvas = rst.util.getCanvas(canvas);
+       }
+       rst.util.generateBasicSpatialCoords(canvas, nodef);
+    }
+
     private Object getFirstNode(Object sentence) 
        throws RemoteException
     {
@@ -116,6 +195,8 @@
     {
        p("go last");
        Object n = getFirstNode(sentence);
+       if (n == null) return null;
+
        Object next = fen.graph.find1_11X(n, RST.nextNode);
        while (next != null) {
            n = next;
@@ -129,7 +210,7 @@
        throws RemoteException
     {
        p("go node");
-       Object n = getFirstNode(rst.getSentence(node));
+       Object n = getFirstNode(rst.util.getSentence(node));
        Object next = fen.graph.find1_11X(n, RST.nextNode);
        int i = 0;
        while (n != node || next != null) {
Index: fenfire/org/fenfire/view/TextNodeView.java
diff -u fenfire/org/fenfire/view/TextNodeView.java:1.2 
fenfire/org/fenfire/view/TextNodeView.java:1.3
--- fenfire/org/fenfire/view/TextNodeView.java:1.2      Fri Apr 25 10:43:04 2003
+++ fenfire/org/fenfire/view/TextNodeView.java  Wed May  7 00:08:05 2003
@@ -53,6 +53,7 @@
     public Object f(ConstGraph g, Object node) {
        Enfilade1D enf = (Enfilade1D)nodeContent.f(g, node);
        
+       final Object objNode = node;
        String s = enf.makeString();
        final TextVob vob = new TextVob(style, s, false);
        final float width = style.getWidth(s, scale);
@@ -60,8 +61,8 @@
 
        return new org.nongnu.libvob.lava.placeable.Placeable() {
                public void place(VobScene vs, int into) {
-                   int scaled = vs.orthoCS(into, "Scaled", 0,
-                                              0, 0, height, height);
+                   int scaled = vs.orthoCS(into, objNode, 0,
+                                           0, 0, height, height);
                    vs.put(vob, scaled);
                }
 
Index: fenfire/org/fenfire/vocab/RST.java
diff -u fenfire/org/fenfire/vocab/RST.java:1.2 
fenfire/org/fenfire/vocab/RST.java:1.3
--- fenfire/org/fenfire/vocab/RST.java:1.2      Sun May  4 21:38:50 2003
+++ fenfire/org/fenfire/vocab/RST.java  Wed May  7 00:08:05 2003
@@ -6,21 +6,28 @@
 
 /** Vocabulary for RST text like canvas */
 public class RST {
-public static final String rcsid = "$Id: RST.java,v 1.2 2003/05/05 01:38:50 
mudyc Exp $";
+public static final String rcsid = "$Id: RST.java,v 1.3 2003/05/07 04:08:05 
mudyc Exp $";
     protected static void pa(String s) { System.out.println("RST: "+s); }
 
     // Propertys
-    static public Object beginParagraph;
-    static public Object nextSentence;
-    static public Object nextNode;
-    static public Object firstSentence;
+    static final public Object beginParagraph;
+    static final public Object nextSentence;
+    static final public Object nextNode;
+    static final public Object firstSentence;
+    static final public Object width;
 
 
     // Resources
-    static public Object Canvas;
-    static public Object Paragraph;
-    static public Object Sentence;
-    static public Object Node;
+    static final public Object Canvas;
+    static final public Object Paragraph;
+    static final public Object Sentence;
+    static final public Object Node;
+
+    static final public Object NewLine;
+
+    // Gen as generated
+    static final public Object GenSpace;
+    static final public Object GenNewLine;
 
     static {
        String rst = "http://fenfire.org/vocabulary/rst.html#";;
@@ -30,11 +37,15 @@
        nextNode = Nodes.get(rst+"nextNode");
        nextSentence = Nodes.get(rst+"nextSentence");
        firstSentence = Nodes.get(rst+"firstSentence");
+       width = Nodes.get(rst+"width");
 
        // Resources
        Canvas = Nodes.get(rst+"Canvas");
        Paragraph = Nodes.get(rst+"Paragraph");
        Sentence = Nodes.get(rst+"Sentence");
        Node = Nodes.get(rst+"Node");
+       NewLine = Nodes.get(rst+"NewLine");
+       GenSpace = Nodes.get(rst+"GenSpace");
+       GenNewLine = Nodes.get(rst+"GenNewLine");
     }
 }




reply via email to

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