Code Search for Developers
 
 
  

AwtNileView.java from gzz at Krugle


Show AwtNileView.java syntax highlighted

/*   
AwtNileView.java
 *    
 *    Copyright (c) 2000, Ted Nelson and Tuomas Lukka
 *
 *    This file is part of Gzz.
 *    
 *    Gzz is free software; you can redistribute it and/or modify it under
 *    the terms of the GNU Lesser General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *    
 *    Gzz 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 GNU Lesser General
 *    Public License for more details.
 *    
 *    You should have received a copy of the GNU Lesser General
 *    Public License along with Gzz; if not, write to the Free
 *    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *    
 *
 */
/*
 * 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 Rectangle placeParagraph(FlobSet into, 
	FText ft, ZZCell para,Rectangle origrect, int depth,
	int direction, int initY, int middleOffs) {
	beginningSentence[0] = true;
	beginningSentence[1] = false;
	// Margins.
	Rectangle rect = pmarg(origrect, para);
	Rectangle ret = ((FTextLayouter)ftextlayouter).place(into, ft, rect,
				    depth,
				    direction, initY, middleOffs, false, 
				    beginningSentence);
	// Now, do the cool thing with the section headings: include
	// previous and next section headings of the same level here.
	if(Nile2Iter.getLevel(para) > 0) {

	ZZCell strcell = para.s("d.nile-struct");
	if(strcell == null) return ret;

	for(int dir = -1; dir <= 1; dir += 2) {
	    ZZCell prevsec = strcell.s("nile1str:breadth",dir);
	    if(prevsec == null) continue;
	    prevsec = prevsec.h("nile1str:depth").s("d.nile-struct", -1);
	    if(prevsec == null) continue;
	    beginningSentence[0] = true;
	    beginningSentence[1] = false;
	    FText nft = paragraph(prevsec, Nile2Iter.findStruct(prevsec, 1, false),
				    null, null, null);
	    ((FTextLayouter)ftextlayouter).place(into, nft, rect, 200,
			    dir, ret.y + (dir < 0 ? 0 : ret.height), 
			    0, false, beginningSentence);
	}
	}
	return ret;
    }


    public void awtNileRaster(FlobSet into, ZZCell view, ZZCell accursed,
                              Rectangle rect, int depth) {
	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, depth, 
	    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, depth,
		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, depth,
		-1, r.y - paraskip, 0);

	    if(r.y < 0) break;
	}
	// into.dump();
	Flob cursf = into.findFlob(null, accursed);
	// p("Cursf: "+cursf);
        // add condition: if ciew is active, then show cursor
	if(cursf != null) 
	    ((SplitCellFlob1)cursf).addCurs(into, ZZCursorReal.getOffs(view), 
				    Color.red);
    }
}


// vim: set syntax=java :




See more files for this project here

gzz

An implementation of Ted Nelson's ZZstructure. ZZstructure is a new type of programming platform for structured data.

Project homepage: http://savannah.nongnu.org/projects/gzz
Programming language(s): C++,Java,Python
License: lgpl21

  AwtCursor.java
  AwtLink.java
  AwtLink.zob
  AwtMetrics.java
  AwtMetrics.zob
  AwtMetricsFC.java
  AwtMetricsFC2.java
  AwtMetricsNormal.java
  AwtNileView.java
  AwtNote.java
  AwtNote.zob
  AwtUtil.java
  AwtView1.java
  Awtool.java
  Awtool.zob
  BooleanMesh.java
  README
  TODO
  ZObCellRepr.java