created mirror
This commit is contained in:
51
Modules/prez/Prez.java
Normal file
51
Modules/prez/Prez.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Prez.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.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Written by Tuomas Lukka
|
||||
*/
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
/** A simple presentation module.
|
||||
*/
|
||||
|
||||
public class Prez {
|
||||
public static final String rcsid = "$Id: Prez.java,v 1.4 2000/09/19 10:32:03 ajk Exp $";
|
||||
public static boolean dbg = false;
|
||||
static final void p(String s) { if(dbg) System.out.println(s); }
|
||||
static final void pa(String s) { System.out.println(s); }
|
||||
|
||||
static public ZZModule module = new ZZModule() {
|
||||
public void action(String id,
|
||||
ZZCell code,
|
||||
ZZCell target,
|
||||
ZZView view, ZZView cview, String key, Point pt, ZZScene xi) {
|
||||
}
|
||||
public ZOb newZOb(String id) {
|
||||
if(id.equals("R"))
|
||||
return new PrezRaster();
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
173
Modules/prez/PrezRaster.zob
Normal file
173
Modules/prez/PrezRaster.zob
Normal file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
Prez.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.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Written by Tuomas Lukka and Asko Soukka
|
||||
*/
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
/** A simple presentation raster.
|
||||
* The structure is described along three dimensions:
|
||||
* hierarchy, sibling and cross-reference (x, y and z).
|
||||
* On these, the hierarchy is arranged as a corner list with an empty
|
||||
* corner cell, and the cross-references are simply siblings
|
||||
* connected.
|
||||
*/
|
||||
|
||||
public class PrezRaster implements FlobView, ZOb {
|
||||
public static boolean dbg = false;
|
||||
static final void p(String s) { if(dbg) System.out.println(s); }
|
||||
static final void pa(String s) { System.out.println(s); }
|
||||
|
||||
STRUCTPARAMS {
|
||||
/** The vstream raster used for the header. */
|
||||
ZOb hdrvs // VStreamRaster
|
||||
= new RankTextView() {{
|
||||
width = 650;
|
||||
dim = "d.foo";
|
||||
}};
|
||||
/** The vstream raster used for the items. */
|
||||
ZOb txtvs // RankTextView
|
||||
= new RankTextView() {{
|
||||
width = 500;
|
||||
dim = "d.foo";
|
||||
}};
|
||||
/** The vstream raster used for the crossrefs. */
|
||||
ZOb xrefvs // RankTextView
|
||||
= new RankTextView() {{
|
||||
width = 500;
|
||||
dim = "d.foo";
|
||||
}};
|
||||
|
||||
/** The amount to shift the header. */
|
||||
int hdrindent
|
||||
= 30;
|
||||
|
||||
/** The amount to shift the items. */
|
||||
int indent
|
||||
= 50;
|
||||
|
||||
/** The amount to space the items. */
|
||||
int space
|
||||
= 30;
|
||||
|
||||
int topmargin
|
||||
= 120;
|
||||
|
||||
int afterhdr
|
||||
= 0;
|
||||
|
||||
ScalableFont hdrfont
|
||||
= new ScalableFont("SansSerif", Font.PLAIN, 32);
|
||||
|
||||
ScalableFont txtfont
|
||||
= new ScalableFont("SansSerif", Font.PLAIN, 24);
|
||||
|
||||
ScalableFont xreffont
|
||||
= new ScalableFont("SansSerif", Font.PLAIN, 10);
|
||||
|
||||
int hdrwidth
|
||||
= 650;
|
||||
int txtwidth
|
||||
= 500;
|
||||
}
|
||||
|
||||
String next = "d.2";
|
||||
String hier = "d.1";
|
||||
String cross = "d.3";
|
||||
|
||||
public void raster(FlobSet into, FlobFactory fact,
|
||||
ZZCell view, String[] dims, ZZCell accursed) {
|
||||
|
||||
hier = dims[0];
|
||||
next = dims[1];
|
||||
cross = dims[2];
|
||||
|
||||
ZZCell hdr = null;
|
||||
|
||||
/* Something to work with circular ranks.
|
||||
* Goes rank backwards and gets the first available cell
|
||||
* on the negative direction on the hier-dimension.
|
||||
* Otherwise gets the accursed cell. */
|
||||
hdr = accursed.s(hier, -1);
|
||||
int i = -1;
|
||||
while (hdr == null) {
|
||||
if (accursed.s(next, i) == null) break;
|
||||
hdr = accursed.s(next, i).s(hier, -1);
|
||||
if (i < -20) break;
|
||||
i--;
|
||||
}
|
||||
|
||||
if (hdr == null) hdr = accursed;
|
||||
|
||||
RankTextView hdrvs = (RankTextView)this.hdrvs;
|
||||
RankTextView txtvs = (RankTextView)this.txtvs;
|
||||
RankTextView xrefvs = (RankTextView)this.xrefvs;
|
||||
|
||||
hdrvs.font = hdrfont;
|
||||
txtvs.font = txtfont;
|
||||
xrefvs.font = xreffont;
|
||||
|
||||
hdrvs.width = hdrwidth;
|
||||
txtvs.width = txtwidth;
|
||||
|
||||
hdrvs.readParams(null);
|
||||
txtvs.readParams(null);
|
||||
xrefvs.readParams(null);
|
||||
|
||||
int y = topmargin;
|
||||
Rectangle bds = hdrvs.raster(into, hdr, 0, false,
|
||||
hdrindent, y);
|
||||
p("Raster 1: "+bds);
|
||||
|
||||
y += bds.height + afterhdr;
|
||||
|
||||
ZZCell cur = hdr.s(hier, 1);
|
||||
if(cur == null) return;
|
||||
|
||||
LoopDetector l = new LoopDetector();
|
||||
while(true) {
|
||||
cur = cur.s(next, 1);
|
||||
if(cur == null) break;
|
||||
if(cur == hdr.s(hier, 1)) break;
|
||||
l.detect(cur);
|
||||
bds = txtvs.raster(into, cur, 0, false, indent, y);
|
||||
p("Raster n: "+bds);
|
||||
// indicate that there is more
|
||||
if(cur.s(hier, 1) != null) {
|
||||
into.add(new LineDecor(bds.x+bds.width, bds.y,
|
||||
bds.x+bds.width, bds.y+bds.height,
|
||||
Color.blue, 1));
|
||||
}
|
||||
if(cur.s(cross, -1) != null)
|
||||
xrefvs.raster(into, cur.s(cross,-1),
|
||||
0, false, 400, bds.y-15);
|
||||
if(cur.s(cross, 1) != null)
|
||||
xrefvs.raster(into, cur.s(cross,1),
|
||||
0, false, 400, bds.y+bds.height+5);
|
||||
|
||||
y += bds.height + space;
|
||||
}
|
||||
}
|
||||
}
|
||||
// vim: set syntax=java :
|
||||
Reference in New Issue
Block a user