55 |
|
|
56 |
if (stroke.equals(" ")) { |
if (stroke.equals(" ")) { |
57 |
p("space pressed!"); |
p("space pressed!"); |
58 |
|
|
59 |
|
// check if two spaces one after other XXX |
60 |
|
// and make a new sentence |
61 |
|
|
62 |
|
Object node = RDFUtil.N(fen, RST.Node); |
63 |
|
alphContent.setText(node, stroke, true); |
64 |
|
rst.insertNode(sentence, node, |
65 |
|
getNodeNumInSentence(getLastNode(sentence)) + 1); |
66 |
|
rst.generateBasicSpatialCoords( |
67 |
|
rst.getRSTCanvas(rst.getParagraph(rstNode)), |
68 |
|
nodef); |
69 |
|
|
70 |
return; |
return; |
71 |
} |
} |
72 |
if (stroke.equals("Return")) { |
else if (stroke.equals("Return")) { |
73 |
p("enter makes a new sentence."); |
p("enter makes a new sentence."); |
74 |
|
p("...if implemented ;)"); |
75 |
|
|
76 |
|
int num = getSentenceNum(sentence); |
77 |
|
Object para = rst.getParagraph(sentence); |
78 |
|
rstNode = sentence = rst.newSentence(para, num+1); |
79 |
|
|
80 |
|
Object node = RDFUtil.N(fen, RST.Node); |
81 |
|
alphContent.setText(node, " ", true); |
82 |
|
rst.insertNode(sentence, node, 0); |
83 |
|
rst.generateBasicSpatialCoords( |
84 |
|
rst.getRSTCanvas(rst.getParagraph(rstNode)), |
85 |
|
nodef); |
86 |
|
|
87 |
return; |
return; |
88 |
} |
} |
89 |
|
|
90 |
p("length"+stroke.length()); |
else if (stroke.length() == 1) { |
|
if (stroke.length() == 1) { |
|
91 |
Object node = RDFUtil.N(fen, RST.Node); |
Object node = RDFUtil.N(fen, RST.Node); |
92 |
alphContent.setText(node, stroke, true); |
alphContent.setText(node, stroke, true); |
93 |
rst.insertNode(sentence, node, |
rst.insertNode(sentence, node, |
142 |
throw new Error("node not found in sentence"); |
throw new Error("node not found in sentence"); |
143 |
return i; |
return i; |
144 |
} |
} |
145 |
|
|
146 |
|
private int getSentenceNum(Object sentence) { |
147 |
|
if (! RDFUtil.isNodeType(fen, sentence, RST.Sentence)) |
148 |
|
throw new Error("sentence is not sentence! "+sentence); |
149 |
|
|
150 |
|
Object n = sentence; |
151 |
|
Object prev = fen.graph.find1_X11(RST.nextSentence, n); |
152 |
|
while (prev != null) { |
153 |
|
n = prev; |
154 |
|
prev = fen.graph.find1_X11(RST.nextSentence, n); |
155 |
|
} |
156 |
|
int i=0; |
157 |
|
for (i=0; n!=sentence; i++) { |
158 |
|
n = fen.graph.find1_11X(n, RST.nextSentence); |
159 |
|
} |
160 |
|
return i; |
161 |
|
} |
162 |
|
|
163 |
} |
} |