Files
gzz-mirror/Modules/awtool/AwtNileView.java
2026-09-14 20:19:29 -04:00

111 lines
3.0 KiB
Java

/*
AwtNileView.java
*
* Copyright (c) 2000, Ted Nelson and Tuomas Lukka
*
* You may use and distribute under the terms of either the GNU Lesser
* General Public License, either version 2 of the license or,
* at your choice, any later version. Alternatively, you may use and
* distribute under the terms of the XPL.
*
* See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of
* the licenses.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the README
* file for more details.
*
*/
/*
* Nile1View.java written by Tuomas Lukka,
* AwtNileView - localization for Awtool by Kimmo Wideroos
*/
package org.gzigzag.module;
import org.gzigzag.*;
import java.util.*;
import java.awt.*;
import java.io.*;
/** A view for nile streams.
*/
public class AwtNileView extends Nile1View {
public static final String rcsid = "";
public static boolean dbg = false;
static void p(String s) { if(dbg) System.out.println(s); }
static void pa(String s) { System.out.println(s); }
public AwtNileView() {
init__zob();
}
public void awtNileRaster(FlobSet into, ZZCell view, ZZCell accursed,
Rectangle rect) {
int[] offs = new int[1];
LoopDetector ld = new LoopDetector();
ZZCursor selectEnd = null;
ZZCell sele = view.s("d.nile-sel");
if(sele != null) {
selectEnd = ZZCursorVirtual.createFromReal(sele);
}
// Do the center paragraph first.
ZZCell firstpara = Nile2Iter.findStruct(accursed, -1, true);
ZZCell nextpara = Nile2Iter.findStruct(accursed, 1, false);
FText ft = paragraph(firstpara, nextpara, new ZZCursorReal(view),
offs, selectEnd);
Dimension size = new Dimension(rect.width, rect.height);
//Rectangle rect = new Rectangle(0, 0, size.width, size.height);
Rectangle ctr = placeParagraph(into, ft, firstpara, rect,
0, rect.y+rect.height/2,
ZZCursorReal.getVisualTextOffset(view));
// Go into positive direction.
Rectangle r = ctr;
while(nextpara != null) {
ld.detect(nextpara);
ZZCell next = Nile2Iter.findStruct(nextpara, 1, false);
ft = paragraph(nextpara, next, null, null, selectEnd);
r = placeParagraph(into, ft, nextpara, rect,
1, r.y+r.height + paraskip, 0);
nextpara = next;
if(r.y + r.height > size.height) break;
}
// And negative.
r = ctr;
while(true) {
ZZCell prev = firstpara;
firstpara = Nile2Iter.findStruct(firstpara, -1, false);
if(firstpara == null) break;
ld.detect(firstpara);
ft = paragraph(firstpara, prev, null, null, null);
beginningSentence[0] = true;
r = placeParagraph(into, ft, firstpara, rect,
-1, r.y - paraskip, 0);
if(r.y < 0) break;
}
// into.dump();
Flob cursf = into.findFlob(null, accursed);
// p("Cursf: "+cursf);
if(cursf != null)
((SplitCellFlob1)cursf).addCurs(into, ZZCursorReal.getOffs(view),
Color.red);
}
}
// vim: set syntax=java :