117 lines
3.8 KiB
Java
117 lines
3.8 KiB
Java
/*
|
|
ClockCellView.zob
|
|
*
|
|
* Copyright (c) 2001, Benja Fallenstein
|
|
*
|
|
* 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 Benja Fallenstein
|
|
*/
|
|
|
|
package org.gzigzag.module;
|
|
import org.gzigzag.*;
|
|
import java.util.*;
|
|
import java.awt.*;
|
|
|
|
/** A cell view that shows the daytime demo clock, using a scene flob.
|
|
* For use with ideosyncratic cell view. Create the cell to be shown as a
|
|
* clock. Posward on d.3, connect the clock cell to a d.2 rank of appointments
|
|
* in the regular DayTimeDemo structure (see DayTimeDemo.zob and the
|
|
* CyberText article pictures). Then, from the clock cell negwards on
|
|
* d.cellview create a new cell and write the cell view's name, e.g.
|
|
* "Clock Cellview," in it. From that cell, create a new cell poswards on d.1
|
|
* and write "DayTimeDemo.C" (of course w/o quotes) in it. Use F2 to switch
|
|
* to the ideosyncratic cell view, and the clock cell should change its
|
|
* appereance to a DayTimeDemo clock. (Best viewed with StretchVanishing or
|
|
* Quad view, so that it's not shown that small.)
|
|
*/
|
|
|
|
public class ClockCellView implements FlobFactory, ZOb {
|
|
public static final String rcsid = "$Id: ClockCellView.zob,v 1.3 2001/03/18 17:50:16 bfallenstein Exp $";
|
|
public static boolean dbg = false;
|
|
private static void p(String s) { if(dbg) ZZLogger.log(s); }
|
|
private static void pa(String s) { ZZLogger.log(s); }
|
|
|
|
STRUCTPARAMS {
|
|
Font txtfont
|
|
= new Font("Serif", Font.BOLD, 14);
|
|
|
|
Font clkfont
|
|
= new Font("SansSerif", Font.PLAIN, 11);
|
|
}
|
|
|
|
public Dimension getSize(ZZCell c, float fract) {
|
|
return new Dimension((int)(150*fract), (int)(150*fract));
|
|
}
|
|
|
|
DayTimeDemo dtd = new DayTimeDemo();
|
|
|
|
INITIALIZE {
|
|
dtd.txtfont = txtfont;
|
|
dtd.clkfont = clkfont;
|
|
dtd.txtfm = FONTMETRICS(txtfont);
|
|
dtd.clkfm = FONTMETRICS(clkfont);
|
|
}
|
|
|
|
public Flob makeFlob(FlobSet into, ZZCell c, ZZCell handleCell,
|
|
float fract,
|
|
int x, int y, int d, int w, int h) {
|
|
|
|
FlobSet sc = new FlobSet(new Dimension(w, h), Color.white, Color.black,
|
|
ScalableFont.fmComp);
|
|
dtd.raster(sc, null, null, null, c.getRootclone().h("d.3", 1));
|
|
|
|
SceneFlob sf = new SimpleSceneFlob(x, y, d, w, h, c, sc);
|
|
CellFlobFactory1.addSolidColors(into, sf, sf);
|
|
into.add(sf);
|
|
return sf;
|
|
}
|
|
|
|
public Flob placeFlob(FlobSet into, ZZCell c, ZZCell handleCell,
|
|
float fract,
|
|
int x, int y, int depth,
|
|
float xfract, float yfract) {
|
|
Dimension d = getSize(c, fract);
|
|
return makeFlob(into, c, handleCell, fract,
|
|
(int)(x-xfract*d.width),
|
|
(int)(y-yfract*d.height),
|
|
depth, d.width, d.height);
|
|
}
|
|
|
|
public Flob centerFlob(FlobSet into, ZZCell c, ZZCell handleCell,
|
|
float fract, Point p, int xalign, int yalign,
|
|
int depth, Dimension d) {
|
|
if(d == null) d = getSize(c, fract);
|
|
int x, y;
|
|
x = p.x - d.width/2; y = p.y - d.height/2;
|
|
|
|
if(xalign < 0) x = p.x;
|
|
if(xalign > 0) x = p.x - d.width;
|
|
if(yalign < 0) y = p.y;
|
|
if(yalign > 0) y = p.y - d.height;
|
|
p("centerFlob "+p+" "+d+" at "+x+" "+y+" align "+xalign+" "+yalign);
|
|
return makeFlob(into, c, handleCell, fract, x, y,
|
|
depth, d.width, d.height);
|
|
}
|
|
public Flob centerFlob(FlobSet into, ZZCell c, ZZCell handleCell,
|
|
float fract, Point p, int xalign, int yalign, int depth) {
|
|
return centerFlob(into, c, handleCell, fract, p, xalign, yalign,
|
|
depth, null);
|
|
}
|
|
}
|
|
|
|
// vim: set syntax=java :
|