//(c): Matti J Katila package org.fenfire.modules.pp.lava; import org.fenfire.*; import org.fenfire.vocab.*; import org.fenfire.vocab.lava.RST; 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.libvob.lava.placeable.Placeable; 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/14 12:32:53 mudyc Exp $"; public static final boolean dbg = false; protected static void p(String s) { System.out.println("RSTActionsImpl: "+s); } private Fen fen = null; public void setFen(Fen fen) { this.fen = fen; } public RSTUtil util; public RSTActionsImpl(Fen fen) throws RemoteException { super(); setFen(fen); util = new RSTUtilImpl(fen); } // --- implement RSTActions // public Object newRSTCanvas() throws RemoteException { synchronized(fen) { if(dbg) p("make a new rst canvas"); Object canvas = RDFUtil.N(fen, RST.Canvas); fen.graph.add(canvas, RDF.type, CANVAS2D.Canvas); return canvas; }} public Object newParagraph(Object canvas, int width, 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); fen.graph.set1_11X(parag, RST.width, Nodes.getStringLiteral(""+width) ); // set coords fen.graph.set1_11X(parag, CANVAS2D.x, Nodes.getStringLiteral(""+x) ); fen.graph.set1_11X(parag, CANVAS2D.y, 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