//(c): Matti J Katila package org.fenfire.modules.pp; import org.fenfire.*; import org.fenfire.vocab.*; import org.fenfire.util.*; import org.fenfire.swamp.*; import java.io.IOException; import java.rmi.*; import java.rmi.server.*; import java.util.Iterator; //import org.nongnu.alph.impl.*; import org.fenfire.impl.*; /** The implementation of RSTActions. */ public class RSTActionsImpl extends UnicastRemoteObject implements RSTActions { public static final String rcsid = "$Id: RSTActionsImpl.java,v 1.1 2003/05/02 00:22:40 mudyc Exp $"; public static final boolean dbg = true; protected static void pa(String s) { System.out.println("RSTActionsImpl: "+s); } private Fen fen = null; private AlphContent alphContent; public void setFen(Fen fen) { this.fen = fen; this.alphContent = new AlphContent(fen); } public RSTActionsImpl(Fen fen) throws RemoteException { super(); setFen(fen); } // --- implement RSTActions // public Object newRSTCanvas() throws RemoteException { synchronized(fen) { if(dbg) pa("make a new rst canvas"); Object canvas = RDFUtil.N(fen, RST.Canvas); fen.graph.add(canvas, RDF.type, PAPER.Canvas); return canvas; }} public Object newParagraph(Object canvas, int x, int y) throws RemoteException { synchronized(fen) { if (! RDFUtil.isNodeType(fen, canvas, RST.Canvas)) throw new Error("canvas is not canvas! "+canvas); if (canvas == null) throw new Error("canvas is null!"); Object parag = RDFUtil.N(fen, RST.Paragraph); // set coords fen.graph.set1_11X(parag, SPATIAL.coordX, Nodes.getStringLiteral(""+x) ); fen.graph.set1_11X(parag, SPATIAL.coordY, Nodes.getStringLiteral(""+y) ); fen.graph.add(canvas, RST.beginParagraph, parag); return parag; }} public void deleteParagraph(Object paragraph) throws RemoteException { synchronized(fen) { return; }} public Object newSentence(Object paragraph, int num) throws RemoteException { synchronized(fen) { if (! RDFUtil.isNodeType(fen, paragraph, RST.Paragraph)) throw new Error("paragraph is not paragraph! "+paragraph); Object senten = RDFUtil.N(fen, RST.Sentence); if (num < 0) throw new Error("Num is too small"+num); else if (num == 0) { // check if there are any other sentences Object firstSent = fen.graph.find1_11X(paragraph, RST.firstSentence); // put this at first - delete if already set fen.graph.set1_11X(paragraph, RST.firstSentence, senten); if (firstSent != null) { // link from new first to the old first fen.graph.set1_11X(senten, RST.nextSentence, firstSent); } } else if (num > 0) { // find first sentences Object firstSent = fen.graph.find1_11X(paragraph, RST.firstSentence); Object prev=firstSent, next=null; for (int i=0; i 0) { // find first node Object firstNode = fen.graph.find1_11X(sentence, RST.nextNode); Object prev=firstNode, next=null; for (int i=0; i