created mirror

This commit is contained in:
whatever
2026-09-14 20:19:29 -04:00
commit 6764738d92
600 changed files with 87187 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
/*
Vob.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;
import java.util.*;
import java.awt.*;
/** A connection to draw between two vobs.
* This doesn't need to store the vob coordinates, so the same Connection
* object can actually be used to draw many connections.
*/
public abstract class Vob extends Renderable {
public static final String rcsid = "$Id: Connection.java,v 1.1 2001/01/20 08:56:19 bfallenstein Exp $";
/** Render this connection between the given vobs.
* Default: render nothing.
*/
public void render(Graphics g, Vob v1, int x1, int y1,
Vob v2, int x2, int y2) {
}
/** Returns an object telling what was hit.
* Default implementation: returns null.
* XXX interaction with coords?
*/
public Object hit(Vob v1, Vob v2) { return null; }
}

38
Modules/vob/View.java Normal file
View File

@@ -0,0 +1,38 @@
/*
FlobRaster.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;
import java.util.*;
/** A fairly general interface for drawing a structure
* on the screen using vobs.
* The parameters have been read through the ZOb interface so
* we don't need to worry about those here.
*/
public abstract class View {
String rcsid = "$Id: View.java,v 1.1 2001/01/20 08:56:19 bfallenstein Exp $";
/** Draw a representation of the structure into the VobSet.
*/
public abstract void raster(VobSet into, ZZCell what, CellView cv,
ZZCell win, String[] dims, ZZCell accursed);
}

142
Modules/vob/Vob.java Normal file
View File

@@ -0,0 +1,142 @@
/*
Vob.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;
import java.util.*;
import java.awt.*;
/** A vob or visual object shown on the screen.
* Vobs are constant read-only objects like Strings.
* <p>
* Vobs should be able to render themselves quickly for animations;
* caching relevant information in this structure is therefore a good idea.
* <p>
* The minimal vob implementation simply implements the
* render(Graphics, int, int, int, int, int) method.
*/
public abstract class Vob extends Renderable {
public static final String rcsid = "$Id: Vob.java,v 1.1 2001/01/20 08:56:19 bfallenstein Exp $";
public int w, h;
/** The cell associated with this vob.
* This may be set to null for things that are - well - just
* things rendered. But those should be in a minority always.
*/
public ZZCell c;
/** The vob we are interpolating with.
* Storing it here is a pure speed hack: in reality it'd belong in
* a hashtable somewhere. But this is crucial for the frame rate.
*/
protected Vob interpTo;
/** A 3-tuple with the global coordinates for this vob.
* Conceptually this belongs in the VobStore, but I can't think of a
* clean, not too wasteful implementation.
*/
protected int[] coords;
/** The lowest-level VobSet this was placed into.
*/
public VobSet vobset;
public Vob(ZZCell c) {
this.c = c;
}
/** Get the visual center of this vob.
*/
public Point getCenter(Point p) {
p.x = w/2; p.y = h/2;
return p;
}
/** Get the visual center of this vob.
*/
public Point getCenter() {
return getCenter(new Point());
}
/** Render this vob at the given coordinates.
* Default: render nothing.
* You may override either this function or one or both of
* render(Graphics, int, int) and renderInterp(Graphics, int, int,
int, int, float).
*/
public void render(Graphics g, int mx, int my, int md,
int mw, int mh) {
}
/** Render this vob.
* May be overridden; default implementation uses render(g, x, y, w, h, d);
*/
public void render(Graphics g, x, y, d) {
render(g, x, y, d, w, h);
}
/** Render an interpolated version of this vob.
* Default implementation uses render(g, x, y, d, w, h) with linearly
* interpolated coordinates.
*/
public void renderInterp(Graphics g, float fract) {
Vob r = interpTo;
if(r==null) return;
render(g,
(int)(x + fract*(r.x-x)),
(int)(y + fract*(r.y-y)),
(int)(d + fract*(r.d-d)),
(int)(w + fract*(r.w-w)),
(int)(h + fract*(r.h-h))
);
}
/** Whether it would make visually sense to interpolate
* this vob.
* Default implementation: whether the sum of the squares of
* the differences of the coordinates and widths is more than 100.
* Not a terribly useful measure but good enough.
*/
public boolean isInterpUseful() {
Vob r = interpTo;
if(r==null) return false;
return (r.x - x) * (r.x - x) +
(r.y - y) * (r.y - y) +
(r.w - w) * (r.w - w) +
(r.h - h) * (r.h - h) > 100;
}
/** Returns an object telling what was hit.
* Default implementation: returns null.
*/
public Object hit(int x, int y) { return null; }
/** A convenience routine to check whether a point
* is inside the defining rectangle.
* If the vob is (as many are) rectangular, this routine can
* be used to check the hit.
*/
public final boolean insideRect(int x0, int y0) {
return x0 >= x && y0 >= y && x0 < x+w && y0 < y+h;
}
}

66
Modules/vob/VobSet.java Normal file
View File

@@ -0,0 +1,66 @@
/*
VobSet.java
*
* Copyright (c) 2001, 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 Benjamin Fallenstein
*/
package org.gzigzag;
import java.util.*;
import java.awt.*;
/** A VobSet.
* This extends Vob in order to get interpolated. XXX is this right?
*/
public class VobSet extends Vob {
public static final String rcsid = "$Id: VobSet.java,v 1.1 2001/01/20 08:56:19 bfallenstein Exp $";
public static final boolean dbg = true;
private static final void p(String s) { if(dbg) System.out.println(s); }
private static final void pa(String s) { System.out.println(s); }
public VobStore store;
public ZZCell applitude;
public static ZZCell getApplitude(Vob vob) { return null; }
public void add(Vob vob, int vx, int vy, int vd) {
store.add(vob, vx+x, vy+y, vd+d, this);
}
public void add(Connection c, Vob from, Vob to) {
store.add(c, from, to, this);
}
/** Add a vob as a connection, i.e. in the middle between two other vobs.
* XXX how?
*/
public void add(Vob vob, Vob from, Vob to) {
}
public void add(Decoration d) {
store.add(d);
}
public int getX(Vob v) { return v.x - x; }
public int getY(Vob v) { return v.y - y; }
public int getD(Vob v) { return v.d - d; }
public int[] getCoords(Vob v) { return new int[] { v.x-x, v.y-y, v.d-d }; }
}

64
Modules/vob/VobStore.java Normal file
View File

@@ -0,0 +1,64 @@
/*
VobStore.java
*
* Copyright (c) 2001, 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 Benjamin Fallenstein
*/
package org.gzigzag;
import java.util.*;
import java.awt.*;
/** A store for Vobs.
*/
public class VobStore implements ZZScene {
public static final String rcsid = "$Id: VobStore.java,v 1.1 2001/01/20 08:56:19 bfallenstein Exp $";
public static final boolean dbg = true;
private static final void p(String s) { if(dbg) System.out.println(s); }
private static final void pa(String s) { System.out.println(s); }
public boolean interpConns = false;
/** Visual objects.
*/
private int nvobs;
private Vob[] vobs = new Vob[30];
boolean vsorted = false;
boolean vtagged = false;
/** Connections between vobs.
* These are rendered before (under) the vobs of the same depth. Note
* that they are interpolated if the interpConns flag is set.
*/
private int nconns;
private Connection[] conns = new Connection[30];
boolean csorted = false;
/** Decorations.
* These are always rendered last (above everything else). They are never
* interpolated.
*/
private int ndecors;
private Decoration[] decors = new Decoration[2];
// ??? private int maxdepth = 0;
}