/[fenfire]/fenfire/org/fenfire/modules/pp/RSTActionsImpl.java
ViewVC logotype

Diff of /fenfire/org/fenfire/modules/pp/RSTActionsImpl.java

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

revision 1.1 by mudyc, Fri May 2 00:22:40 2003 UTC revision 1.2 by mudyc, Mon May 5 01:38:49 2003 UTC
# Line 10  import java.rmi.*; Line 10  import java.rmi.*;
10  import java.rmi.server.*;  import java.rmi.server.*;
11  import java.util.Iterator;  import java.util.Iterator;
12    
13  //import org.nongnu.alph.impl.*;  import org.nongnu.libvob.lava.placeable.Placeable;
14  import org.fenfire.impl.*;  import org.fenfire.impl.*;
15    
16  /** The implementation of RSTActions.  /** The implementation of RSTActions.
# Line 18  import org.fenfire.impl.*; Line 18  import org.fenfire.impl.*;
18  public class RSTActionsImpl extends UnicastRemoteObject implements RSTActions {  public class RSTActionsImpl extends UnicastRemoteObject implements RSTActions {
19  public static final String rcsid = "$Id$";  public static final String rcsid = "$Id$";
20      public static final boolean dbg = true;      public static final boolean dbg = true;
21      protected static void pa(String s) { System.out.println("RSTActionsImpl: "+s); }      protected static void p(String s) { System.out.println("RSTActionsImpl: "+s); }
22    
23      private Fen fen = null;      private Fen fen = null;
     private AlphContent alphContent;  
24      public void setFen(Fen fen) {      public void setFen(Fen fen) {
25          this.fen = fen;          this.fen = fen;
         this.alphContent = new AlphContent(fen);  
26      }      }
27    
28      public RSTActionsImpl(Fen fen)  throws RemoteException {      public RSTActionsImpl(Fen fen)  throws RemoteException {
# Line 40  public static final String rcsid = "$Id$ Line 38  public static final String rcsid = "$Id$
38    
39      public Object newRSTCanvas() throws RemoteException      public Object newRSTCanvas() throws RemoteException
40      { synchronized(fen) {      { synchronized(fen) {
41          if(dbg) pa("make a new rst canvas");          if(dbg) p("make a new rst canvas");
42          Object canvas = RDFUtil.N(fen, RST.Canvas);          Object canvas = RDFUtil.N(fen, RST.Canvas);
43          fen.graph.add(canvas, RDF.type, PAPER.Canvas);          fen.graph.add(canvas, RDF.type, PAPER.Canvas);
44          return canvas;          return canvas;
# Line 110  public static final String rcsid = "$Id$ Line 108  public static final String rcsid = "$Id$
108          return;          return;
109      }}      }}
110    
111      private Object getRSTCanvas(Object paragraph)      public Object getRSTCanvas(Object paragraph)
112      { synchronized(fen) {      { synchronized(fen) {
113          if (! RDFUtil.isNodeType(fen, paragraph, RST.Paragraph))          if (! RDFUtil.isNodeType(fen, paragraph, RST.Paragraph))
114              throw new Error("paragraph is not paragraph! "+paragraph);              throw new Error("paragraph is not paragraph! "+paragraph);
# Line 120  public static final String rcsid = "$Id$ Line 118  public static final String rcsid = "$Id$
118              return canvas;              return canvas;
119          else throw new Error("Big mistake, canvas isn't canvas!"+ canvas);          else throw new Error("Big mistake, canvas isn't canvas!"+ canvas);
120      }}      }}
121      private Object getParagraph(Object sentence)      public Object getParagraph(Object sentence)
122      { synchronized(fen) {      { synchronized(fen) {
123          if (! RDFUtil.isNodeType(fen, sentence, RST.Sentence))          if (! RDFUtil.isNodeType(fen, sentence, RST.Sentence))
124              throw new Error("sentence is not sentence! "+sentence);              throw new Error("sentence is not sentence! "+sentence);
# Line 131  public static final String rcsid = "$Id$ Line 129  public static final String rcsid = "$Id$
129              curr = prev;              curr = prev;
130              prev = fen.graph.find1_X11(RST.nextNode, curr);              prev = fen.graph.find1_X11(RST.nextNode, curr);
131          }          }
132          pa("curr: "+curr);          p("curr: "+curr);
133          Object parag = fen.graph.find1_X11(RST.firstSentence, curr);          Object parag = fen.graph.find1_X11(RST.firstSentence, curr);
134          if (RDFUtil.isNodeType(fen, parag, RST.Paragraph))          if (RDFUtil.isNodeType(fen, parag, RST.Paragraph))
135              return parag;              return parag;
136          else throw new Error("paragraph is not paragraph! "+parag);          else throw new Error("paragraph is not paragraph! "+parag);
137      }}      }}
138      private Object getSentence(Object node)      public Object getSentence(Object node)
139      { synchronized(fen) {      { synchronized(fen) {
140          if (node == null) throw new Error("node is null!"+ node);          if (node == null) throw new Error("node is null!"+ node);
141            if (! RDFUtil.isNodeType(fen, node, RST.Node))
142                throw new Error("node is not a node! "+node);
143    
144          Object sentence = fen.graph.find1_X11(RST.nextNode, node);          Object sentence = fen.graph.find1_X11(RST.nextNode, node);
145          Object prev = sentence;          Object prev = sentence;
# Line 187  public static final String rcsid = "$Id$ Line 187  public static final String rcsid = "$Id$
187              if (next != null)              if (next != null)
188                  fen.graph.set1_11X(node, RST.nextNode, next);                  fen.graph.set1_11X(node, RST.nextNode, next);
189          }                    }          
190            if (! RDFUtil.isNodeType(fen, node, RST.Node))
191                fen.graph.add(node, RDF.type, RST.Node);
192    
193          Object canvas = getRSTCanvas(getParagraph(getSentence(node)));          Object canvas = getRSTCanvas(getParagraph(getSentence(node)));
194          fen.graph.add(canvas, PAPER.contains, node);          fen.graph.add(canvas, PAPER.contains, node);
195      }}      }}
# Line 200  public static final String rcsid = "$Id$ Line 203  public static final String rcsid = "$Id$
203    
204      /** Generate the nodes' coordinates.      /** Generate the nodes' coordinates.
205       */       */
206      public void generateBasicSpatialCoords(Object rstCanvas)      public void generateBasicSpatialCoords(Object rstCanvas, NodeFunction nodef)
207          throws RemoteException          throws RemoteException
208      { synchronized(fen) {      { synchronized(fen) {
209          if (! RDFUtil.isNodeType(fen, rstCanvas, RST.Canvas))          if (! RDFUtil.isNodeType(fen, rstCanvas, RST.Canvas))
210              throw new Error("canvas is not canvas! "+rstCanvas);              throw new Error("canvas is not canvas! "+rstCanvas);
211    
212          if (dbg) pa("generate");          if (dbg) p("generate");
213    
214          Iterator iter = fen.constgraph.findN_11X_Iter(rstCanvas, RST.beginParagraph);          Iterator iter = fen.constgraph.findN_11X_Iter(rstCanvas, RST.beginParagraph);
215          while (iter.hasNext() ) {          while (iter.hasNext() ) {
216              pa("paragraph");              if (dbg) p("paragraph");
217              Object parag = iter.next();              Object parag = iter.next();
218              int paragX = RDFUtil.getInt(fen, parag, SPATIAL.coordX);              int paragX = RDFUtil.getInt(fen, parag, SPATIAL.coordX);
219              int paragY = RDFUtil.getInt(fen, parag, SPATIAL.coordY);              int paragY = RDFUtil.getInt(fen, parag, SPATIAL.coordY);
220              Object senten = fen.graph.find1_11X(parag, RST.firstSentence);              Object senten = fen.graph.find1_11X(parag, RST.firstSentence);
221              for (int iy=0; senten != null; iy++) {              for (int iy=0; senten != null; iy++) {
222                  pa("senten"+iy);                  if (dbg) p("senten, "+iy);
223                  Object node = fen.graph.find1_11X(senten, RST.nextNode);                  Object node = fen.graph.find1_11X(senten, RST.nextNode);
224                    int x = paragX;
225                  for (int ix=0; node != null; ix++) {                  for (int ix=0; node != null; ix++) {
226                      pa("senten"+ix);                      if (dbg) p("node, "+ix);
227                      int x = paragX + ix*60;  
228                        Placeable p = (Placeable)nodef.f(fen.constgraph, node);
229    
230                        x += p.getWidth();
231                      int y = paragY + iy*30;                      int y = paragY + iy*30;
232                      // set coords                      // set coords
233                      fen.graph.set1_11X(node, SPATIAL.coordX, Nodes.getStringLiteral(""+x) );                      fen.graph.set1_11X(node, SPATIAL.coordX, Nodes.getStringLiteral(""+x) );
# Line 231  public static final String rcsid = "$Id$ Line 238  public static final String rcsid = "$Id$
238                  senten = fen.graph.find1_11X(senten, RST.nextSentence);                  senten = fen.graph.find1_11X(senten, RST.nextSentence);
239              }              }
240          }          }
241          if (dbg) pa("generate..DONE");          if (dbg) p("generate..DONE");
242          return;          return;
243      }}      }}
244    

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