created mirror
This commit is contained in:
36
Modules/awtool/AwtCursor.java
Normal file
36
Modules/awtool/AwtCursor.java
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
AwtCursor.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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class AwtCursor {
|
||||
Color color;
|
||||
boolean shared;
|
||||
public AwtCursor(Color cursorColor, boolean shared) {
|
||||
color = cursorColor;
|
||||
this.shared = shared;
|
||||
}
|
||||
}
|
||||
176
Modules/awtool/AwtLink.java
Normal file
176
Modules/awtool/AwtLink.java
Normal file
@@ -0,0 +1,176 @@
|
||||
/* DO NOT EDIT THIS FILE. THIS FILE WAS GENERATED FROM ../Modules/awtool/AwtLink.zob,
|
||||
* EDIT THAT FILE INSTEAD!
|
||||
* All changes to this file will be lost.
|
||||
*/
|
||||
/*
|
||||
AwtLink.zob
|
||||
*
|
||||
* Copyright (c) 1999-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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class AwtLink extends ZObCellRepr implements 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); }
|
||||
|
||||
|
||||
/** UNDOCUMENTED.
|
||||
|
||||
* <p>Default value: <PRE> 0.0;</PRE>.
|
||||
|
||||
* @structparam 1
|
||||
*/
|
||||
|
||||
public
|
||||
double x
|
||||
= 0.0;/** UNDOCUMENTED.
|
||||
|
||||
* <p>Default value: <PRE> 0.0;</PRE>.
|
||||
|
||||
* @structparam 1
|
||||
*/
|
||||
|
||||
public double y
|
||||
= 0.0;/** UNDOCUMENTED.
|
||||
|
||||
* <p>Default value: <PRE> false;</PRE>.
|
||||
|
||||
* @structparam 1
|
||||
*/
|
||||
|
||||
public boolean fixed
|
||||
= false;
|
||||
|
||||
|
||||
/* AUTOGENERATED! */
|
||||
static final private int fullmask = 7;
|
||||
|
||||
/* AUTOGENERATED! */
|
||||
public String readParams(ZZCell start) {
|
||||
int m = 0;
|
||||
try {
|
||||
if(start != null)
|
||||
m = readParams(start, 0);
|
||||
} catch(Throwable t) {
|
||||
ZZLogger.exc(t);
|
||||
} finally {
|
||||
|
||||
}
|
||||
if((m & fullmask) != fullmask) {
|
||||
// not all parameters present - no problem right now.
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/* AUTOGENERATED! */
|
||||
private int readParams(ZZCell start, int mask) {
|
||||
ZZCell n = start;
|
||||
while(n != null) {
|
||||
String s = n.getText();
|
||||
// Tests autogenerated from members.
|
||||
|
||||
if(s.equals("x")) {
|
||||
mask |= 1;
|
||||
try {
|
||||
ZZCell c = n.s("d.1"); s = c.getText(); x = (Double.valueOf(s)).doubleValue();
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
}
|
||||
} else
|
||||
|
||||
|
||||
if(s.equals("y")) {
|
||||
mask |= 2;
|
||||
try {
|
||||
ZZCell c = n.s("d.1"); s = c.getText(); y = (Double.valueOf(s)).doubleValue();
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
}
|
||||
} else
|
||||
|
||||
|
||||
if(s.equals("fixed")) {
|
||||
mask |= 4;
|
||||
try {
|
||||
ZZCell c = n.s("d.1"); s = c.getText();
|
||||
if(s.equals("true")) fixed=true;
|
||||
else if(s.equals("false")) fixed=false;
|
||||
else { /* XXX ??? */ }
|
||||
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
}
|
||||
} else
|
||||
|
||||
|
||||
{ } // grab that last "else"
|
||||
ZZCell h = n.h("d.3");
|
||||
if(h != null && h != n) {
|
||||
// recurse
|
||||
mask |= readParams(h, mask);
|
||||
}
|
||||
n = n.s("d.2");
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isFixed() { return fixed; }
|
||||
|
||||
public void setX(double x) { this.x = x; }
|
||||
public void setY(double y) { this.y = y; }
|
||||
|
||||
public double getX() { return x; }
|
||||
public double getY() { return y; }
|
||||
|
||||
public ZZCell toHeadCell() {
|
||||
return getCell().h(AwtUtil.d_from, 1).h(AwtUtil.d_clone);
|
||||
}
|
||||
|
||||
public ZZCell fromHeadCell() {
|
||||
return getCell().h(AwtUtil.d_to).h(AwtUtil.d_clone);
|
||||
}
|
||||
|
||||
public String getZObName() {
|
||||
return "Link";
|
||||
}
|
||||
|
||||
public String cellRepr(ZZCell start, boolean clone)
|
||||
{
|
||||
ZZCell c = start.getOrNewCell("d.1");
|
||||
c.setText(getZObClassName());
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText("x");
|
||||
c.getOrNewCell("d.1").setText(""+getX());
|
||||
c = c.getOrNewCell("d.2");
|
||||
c.setText("y");
|
||||
c.getOrNewCell("d.1").setText(""+getY());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// vim: set syntax=java :
|
||||
80
Modules/awtool/AwtLink.zob
Normal file
80
Modules/awtool/AwtLink.zob
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
AwtLink.zob
|
||||
*
|
||||
* Copyright (c) 1999-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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class AwtLink extends ZObCellRepr implements 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 {
|
||||
double x
|
||||
= 0.0;
|
||||
|
||||
double y
|
||||
= 0.0;
|
||||
|
||||
boolean fixed
|
||||
= false;
|
||||
}
|
||||
|
||||
public boolean isFixed() { return fixed; }
|
||||
|
||||
public void setX(double x) { this.x = x; }
|
||||
public void setY(double y) { this.y = y; }
|
||||
|
||||
public double getX() { return x; }
|
||||
public double getY() { return y; }
|
||||
|
||||
public ZZCell toHeadCell() {
|
||||
return getCell().h(AwtUtil.d_from, 1).h(AwtUtil.d_clone);
|
||||
}
|
||||
|
||||
public ZZCell fromHeadCell() {
|
||||
return getCell().h(AwtUtil.d_to).h(AwtUtil.d_clone);
|
||||
}
|
||||
|
||||
public String getZObName() {
|
||||
return "Link";
|
||||
}
|
||||
|
||||
public String cellRepr(ZZCell start, boolean clone)
|
||||
{
|
||||
ZZCell c = start.getOrNewCell("d.1");
|
||||
c.setText(getZObClassName());
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText("x");
|
||||
c.getOrNewCell("d.1").setText(""+getX());
|
||||
c = c.getOrNewCell("d.2");
|
||||
c.setText("y");
|
||||
c.getOrNewCell("d.1").setText(""+getY());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// vim: set syntax=java :
|
||||
502
Modules/awtool/AwtMetrics.java
Normal file
502
Modules/awtool/AwtMetrics.java
Normal file
@@ -0,0 +1,502 @@
|
||||
/* DO NOT EDIT THIS FILE. THIS FILE WAS GENERATED FROM ../Modules/awtool/AwtMetrics.zob,
|
||||
* EDIT THAT FILE INSTEAD!
|
||||
* All changes to this file will be lost.
|
||||
*/
|
||||
/*
|
||||
AwtMetrics.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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
/** Abstract class for different metrics (in order to get different
|
||||
* focus+context effects)
|
||||
*/
|
||||
|
||||
public abstract class AwtMetrics extends ZObCellRepr implements ZOb {
|
||||
public static boolean dbg = true;
|
||||
static void p(String s) { if(dbg) System.out.println(s); }
|
||||
static void pa(String s) { System.out.println(s); }
|
||||
|
||||
|
||||
/** UNDOCUMENTED.
|
||||
|
||||
* <p>Default value: <PRE> { 400, 400 };</PRE>.
|
||||
|
||||
* @structparam 1
|
||||
*/
|
||||
|
||||
public
|
||||
int[] RealView
|
||||
= { 400, 400 };/** UNDOCUMENTED.
|
||||
|
||||
* <p>Default value: <PRE> { 400, 400 };</PRE>.
|
||||
|
||||
* @structparam 1
|
||||
*/
|
||||
|
||||
public int[] VirtualView
|
||||
= { 400, 400 };/** UNDOCUMENTED.
|
||||
|
||||
* <p>Default value: <PRE> { 0.0, 0.0 };</PRE>.
|
||||
|
||||
* @structparam 1
|
||||
*/
|
||||
|
||||
public double[] Origo
|
||||
= { 0.0, 0.0 };/** UNDOCUMENTED.
|
||||
|
||||
* <p>Default value: <PRE> { 200, 200 };</PRE>.
|
||||
|
||||
* @structparam 1
|
||||
*/
|
||||
|
||||
public int[] FocusOrigo
|
||||
= { 200, 200 };/** UNDOCUMENTED.
|
||||
|
||||
* <p>Default value: <PRE> true;</PRE>.
|
||||
|
||||
* @structparam 1
|
||||
*/
|
||||
|
||||
public boolean GridOn
|
||||
= true;
|
||||
|
||||
/* AUTOGENERATED! */
|
||||
static final private int fullmask = 31;
|
||||
|
||||
/* AUTOGENERATED! */
|
||||
public String readParams(ZZCell start) {
|
||||
int m = 0;
|
||||
try {
|
||||
if(start != null)
|
||||
m = readParams(start, 0);
|
||||
} catch(Throwable t) {
|
||||
ZZLogger.exc(t);
|
||||
} finally {
|
||||
|
||||
}
|
||||
if((m & fullmask) != fullmask) {
|
||||
// not all parameters present - no problem right now.
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/* AUTOGENERATED! */
|
||||
private int readParams(ZZCell start, int mask) {
|
||||
ZZCell n = start;
|
||||
while(n != null) {
|
||||
String s = n.getText();
|
||||
// Tests autogenerated from members.
|
||||
|
||||
if(s.equals("RealView")) {
|
||||
mask |= 1;
|
||||
try {
|
||||
|
||||
// count rank
|
||||
int i=-1;
|
||||
for(ZZCell c = n; c!=null; c=c.s("d.1")) i++;
|
||||
// XXX check range
|
||||
RealView = new int[i];
|
||||
i=0;
|
||||
for(ZZCell c = n.s("d.1");
|
||||
c!=null; c=c.s("d.1")) {
|
||||
s = c.getText();
|
||||
RealView[i] = Integer.parseInt(s); ;
|
||||
i++;
|
||||
}
|
||||
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
}
|
||||
} else
|
||||
|
||||
|
||||
if(s.equals("VirtualView")) {
|
||||
mask |= 2;
|
||||
try {
|
||||
|
||||
// count rank
|
||||
int i=-1;
|
||||
for(ZZCell c = n; c!=null; c=c.s("d.1")) i++;
|
||||
// XXX check range
|
||||
VirtualView = new int[i];
|
||||
i=0;
|
||||
for(ZZCell c = n.s("d.1");
|
||||
c!=null; c=c.s("d.1")) {
|
||||
s = c.getText();
|
||||
VirtualView[i] = Integer.parseInt(s); ;
|
||||
i++;
|
||||
}
|
||||
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
}
|
||||
} else
|
||||
|
||||
|
||||
if(s.equals("Origo")) {
|
||||
mask |= 4;
|
||||
try {
|
||||
|
||||
// count rank
|
||||
int i=-1;
|
||||
for(ZZCell c = n; c!=null; c=c.s("d.1")) i++;
|
||||
// XXX check range
|
||||
Origo = new double[i];
|
||||
i=0;
|
||||
for(ZZCell c = n.s("d.1");
|
||||
c!=null; c=c.s("d.1")) {
|
||||
s = c.getText();
|
||||
Origo[i] = (Double.valueOf(s)).doubleValue();;
|
||||
i++;
|
||||
}
|
||||
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
}
|
||||
} else
|
||||
|
||||
|
||||
if(s.equals("FocusOrigo")) {
|
||||
mask |= 8;
|
||||
try {
|
||||
|
||||
// count rank
|
||||
int i=-1;
|
||||
for(ZZCell c = n; c!=null; c=c.s("d.1")) i++;
|
||||
// XXX check range
|
||||
FocusOrigo = new int[i];
|
||||
i=0;
|
||||
for(ZZCell c = n.s("d.1");
|
||||
c!=null; c=c.s("d.1")) {
|
||||
s = c.getText();
|
||||
FocusOrigo[i] = Integer.parseInt(s); ;
|
||||
i++;
|
||||
}
|
||||
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
}
|
||||
} else
|
||||
|
||||
|
||||
if(s.equals("GridOn")) {
|
||||
mask |= 16;
|
||||
try {
|
||||
ZZCell c = n.s("d.1"); s = c.getText();
|
||||
if(s.equals("true")) GridOn=true;
|
||||
else if(s.equals("false")) GridOn=false;
|
||||
else { /* XXX ??? */ }
|
||||
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
}
|
||||
} else
|
||||
|
||||
|
||||
{ } // grab that last "else"
|
||||
ZZCell h = n.h("d.3");
|
||||
if(h != null && h != n) {
|
||||
// recurse
|
||||
mask |= readParams(h, mask);
|
||||
}
|
||||
n = n.s("d.2");
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static ZZCell FocusedCell = null;
|
||||
|
||||
double FocusCoefficient = focusCoefficientMinimum();
|
||||
|
||||
abstract double focusCoefficientMinimum();
|
||||
abstract double focusCoefficientMaximum();
|
||||
|
||||
public double[] RealViewd() {
|
||||
return new double[] { (double)RealView[0], (double)RealView[1] };
|
||||
}
|
||||
|
||||
public double[] RealViewHalfd() {
|
||||
return new double[] { (double)RealView[0]*0.5, (double)RealView[1]*0.5 };
|
||||
}
|
||||
|
||||
public void setRealView(int x, int y, boolean adjustFocus) {
|
||||
if(adjustFocus) {
|
||||
double[] rvd = RealViewd();
|
||||
double newfox = ((double)(x*FocusOrigo[0]))/rvd[0];
|
||||
double newfoy = ((double)(y*FocusOrigo[1]))/rvd[1];
|
||||
setFocusOrigo((int)newfox, (int)newfoy);
|
||||
}
|
||||
RealView[0] = x; RealView[1] = y;
|
||||
}
|
||||
|
||||
public void setRealView(Dimension d, boolean adjustFocus) {
|
||||
setRealView(d.width, d.height, adjustFocus);
|
||||
}
|
||||
public double[] VirtualViewd() {
|
||||
return new double[] { (double)VirtualView[0], (double)VirtualView[1] };
|
||||
}
|
||||
|
||||
public double[] VirtualViewHalfd() {
|
||||
return new double[] { (double)VirtualView[0]*0.5, (double)VirtualView[1]*0.5 };
|
||||
}
|
||||
|
||||
public void setVirtualView(int x, int y) {
|
||||
VirtualView[0] = x; VirtualView[1] = y;
|
||||
}
|
||||
|
||||
public void setOrigo(double ox, double oy) {
|
||||
Origo[0] = ox;
|
||||
Origo[1] = oy;
|
||||
}
|
||||
|
||||
public void moveOrigo(double dox, double doy) {
|
||||
Origo[0] += dox;
|
||||
Origo[1] += doy;
|
||||
}
|
||||
|
||||
public double[] FocusOrigod() {
|
||||
return new double[] { (double)FocusOrigo[0], (double)FocusOrigo[1] };
|
||||
}
|
||||
|
||||
|
||||
public void setFocusOrigo(int fox, int foy) {
|
||||
setFocusOrigo(fox, foy, null);
|
||||
}
|
||||
|
||||
public void setFocusOrigo(int fox, int foy, ZZCell focusCell) {
|
||||
FocusOrigo[0] = fox;
|
||||
FocusOrigo[1] = foy;
|
||||
if(focusCell != null && focusCell == FocusedCell) {
|
||||
FocusCoefficient += 1.0;
|
||||
if(FocusCoefficient > focusCoefficientMaximum())
|
||||
FocusCoefficient = focusCoefficientMaximum();
|
||||
} else {
|
||||
FocusCoefficient = focusCoefficientMinimum();
|
||||
FocusedCell = focusCell;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void init(ZZCell start, Dimension rv, Dimension vv,
|
||||
double ox, double oy) {
|
||||
setCell(start);
|
||||
setRealView(rv.width, rv.height, false);
|
||||
setVirtualView(vv.width, vv.height);
|
||||
setOrigo(ox, oy);
|
||||
setFocusOrigo(rv.width>>1, rv.height>>1);
|
||||
}
|
||||
|
||||
public AwtMetrics() { }
|
||||
|
||||
public AwtMetrics(ZZCell start, Dimension rv, Dimension vv,
|
||||
double ox, double oy)
|
||||
{
|
||||
init(start, rv, vv, ox, oy);
|
||||
|
||||
}
|
||||
|
||||
private Point mapToUnfocusedRealView(double x, double y) {
|
||||
int rx, ry;
|
||||
double[] vvhd = VirtualViewHalfd(), rvhd = RealViewHalfd();
|
||||
rx = (int)(( (x-Origo[0]) * vvhd[0]) + rvhd[0]);
|
||||
ry = (int)(( (y-Origo[1]) * vvhd[1]) + rvhd[1]);
|
||||
return new Point(rx, ry);
|
||||
}
|
||||
|
||||
/** mapping from 'virtualview' (=modelview, coordinates
|
||||
* -1.0<x,y<1.0) to 'realview' (coordinates in this.RealView).
|
||||
* can be used for example in order to gain an illusion of focus+context
|
||||
* by demagnifying areas near focus. ceturns 'realview' coordinates.
|
||||
* @param x x-coordinate ranging from -infinity ... infinity
|
||||
* @param y y-coordinate
|
||||
*/
|
||||
public Point mapToRealView(double x, double y) {
|
||||
Point ufr; // unfocused realview point
|
||||
ufr = mapToUnfocusedRealView(x, y);
|
||||
return focusRealView(ufr.x, ufr.y);
|
||||
}
|
||||
|
||||
/** reverse mapping, see 'mapToRealView' */
|
||||
public double[] mapToVirtualView(int rx, int ry) {
|
||||
double x, y;
|
||||
double[] vvhd = VirtualViewHalfd(), rvhd = RealViewHalfd();
|
||||
Point iCoord = inverseTransform(rx, ry);
|
||||
x = (((double)iCoord.x - rvhd[0]) / vvhd[0]) + Origo[0];
|
||||
y = (((double)iCoord.y - rvhd[1]) / vvhd[1]) + Origo[1];
|
||||
return new double[] { x, y };
|
||||
}
|
||||
|
||||
public Point mapToRealView(double[] coord) {
|
||||
return mapToRealView(coord[0], coord[1]);
|
||||
}
|
||||
|
||||
public Point focusRealView(int x, int y) {
|
||||
double xFocus, yFocus, dx, dy;
|
||||
double[] d;
|
||||
double[] vvhd = VirtualViewHalfd();
|
||||
xFocus = (double)(x - FocusOrigo[0]);
|
||||
yFocus = (double)(y - FocusOrigo[1]);
|
||||
d = transformAtFocusNbhood(xFocus/vvhd[0], yFocus/vvhd[1]);
|
||||
return new Point(FocusOrigo[0]+(int)(vvhd[0]*d[0]), FocusOrigo[1]+(int)(vvhd[1]*d[1]));
|
||||
}
|
||||
|
||||
public Point inverseTransform(int x, int y) {
|
||||
double xFocus, yFocus, dx, dy;
|
||||
double[] d;
|
||||
double[] vvhd = VirtualViewHalfd();
|
||||
xFocus = (double)(x - FocusOrigo[0]);
|
||||
yFocus = (double)(y - FocusOrigo[1]);
|
||||
d = inverseTransformAtFocusNbhood(xFocus/vvhd[0], yFocus/vvhd[1]);
|
||||
return new Point(FocusOrigo[0]+(int)(vvhd[0]*d[0]), FocusOrigo[1]+(int)(vvhd[1]*d[1]));
|
||||
}
|
||||
|
||||
public double[] getVirtualDimension(int x, int y, Dimension dim) {
|
||||
double s = getInverseScalingValue(x, y);
|
||||
double[] vvhd = VirtualViewHalfd();
|
||||
return new double[] {s*(double)dim.width/vvhd[0], s*(double)dim.height/vvhd[1]};
|
||||
}
|
||||
|
||||
public Dimension getRealDimension(double x, double y, double[] dim) {
|
||||
double s = getScalingValue(x, y);
|
||||
double[] vvhd = VirtualViewHalfd();
|
||||
return new Dimension((int)(s*(double)dim[0]*vvhd[0]), (int)(s*(double)dim[1]*vvhd[1]));
|
||||
}
|
||||
|
||||
|
||||
abstract public double[] transformAtFocusNbhood(double x, double y,
|
||||
double focusCoeff);
|
||||
|
||||
abstract public double[] inverseTransformAtFocusNbhood(double x, double
|
||||
y, double focusCoeff);
|
||||
|
||||
abstract public double transformScalingValue(double s);
|
||||
|
||||
|
||||
public double[] transformAtFocusNbhood(double x, double y) {
|
||||
return transformAtFocusNbhood(x, y, FocusCoefficient);
|
||||
}
|
||||
|
||||
public double[] inverseTransformAtFocusNbhood(double x, double y) {
|
||||
return inverseTransformAtFocusNbhood(x, y, FocusCoefficient);
|
||||
}
|
||||
|
||||
|
||||
public double getScalingValue(double x, double y) {
|
||||
double d1x, d1y, d2x, d2y, s;
|
||||
|
||||
Point ufr, invf; // unfocused realview point, inverse focus point
|
||||
Point rPoint = mapToRealView(x, y);
|
||||
|
||||
d1x = (double)(rPoint.x-FocusOrigo[0]);
|
||||
d1y = (double)(rPoint.y-FocusOrigo[1]);
|
||||
|
||||
ufr = mapToUnfocusedRealView(x, y);
|
||||
invf = inverseTransform(FocusOrigo[0], FocusOrigo[1]);
|
||||
|
||||
d2x = (double)(ufr.x-invf.x);
|
||||
d2y = (double)(ufr.y-invf.y);
|
||||
|
||||
s = Math.sqrt((d1x*d1x + d1y*d1y)/(d2x*d2x + d2y*d2y));
|
||||
|
||||
return transformScalingValue(s);
|
||||
}
|
||||
|
||||
public double getInverseScalingValue(int rx, int ry) {
|
||||
double d1x, d1y, d2x, d2y, s;
|
||||
Point ufr, invf; // unfocused realview point, inverse focus point
|
||||
|
||||
d1x = rx-FocusOrigo[0];
|
||||
d1y = ry-FocusOrigo[1];
|
||||
|
||||
ufr = inverseTransform(rx, ry);
|
||||
invf = inverseTransform(FocusOrigo[0], FocusOrigo[1]);
|
||||
|
||||
d2x = (double)(ufr.x-invf.x);
|
||||
d2y = (double)(ufr.y-invf.y);
|
||||
|
||||
s = Math.sqrt((d2x*d2x + d2y*d2y)/(d1x*d1x + d1y*d1y));
|
||||
|
||||
return transformScalingValue(s);
|
||||
}
|
||||
|
||||
public boolean RealViewEquals(Dimension view) {
|
||||
if(view.width==RealView[0] && view.height==RealView[1])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Write the parameters of this ZOb back in the cellstructure.
|
||||
* Returns a string describing the errors encountered, or null if
|
||||
* everything went fine..
|
||||
* @param c starting cell
|
||||
* @param clone whether or not to make the new ZOb centralcell a clone
|
||||
* of the former centralcell (if cells equal, the whole
|
||||
* issue is trivial).
|
||||
*/
|
||||
|
||||
String cellRepr(ZZCell start, boolean clone) {
|
||||
ZZCell c2, c = start.getOrNewCell("d.1");
|
||||
start.setText(getZObName());
|
||||
c.setText(getZObClassName());
|
||||
c = c2 = c.getOrNewCell("d.1");
|
||||
c.setText("RealView");
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+RealView[0]);
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+RealView[1]);
|
||||
|
||||
c = c2 = c2.getOrNewCell("d.2");
|
||||
c.setText("VirtualView");
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+VirtualView[0]);
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+VirtualView[1]);
|
||||
|
||||
c = c2 = c2.getOrNewCell("d.2");
|
||||
c.setText("Origo");
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+Origo[0]);
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+Origo[1]);
|
||||
|
||||
c = c2 = c2.getOrNewCell("d.2");
|
||||
c.setText("FocusOrigo");
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+FocusOrigo[0]);
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+FocusOrigo[1]);
|
||||
|
||||
c = c2 = c2.getOrNewCell("d.2");
|
||||
c.setText("GridOn");
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+GridOn);
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
326
Modules/awtool/AwtMetrics.zob
Normal file
326
Modules/awtool/AwtMetrics.zob
Normal file
@@ -0,0 +1,326 @@
|
||||
/*
|
||||
AwtMetrics.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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
/** Abstract class for different metrics (in order to get different
|
||||
* focus+context effects)
|
||||
*/
|
||||
|
||||
public abstract class AwtMetrics extends ZObCellRepr implements ZOb {
|
||||
public static boolean dbg = true;
|
||||
static void p(String s) { if(dbg) System.out.println(s); }
|
||||
static void pa(String s) { System.out.println(s); }
|
||||
|
||||
STRUCTPARAMS {
|
||||
int[] RealView
|
||||
= { 400, 400 };
|
||||
|
||||
int[] VirtualView
|
||||
= { 400, 400 };
|
||||
|
||||
double[] Origo
|
||||
= { 0.0, 0.0 };
|
||||
|
||||
int[] FocusOrigo
|
||||
= { 200, 200 };
|
||||
|
||||
boolean GridOn
|
||||
= true;
|
||||
|
||||
}
|
||||
|
||||
static ZZCell FocusedCell = null;
|
||||
|
||||
double FocusCoefficient = focusCoefficientMinimum();
|
||||
|
||||
abstract double focusCoefficientMinimum();
|
||||
abstract double focusCoefficientMaximum();
|
||||
|
||||
public double[] RealViewd() {
|
||||
return new double[] { (double)RealView[0], (double)RealView[1] };
|
||||
}
|
||||
|
||||
public double[] RealViewHalfd() {
|
||||
return new double[] { (double)RealView[0]*0.5, (double)RealView[1]*0.5 };
|
||||
}
|
||||
|
||||
public void setRealView(int x, int y, boolean adjustFocus) {
|
||||
if(adjustFocus) {
|
||||
double[] rvd = RealViewd();
|
||||
double newfox = ((double)(x*FocusOrigo[0]))/rvd[0];
|
||||
double newfoy = ((double)(y*FocusOrigo[1]))/rvd[1];
|
||||
setFocusOrigo((int)newfox, (int)newfoy);
|
||||
}
|
||||
RealView[0] = x; RealView[1] = y;
|
||||
}
|
||||
|
||||
public void setRealView(Dimension d, boolean adjustFocus) {
|
||||
setRealView(d.width, d.height, adjustFocus);
|
||||
}
|
||||
public double[] VirtualViewd() {
|
||||
return new double[] { (double)VirtualView[0], (double)VirtualView[1] };
|
||||
}
|
||||
|
||||
public double[] VirtualViewHalfd() {
|
||||
return new double[] { (double)VirtualView[0]*0.5, (double)VirtualView[1]*0.5 };
|
||||
}
|
||||
|
||||
public void setVirtualView(int x, int y) {
|
||||
VirtualView[0] = x; VirtualView[1] = y;
|
||||
}
|
||||
|
||||
public void setOrigo(double ox, double oy) {
|
||||
Origo[0] = ox;
|
||||
Origo[1] = oy;
|
||||
}
|
||||
|
||||
public void moveOrigo(double dox, double doy) {
|
||||
Origo[0] += dox;
|
||||
Origo[1] += doy;
|
||||
}
|
||||
|
||||
public double[] FocusOrigod() {
|
||||
return new double[] { (double)FocusOrigo[0], (double)FocusOrigo[1] };
|
||||
}
|
||||
|
||||
|
||||
public void setFocusOrigo(int fox, int foy) {
|
||||
setFocusOrigo(fox, foy, null);
|
||||
}
|
||||
|
||||
public void setFocusOrigo(int fox, int foy, ZZCell focusCell) {
|
||||
FocusOrigo[0] = fox;
|
||||
FocusOrigo[1] = foy;
|
||||
if(focusCell != null && focusCell == FocusedCell) {
|
||||
FocusCoefficient += 1.0;
|
||||
if(FocusCoefficient > focusCoefficientMaximum())
|
||||
FocusCoefficient = focusCoefficientMaximum();
|
||||
} else {
|
||||
FocusCoefficient = focusCoefficientMinimum();
|
||||
FocusedCell = focusCell;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void init(ZZCell start, Dimension rv, Dimension vv,
|
||||
double ox, double oy) {
|
||||
setCell(start);
|
||||
setRealView(rv.width, rv.height, false);
|
||||
setVirtualView(vv.width, vv.height);
|
||||
setOrigo(ox, oy);
|
||||
setFocusOrigo(rv.width>>1, rv.height>>1);
|
||||
}
|
||||
|
||||
public AwtMetrics() { }
|
||||
|
||||
public AwtMetrics(ZZCell start, Dimension rv, Dimension vv,
|
||||
double ox, double oy)
|
||||
{
|
||||
init(start, rv, vv, ox, oy);
|
||||
|
||||
}
|
||||
|
||||
private Point mapToUnfocusedRealView(double x, double y) {
|
||||
int rx, ry;
|
||||
double[] vvhd = VirtualViewHalfd(), rvhd = RealViewHalfd();
|
||||
rx = (int)(( (x-Origo[0]) * vvhd[0]) + rvhd[0]);
|
||||
ry = (int)(( (y-Origo[1]) * vvhd[1]) + rvhd[1]);
|
||||
return new Point(rx, ry);
|
||||
}
|
||||
|
||||
/** mapping from 'virtualview' (=modelview, coordinates
|
||||
* -1.0<x,y<1.0) to 'realview' (coordinates in this.RealView).
|
||||
* can be used for example in order to gain an illusion of focus+context
|
||||
* by demagnifying areas near focus. ceturns 'realview' coordinates.
|
||||
* @param x x-coordinate ranging from -infinity ... infinity
|
||||
* @param y y-coordinate
|
||||
*/
|
||||
public Point mapToRealView(double x, double y) {
|
||||
Point ufr; // unfocused realview point
|
||||
ufr = mapToUnfocusedRealView(x, y);
|
||||
return focusRealView(ufr.x, ufr.y);
|
||||
}
|
||||
|
||||
/** reverse mapping, see 'mapToRealView' */
|
||||
public double[] mapToVirtualView(int rx, int ry) {
|
||||
double x, y;
|
||||
double[] vvhd = VirtualViewHalfd(), rvhd = RealViewHalfd();
|
||||
Point iCoord = inverseTransform(rx, ry);
|
||||
x = (((double)iCoord.x - rvhd[0]) / vvhd[0]) + Origo[0];
|
||||
y = (((double)iCoord.y - rvhd[1]) / vvhd[1]) + Origo[1];
|
||||
return new double[] { x, y };
|
||||
}
|
||||
|
||||
public Point mapToRealView(double[] coord) {
|
||||
return mapToRealView(coord[0], coord[1]);
|
||||
}
|
||||
|
||||
public Point focusRealView(int x, int y) {
|
||||
double xFocus, yFocus, dx, dy;
|
||||
double[] d;
|
||||
double[] vvhd = VirtualViewHalfd();
|
||||
xFocus = (double)(x - FocusOrigo[0]);
|
||||
yFocus = (double)(y - FocusOrigo[1]);
|
||||
d = transformAtFocusNbhood(xFocus/vvhd[0], yFocus/vvhd[1]);
|
||||
return new Point(FocusOrigo[0]+(int)(vvhd[0]*d[0]), FocusOrigo[1]+(int)(vvhd[1]*d[1]));
|
||||
}
|
||||
|
||||
public Point inverseTransform(int x, int y) {
|
||||
double xFocus, yFocus, dx, dy;
|
||||
double[] d;
|
||||
double[] vvhd = VirtualViewHalfd();
|
||||
xFocus = (double)(x - FocusOrigo[0]);
|
||||
yFocus = (double)(y - FocusOrigo[1]);
|
||||
d = inverseTransformAtFocusNbhood(xFocus/vvhd[0], yFocus/vvhd[1]);
|
||||
return new Point(FocusOrigo[0]+(int)(vvhd[0]*d[0]), FocusOrigo[1]+(int)(vvhd[1]*d[1]));
|
||||
}
|
||||
|
||||
public double[] getVirtualDimension(int x, int y, Dimension dim) {
|
||||
double s = getInverseScalingValue(x, y);
|
||||
double[] vvhd = VirtualViewHalfd();
|
||||
return new double[] {s*(double)dim.width/vvhd[0], s*(double)dim.height/vvhd[1]};
|
||||
}
|
||||
|
||||
public Dimension getRealDimension(double x, double y, double[] dim) {
|
||||
double s = getScalingValue(x, y);
|
||||
double[] vvhd = VirtualViewHalfd();
|
||||
return new Dimension((int)(s*(double)dim[0]*vvhd[0]), (int)(s*(double)dim[1]*vvhd[1]));
|
||||
}
|
||||
|
||||
|
||||
abstract public double[] transformAtFocusNbhood(double x, double y,
|
||||
double focusCoeff);
|
||||
|
||||
abstract public double[] inverseTransformAtFocusNbhood(double x, double
|
||||
y, double focusCoeff);
|
||||
|
||||
abstract public double transformScalingValue(double s);
|
||||
|
||||
|
||||
public double[] transformAtFocusNbhood(double x, double y) {
|
||||
return transformAtFocusNbhood(x, y, FocusCoefficient);
|
||||
}
|
||||
|
||||
public double[] inverseTransformAtFocusNbhood(double x, double y) {
|
||||
return inverseTransformAtFocusNbhood(x, y, FocusCoefficient);
|
||||
}
|
||||
|
||||
|
||||
public double getScalingValue(double x, double y) {
|
||||
double d1x, d1y, d2x, d2y, s;
|
||||
|
||||
Point ufr, invf; // unfocused realview point, inverse focus point
|
||||
Point rPoint = mapToRealView(x, y);
|
||||
|
||||
d1x = (double)(rPoint.x-FocusOrigo[0]);
|
||||
d1y = (double)(rPoint.y-FocusOrigo[1]);
|
||||
|
||||
ufr = mapToUnfocusedRealView(x, y);
|
||||
invf = inverseTransform(FocusOrigo[0], FocusOrigo[1]);
|
||||
|
||||
d2x = (double)(ufr.x-invf.x);
|
||||
d2y = (double)(ufr.y-invf.y);
|
||||
|
||||
s = Math.sqrt((d1x*d1x + d1y*d1y)/(d2x*d2x + d2y*d2y));
|
||||
|
||||
return transformScalingValue(s);
|
||||
}
|
||||
|
||||
public double getInverseScalingValue(int rx, int ry) {
|
||||
double d1x, d1y, d2x, d2y, s;
|
||||
Point ufr, invf; // unfocused realview point, inverse focus point
|
||||
|
||||
d1x = rx-FocusOrigo[0];
|
||||
d1y = ry-FocusOrigo[1];
|
||||
|
||||
ufr = inverseTransform(rx, ry);
|
||||
invf = inverseTransform(FocusOrigo[0], FocusOrigo[1]);
|
||||
|
||||
d2x = (double)(ufr.x-invf.x);
|
||||
d2y = (double)(ufr.y-invf.y);
|
||||
|
||||
s = Math.sqrt((d2x*d2x + d2y*d2y)/(d1x*d1x + d1y*d1y));
|
||||
|
||||
return transformScalingValue(s);
|
||||
}
|
||||
|
||||
public boolean RealViewEquals(Dimension view) {
|
||||
if(view.width==RealView[0] && view.height==RealView[1])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Write the parameters of this ZOb back in the cellstructure.
|
||||
* Returns a string describing the errors encountered, or null if
|
||||
* everything went fine..
|
||||
* @param c starting cell
|
||||
* @param clone whether or not to make the new ZOb centralcell a clone
|
||||
* of the former centralcell (if cells equal, the whole
|
||||
* issue is trivial).
|
||||
*/
|
||||
|
||||
String cellRepr(ZZCell start, boolean clone) {
|
||||
ZZCell c2, c = start.getOrNewCell("d.1");
|
||||
start.setText(getZObName());
|
||||
c.setText(getZObClassName());
|
||||
c = c2 = c.getOrNewCell("d.1");
|
||||
c.setText("RealView");
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+RealView[0]);
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+RealView[1]);
|
||||
|
||||
c = c2 = c2.getOrNewCell("d.2");
|
||||
c.setText("VirtualView");
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+VirtualView[0]);
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+VirtualView[1]);
|
||||
|
||||
c = c2 = c2.getOrNewCell("d.2");
|
||||
c.setText("Origo");
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+Origo[0]);
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+Origo[1]);
|
||||
|
||||
c = c2 = c2.getOrNewCell("d.2");
|
||||
c.setText("FocusOrigo");
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+FocusOrigo[0]);
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+FocusOrigo[1]);
|
||||
|
||||
c = c2 = c2.getOrNewCell("d.2");
|
||||
c.setText("GridOn");
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText(""+GridOn);
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
94
Modules/awtool/AwtMetricsFC.java
Normal file
94
Modules/awtool/AwtMetricsFC.java
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
AwtMetricsNormal.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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
/** Focus+context metrics1
|
||||
*/
|
||||
|
||||
|
||||
public class AwtMetricsFC extends AwtMetrics {
|
||||
public String getZObName() {
|
||||
return "Focus+Context";
|
||||
}
|
||||
|
||||
public double[] transformAtFocusNbhood(double x, double y, double focusCoeff) {
|
||||
double dx, dy, x2, y2;
|
||||
|
||||
x2 = x*focusCoeff;
|
||||
y2 = y*focusCoeff;
|
||||
|
||||
if(x2<1 && x2>-1) {
|
||||
dx = x2;
|
||||
} else {
|
||||
dx = x2*x2;
|
||||
dx = x2>0 ? dx : -dx;
|
||||
}
|
||||
|
||||
if(y2<1 && y2>-1) {
|
||||
dy = y2;
|
||||
} else {
|
||||
dy = y2*y2;
|
||||
dy = y2>0 ? dy : -dy;
|
||||
}
|
||||
|
||||
return new double[] { dx/focusCoeff, dy/focusCoeff };
|
||||
}
|
||||
|
||||
public double[] inverseTransformAtFocusNbhood(double x, double y, double focusCoeff) {
|
||||
double dx, dy, x2, y2;
|
||||
|
||||
x2 = x*focusCoeff;
|
||||
y2 = y*focusCoeff;
|
||||
|
||||
if(x2<1 && x2>-1) {
|
||||
dx = x2;
|
||||
} else {
|
||||
dx = (x2>0) ? Math.sqrt(x2) : -Math.sqrt(-x2);
|
||||
}
|
||||
|
||||
if(y2<1 && y2>-1) {
|
||||
dy = y2;
|
||||
} else {
|
||||
dy = (y2>0) ? Math.sqrt(y2) : -Math.sqrt(-y2);
|
||||
}
|
||||
|
||||
return new double[] { dx/focusCoeff, dy/focusCoeff };
|
||||
}
|
||||
|
||||
public double transformScalingValue(double s) { return 1.0/s; }
|
||||
|
||||
public double focusCoefficientMinimum() { return 4.0; }
|
||||
public double focusCoefficientMaximum() { return 8.0; }
|
||||
|
||||
public AwtMetricsFC() { super(); }
|
||||
|
||||
public AwtMetricsFC(ZZCell start, Dimension rv, Dimension vv,
|
||||
double ox, double oy) {
|
||||
super(start, rv, vv, ox, oy);
|
||||
}
|
||||
}
|
||||
|
||||
94
Modules/awtool/AwtMetricsFC2.java
Normal file
94
Modules/awtool/AwtMetricsFC2.java
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
AwtMetricsFC2.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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
/** Focus+context metrics2
|
||||
*/
|
||||
|
||||
|
||||
public class AwtMetricsFC2 extends AwtMetrics {
|
||||
public String getZObName() {
|
||||
return "Focus+Context (2)";
|
||||
}
|
||||
|
||||
public double[] transformAtFocusNbhood(double x, double y, double focusCoeff) {
|
||||
double dx, dy, x2, y2;
|
||||
|
||||
x2 = x*focusCoeff;
|
||||
y2 = y*focusCoeff;
|
||||
|
||||
if(x2<1 && x2>-1) {
|
||||
dx = x2;
|
||||
} else {
|
||||
dx = (x2>0) ? Math.sqrt(x2) : -Math.sqrt(-x2);
|
||||
}
|
||||
|
||||
if(y2<1 && y2>-1) {
|
||||
dy = y2;
|
||||
} else {
|
||||
dy = (y2>0) ? Math.sqrt(y2) : -Math.sqrt(-y2);
|
||||
}
|
||||
|
||||
return new double[] { dx/focusCoeff, dy/focusCoeff };
|
||||
}
|
||||
|
||||
public double[] inverseTransformAtFocusNbhood(double x, double y, double focusCoeff) {
|
||||
double dx, dy, x2, y2;
|
||||
|
||||
x2 = x*focusCoeff;
|
||||
y2 = y*focusCoeff;
|
||||
|
||||
if(x2<1 && x2>-1) {
|
||||
dx = x2;
|
||||
} else {
|
||||
dx = x2*x2;
|
||||
dx = x2>0 ? dx : -dx;
|
||||
}
|
||||
|
||||
if(y2<1 && y2>-1) {
|
||||
dy = y2;
|
||||
} else {
|
||||
dy = y2*y2;
|
||||
dy = y2>0 ? dy : -dy;
|
||||
}
|
||||
|
||||
return new double[] { dx/focusCoeff, dy/focusCoeff };
|
||||
}
|
||||
|
||||
public double transformScalingValue(double s) { return s; }
|
||||
|
||||
public double focusCoefficientMinimum() { return 4.0; }
|
||||
public double focusCoefficientMaximum() { return 8.0; }
|
||||
|
||||
public AwtMetricsFC2() { super(); }
|
||||
|
||||
public AwtMetricsFC2(ZZCell start, Dimension rv, Dimension vv,
|
||||
double ox, double oy) {
|
||||
super(start, rv, vv, ox, oy);
|
||||
}
|
||||
}
|
||||
|
||||
58
Modules/awtool/AwtMetricsNormal.java
Normal file
58
Modules/awtool/AwtMetricsNormal.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
AwtMetricsNormal.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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
/** Default metrics: Euclidean, no focus+context (no scaling)
|
||||
*/
|
||||
|
||||
|
||||
public class AwtMetricsNormal extends AwtMetrics {
|
||||
public String getZObName() {
|
||||
return "Normal(Euclidean)";
|
||||
}
|
||||
|
||||
public double[] transformAtFocusNbhood(double x, double y, double focusCoeff) {
|
||||
return new double[] { x, y };
|
||||
}
|
||||
|
||||
public double[] inverseTransformAtFocusNbhood(double x, double y, double focusCoeff) {
|
||||
return new double[] { x, y };
|
||||
}
|
||||
|
||||
public double transformScalingValue(double s) { return 1.0; }
|
||||
|
||||
public double focusCoefficientMinimum() { return 1.0; }
|
||||
public double focusCoefficientMaximum() { return 1.0; }
|
||||
|
||||
public AwtMetricsNormal() { super(); }
|
||||
|
||||
public AwtMetricsNormal(ZZCell start, Dimension rv, Dimension vv,
|
||||
double ox, double oy) {
|
||||
super(start, rv, vv, ox, oy);
|
||||
}
|
||||
}
|
||||
|
||||
110
Modules/awtool/AwtNileView.java
Normal file
110
Modules/awtool/AwtNileView.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
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 :
|
||||
212
Modules/awtool/AwtNote.java
Normal file
212
Modules/awtool/AwtNote.java
Normal file
@@ -0,0 +1,212 @@
|
||||
/* DO NOT EDIT THIS FILE. THIS FILE WAS GENERATED FROM ../Modules/awtool/AwtNote.zob,
|
||||
* EDIT THAT FILE INSTEAD!
|
||||
* All changes to this file will be lost.
|
||||
*/
|
||||
/*
|
||||
Awtnote.java
|
||||
*
|
||||
* Copyright (c) 1999-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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
/** this is for awt content. change 'AwtNote' => 'AwtContent'
|
||||
*/
|
||||
|
||||
|
||||
public class AwtNote extends ZObCellRepr implements 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); }
|
||||
|
||||
|
||||
/** UNDOCUMENTED.
|
||||
|
||||
* <p>Default value: <PRE> 0.1;</PRE>.
|
||||
|
||||
* @structparam 1
|
||||
*/
|
||||
|
||||
public
|
||||
double width
|
||||
= 0.1;/** UNDOCUMENTED.
|
||||
|
||||
* <p>Default value: <PRE> 0.07;</PRE>.
|
||||
|
||||
* @structparam 1
|
||||
*/
|
||||
|
||||
public double height
|
||||
= 0.07;
|
||||
|
||||
|
||||
/* AUTOGENERATED! */
|
||||
static final private int fullmask = 3;
|
||||
|
||||
/* AUTOGENERATED! */
|
||||
public String readParams(ZZCell start) {
|
||||
int m = 0;
|
||||
try {
|
||||
if(start != null)
|
||||
m = readParams(start, 0);
|
||||
} catch(Throwable t) {
|
||||
ZZLogger.exc(t);
|
||||
} finally {
|
||||
|
||||
}
|
||||
if((m & fullmask) != fullmask) {
|
||||
// not all parameters present - no problem right now.
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/* AUTOGENERATED! */
|
||||
private int readParams(ZZCell start, int mask) {
|
||||
ZZCell n = start;
|
||||
while(n != null) {
|
||||
String s = n.getText();
|
||||
// Tests autogenerated from members.
|
||||
|
||||
if(s.equals("width")) {
|
||||
mask |= 1;
|
||||
try {
|
||||
ZZCell c = n.s("d.1"); s = c.getText(); width = (Double.valueOf(s)).doubleValue();
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
}
|
||||
} else
|
||||
|
||||
|
||||
if(s.equals("height")) {
|
||||
mask |= 2;
|
||||
try {
|
||||
ZZCell c = n.s("d.1"); s = c.getText(); height = (Double.valueOf(s)).doubleValue();
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
}
|
||||
} else
|
||||
|
||||
|
||||
{ } // grab that last "else"
|
||||
ZZCell h = n.h("d.3");
|
||||
if(h != null && h != n) {
|
||||
// recurse
|
||||
mask |= readParams(h, mask);
|
||||
}
|
||||
n = n.s("d.2");
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// category link
|
||||
private AwtLink cLink = null;
|
||||
double x = Double.NaN;
|
||||
double y = Double.NaN;
|
||||
|
||||
public void setCell(ZZCell c) {
|
||||
super.setCell(c);
|
||||
ZZCell cc, nCategoryCell = AwtUtil.getNoteCellCategory(c);
|
||||
if(nCategoryCell != null) {
|
||||
cc = c.s(AwtUtil.d_from, -1);
|
||||
if(cc.s("d.1") != null)
|
||||
cLink = (AwtLink)AwtUtil.readZObClone(cc);
|
||||
else
|
||||
cLink = new AwtLink();
|
||||
cLink.setCell(cc);
|
||||
} else {
|
||||
cLink = new AwtLink();
|
||||
}
|
||||
}
|
||||
|
||||
public double getWidth() { return width; }
|
||||
public double getHeight() { return height; }
|
||||
|
||||
public double[] getDimension() { return new double[] { width, height }; }
|
||||
public void setDimension(double w, double h) {
|
||||
width = w;
|
||||
height = h;
|
||||
}
|
||||
|
||||
public AwtLink getCategoryLink() {
|
||||
return cLink;
|
||||
}
|
||||
|
||||
public void setCategoryLink(AwtLink cl) {
|
||||
cLink = cl;
|
||||
}
|
||||
|
||||
public void setCoord(double x, double y) {
|
||||
cLink.setX(x);
|
||||
cLink.setY(y);
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
cLink.setX(x);
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
cLink.setY(y);
|
||||
}
|
||||
|
||||
public double[] getCoord() {
|
||||
return new double[] { cLink.getX(), cLink.getY() };
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return cLink.getX();
|
||||
}
|
||||
public double getY() {
|
||||
return cLink.getY();
|
||||
}
|
||||
|
||||
public String getZObName() {
|
||||
return "Note";
|
||||
}
|
||||
|
||||
/** method for storing ZOb back to structure.
|
||||
* @param start quess;)
|
||||
* @param clone whether or not to make the new central cell a clone of
|
||||
* this.cell (default is true).
|
||||
*/
|
||||
public String cellRepr(ZZCell start, boolean clone)
|
||||
{
|
||||
ZZCell c = start.getOrNewCell("d.1");
|
||||
c.setText(getZObClassName());
|
||||
c.setText("AwtNote");
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText("width");
|
||||
c.getOrNewCell("d.1").setText(""+getWidth());
|
||||
c = c.getOrNewCell("d.2");
|
||||
c.setText("height");
|
||||
c.getOrNewCell("d.1").setText(""+getHeight());
|
||||
if(clone && !start.equals(getCell())) {
|
||||
getCell().connect(AwtUtil.d_clone, start);
|
||||
}
|
||||
if(cLink.getCell() != null) cLink.cellRepr();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// vim: set syntax=java :
|
||||
135
Modules/awtool/AwtNote.zob
Normal file
135
Modules/awtool/AwtNote.zob
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
Awtnote.java
|
||||
*
|
||||
* Copyright (c) 1999-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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
/** this is for awt content. change 'AwtNote' => 'AwtContent'
|
||||
*/
|
||||
|
||||
|
||||
public class AwtNote extends ZObCellRepr implements 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 {
|
||||
double width
|
||||
= 0.1;
|
||||
|
||||
double height
|
||||
= 0.07;
|
||||
}
|
||||
|
||||
// category link
|
||||
private AwtLink cLink = null;
|
||||
double x = Double.NaN;
|
||||
double y = Double.NaN;
|
||||
|
||||
public void setCell(ZZCell c) {
|
||||
super.setCell(c);
|
||||
ZZCell cc, nCategoryCell = AwtUtil.getNoteCellCategory(c);
|
||||
if(nCategoryCell != null) {
|
||||
cc = c.s(AwtUtil.d_from, -1);
|
||||
if(cc.s("d.1") != null)
|
||||
cLink = (AwtLink)AwtUtil.readZObClone(cc);
|
||||
else
|
||||
cLink = new AwtLink();
|
||||
cLink.setCell(cc);
|
||||
} else {
|
||||
cLink = new AwtLink();
|
||||
}
|
||||
}
|
||||
|
||||
public double getWidth() { return width; }
|
||||
public double getHeight() { return height; }
|
||||
|
||||
public double[] getDimension() { return new double[] { width, height }; }
|
||||
public void setDimension(double w, double h) {
|
||||
width = w;
|
||||
height = h;
|
||||
}
|
||||
|
||||
public AwtLink getCategoryLink() {
|
||||
return cLink;
|
||||
}
|
||||
|
||||
public void setCategoryLink(AwtLink cl) {
|
||||
cLink = cl;
|
||||
}
|
||||
|
||||
public void setCoord(double x, double y) {
|
||||
cLink.setX(x);
|
||||
cLink.setY(y);
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
cLink.setX(x);
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
cLink.setY(y);
|
||||
}
|
||||
|
||||
public double[] getCoord() {
|
||||
return new double[] { cLink.getX(), cLink.getY() };
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return cLink.getX();
|
||||
}
|
||||
public double getY() {
|
||||
return cLink.getY();
|
||||
}
|
||||
|
||||
public String getZObName() {
|
||||
return "Note";
|
||||
}
|
||||
|
||||
/** method for storing ZOb back to structure.
|
||||
* @param start quess;)
|
||||
* @param clone whether or not to make the new central cell a clone of
|
||||
* this.cell (default is true).
|
||||
*/
|
||||
public String cellRepr(ZZCell start, boolean clone)
|
||||
{
|
||||
ZZCell c = start.getOrNewCell("d.1");
|
||||
c.setText(getZObClassName());
|
||||
c.setText("AwtNote");
|
||||
c = c.getOrNewCell("d.1");
|
||||
c.setText("width");
|
||||
c.getOrNewCell("d.1").setText(""+getWidth());
|
||||
c = c.getOrNewCell("d.2");
|
||||
c.setText("height");
|
||||
c.getOrNewCell("d.1").setText(""+getHeight());
|
||||
if(clone && !start.equals(getCell())) {
|
||||
getCell().connect(AwtUtil.d_clone, start);
|
||||
}
|
||||
if(cLink.getCell() != null) cLink.cellRepr();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// vim: set syntax=java :
|
||||
329
Modules/awtool/AwtUtil.java
Normal file
329
Modules/awtool/AwtUtil.java
Normal file
@@ -0,0 +1,329 @@
|
||||
/*
|
||||
AwtUtil.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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
/** Some general stuff
|
||||
*/
|
||||
|
||||
public class AwtUtil {
|
||||
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); }
|
||||
|
||||
public static String d_to="d.map-1";
|
||||
public static String d_from="d.map-2";
|
||||
public static String d_categories="d.categories";
|
||||
public static String d_notes="d.notes";
|
||||
public static String d_awtool="d.awtool";
|
||||
|
||||
public static String d_clone="d.clone";
|
||||
|
||||
public static ZZCell addDims(ZZCell defaultDimsBegin) {
|
||||
Hashtable awtDims = new Hashtable();
|
||||
|
||||
awtDims.put(d_to, d_to);
|
||||
awtDims.put(d_from, d_from);
|
||||
awtDims.put(d_categories, d_categories);
|
||||
awtDims.put(d_notes, d_notes);
|
||||
awtDims.put(d_awtool, d_awtool);
|
||||
|
||||
String dim;
|
||||
|
||||
for(ZZCell c = defaultDimsBegin; c != null; c = c.s("d.2") ) {
|
||||
dim = c.getText();
|
||||
if(awtDims.containsKey(dim))
|
||||
awtDims.remove(dim);
|
||||
if(c.equals(defaultDimsBegin.s("d.2", -1))) break;
|
||||
}
|
||||
|
||||
for(Enumeration e = awtDims.keys(); e.hasMoreElements(); ) {
|
||||
dim = (String)e.nextElement();
|
||||
defaultDimsBegin.N("d.2", -1).setText(dim);
|
||||
}
|
||||
return defaultDimsBegin;
|
||||
}
|
||||
|
||||
/** return awt system list roocell
|
||||
*/
|
||||
public static ZZCell getAwtSysList(ZZCell vc) {
|
||||
ZZCell awtc = ZZDefaultSpace.findInheritableParam(vc, "AwtSystemList");
|
||||
if(awtc == null) return null;
|
||||
return ZZCursorReal.get(awtc);
|
||||
}
|
||||
|
||||
/** return active metrics
|
||||
*/
|
||||
public static AwtMetrics getAwtMetrics(ZZCell awtsyslist) {
|
||||
ZZCell metr = getCursoredCell(Awtool.c_metrics, awtsyslist);
|
||||
if(metr==null) {
|
||||
metr = awtsyslist.findText(d_awtool, 1, "Metrics");
|
||||
if(metr!=null) metr = metr.s("d.1");
|
||||
}
|
||||
if(metr == null) throw new ZZError("Awtool: Couldn't initialize metrics!!");
|
||||
AwtMetrics M = (AwtMetrics)readZObClone(metr);
|
||||
M.setCell(metr);
|
||||
return M;
|
||||
}
|
||||
|
||||
public static ZZCell getCursoredCell(AwtCursor acur, ZZCell viewcellOrAwtsyslist) {
|
||||
String cursorName = acur.color.toString();
|
||||
ZZCell awtsyslist, vc, cur=null, cursors;
|
||||
|
||||
// scrutinize 'viewcellOrAwtsyslist'
|
||||
if(viewcellOrAwtsyslist.getRankLength(d_awtool)>1) {
|
||||
awtsyslist = viewcellOrAwtsyslist;
|
||||
vc = null;
|
||||
} else {
|
||||
vc = viewcellOrAwtsyslist;
|
||||
awtsyslist = getAwtSysList(vc);
|
||||
}
|
||||
|
||||
// shared cursors belongs to all awtool views
|
||||
if(!acur.shared) {
|
||||
cursors = awtsyslist.findText(d_awtool, 1, "Cursors").s("d.1");
|
||||
cur = cursors.findText("d.2", 1, cursorName);
|
||||
} else {
|
||||
ZZCell scursors, win, vcShared;
|
||||
ZZCell[] wins;
|
||||
ZZSpace sp = vc.getSpace();
|
||||
win = ZZDefaultSpace.findOnSystemlist(sp, "Windows", false);
|
||||
win = win.s("d.1");
|
||||
wins = AwtUtil.findAll(win, "d.2", 1, "awtool");
|
||||
if(wins==null) throw new ZZError("Awtool: No awtool window found!!");
|
||||
for(int i=0; i<wins.length; i++) {
|
||||
vcShared = wins[i].s("d.1", 2);
|
||||
scursors = vcShared.findText("d.2", 1, "SharedCursors").s("d.1");
|
||||
cur = scursors.findText("d.2", 1, cursorName);
|
||||
if(cur!=null) break;
|
||||
}
|
||||
}
|
||||
if(cur==null) return null;
|
||||
return ZZCursorReal.get(cur);
|
||||
}
|
||||
|
||||
public static void setCursor(AwtCursor acur, ZZCell c, ZZCell viewcellOrAwtsyslist) {
|
||||
String cursorName = acur.color.toString();
|
||||
ZZCell awtsyslist, vc, cur=null, cursors=null;
|
||||
|
||||
// scrutinize 'viewcellOrAwtsyslist'
|
||||
if(viewcellOrAwtsyslist.getRankLength(d_awtool)>1) {
|
||||
awtsyslist = viewcellOrAwtsyslist;
|
||||
vc = null;
|
||||
} else {
|
||||
vc = viewcellOrAwtsyslist;
|
||||
awtsyslist = getAwtSysList(vc);
|
||||
}
|
||||
|
||||
// shared cursors belongs to all awtool views
|
||||
if(!acur.shared) {
|
||||
cursors = awtsyslist.findText(d_awtool, 1, "Cursors").s("d.1");
|
||||
cur = cursors.findText("d.2", 1, cursorName);
|
||||
} else {
|
||||
ZZCell win, vcShared;
|
||||
ZZCell[] wins;
|
||||
ZZSpace sp = vc.getSpace();
|
||||
win = ZZDefaultSpace.findOnSystemlist(sp, "Windows", false);
|
||||
win = win.s("d.1");
|
||||
wins = AwtUtil.findAll(win, "d.2", 1, "awtool");
|
||||
if(wins==null) throw new ZZError("Awtool: No awtool window found!!");
|
||||
for(int i=0; i<wins.length; i++) {
|
||||
vcShared = wins[i].s("d.1", 2);
|
||||
cursors = vcShared.findText("d.2", 1, "SharedCursors").s("d.1");
|
||||
cur = cursors.findText("d.2", 1, cursorName);
|
||||
if(cur!=null) break;
|
||||
}
|
||||
}
|
||||
if(cur == null) {
|
||||
if(cursors==null) throw new ZZError("Awtool: awt-cursors not initialized properly!!");
|
||||
cur = cursors.N("d.2");
|
||||
cur.setText(cursorName);
|
||||
ZZCursorReal.set(cur, c);
|
||||
ZZCursorReal.setColor(cur, acur.color);
|
||||
return;
|
||||
}
|
||||
ZZCursorReal.set(cur, c);
|
||||
}
|
||||
|
||||
public static ZZCell[] findAll(ZZCell start, String dim, int dir, String id) {
|
||||
ZZCell c;
|
||||
Vector found = new Vector();
|
||||
if(start.getText().equals(id)) found.addElement(start);
|
||||
for(c = start.s(dim, dir); (c!=null) && (c!=start); c = c.s(dim, dir) ) {
|
||||
if(c.getText().equals(id)) found.addElement(c);
|
||||
}
|
||||
int i = found.size();
|
||||
ZZCell[] fc = new ZZCell[i];
|
||||
for(i-=1; i>=0; i--) {
|
||||
fc[i] = (ZZCell)found.elementAt(i);
|
||||
}
|
||||
return fc;
|
||||
}
|
||||
|
||||
public interface ObjectComparator {
|
||||
int compare(Object o1, Object o2);
|
||||
}
|
||||
|
||||
public static void quickSort(Vector a, int lo0, int hi0, ObjectComparator c) {
|
||||
int lo = lo0;
|
||||
int hi = hi0;
|
||||
|
||||
if (lo >= hi)
|
||||
return;
|
||||
|
||||
Object mid = a.elementAt((lo + hi) / 2);
|
||||
while (lo < hi) {
|
||||
while (lo<hi && c.compare(a.elementAt(lo), mid) < 0)
|
||||
lo++;
|
||||
while (lo<hi && c.compare(a.elementAt(hi), mid) > 0)
|
||||
hi--;
|
||||
if (lo < hi) {
|
||||
Object T = a.elementAt(lo);
|
||||
a.setElementAt(a.elementAt(hi), lo);
|
||||
a.setElementAt(T, hi);
|
||||
lo++;
|
||||
hi--;
|
||||
}
|
||||
}
|
||||
if (hi < lo) {
|
||||
int T = hi;
|
||||
hi = lo;
|
||||
lo = T;
|
||||
}
|
||||
quickSort(a, lo0, lo, c);
|
||||
quickSort(a, lo == lo0 ? lo+1 : lo, hi0, c);
|
||||
}
|
||||
|
||||
/** Construct and return a ZOb of the given type.
|
||||
*/
|
||||
public static ZOb newModuleZOb(String id) {
|
||||
// XXX Figure out if we can cache something.
|
||||
// XXX Should ZOb be able to reset? Easier or less easy than
|
||||
// recreate? At least ZObs should cache...
|
||||
try {
|
||||
Class z = Class.forName("org.gzigzag.module."+id);
|
||||
return (ZOb)Class.forName("org.gzigzag.module."+id).newInstance();
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Construct a ZOb corresponding to a cell and read the params.
|
||||
* DOES NOT Go to the rootclone, takes the next cell on d.1 as the ZOb's name,
|
||||
* and takes the NEXT cell on d.1 as the head of the list from which to
|
||||
* read the structparams.
|
||||
*/
|
||||
static public ZOb readZObClone(ZZCell start) {
|
||||
//ZZCell c = start.h("d.clone", -1).s("d.1", 1);
|
||||
|
||||
if(start.s("d.1") == null) start = start.h("d.clone", -1);
|
||||
ZZCell c = start.s("d.1", 1);
|
||||
if(c == null)
|
||||
throw new ZZError("Error reading ZOb from cell "+start.getText());
|
||||
ZOb z = newModuleZOb(c.getText());
|
||||
z.readParams(c.s("d.1", 1));
|
||||
return z;
|
||||
}
|
||||
|
||||
/** return category cell of the note c
|
||||
*/
|
||||
static public ZZCell getNoteCellCategory(ZZCell c) {
|
||||
ZZCell qwerty = c.s(d_from, -1);
|
||||
if(qwerty == null) return null;
|
||||
if(qwerty.equals(qwerty.h(d_to, -1))) return null;
|
||||
qwerty = qwerty.h(d_to, -1);
|
||||
if(qwerty.getRankLength(d_categories) == 1) return null;
|
||||
return qwerty;
|
||||
}
|
||||
|
||||
static public AwtNote createNewNote(ZZCell c, double[] ncenter,
|
||||
double[] ndim) {
|
||||
AwtNote newNote = new AwtNote();
|
||||
newNote.setCell(c);
|
||||
newNote.setCoord(ncenter[0], ncenter[1]);
|
||||
newNote.setDimension(ndim[0], ndim[1]);
|
||||
newNote.cellRepr();
|
||||
return newNote;
|
||||
}
|
||||
|
||||
public void deleteNote(ZZCell nc) {
|
||||
// should delete ZOb structures ... in future
|
||||
// ZObCellRepr will have 'deleteZOb' method.
|
||||
ZZCell hc = nc.h(d_clone);
|
||||
nc.delete();
|
||||
if(hc.getRankLength(d_clone)==1) {
|
||||
hc.delete();
|
||||
}
|
||||
}
|
||||
|
||||
static public void createNewLink(ZZCell from, ZZCell to) {
|
||||
ZZCell newLinkCell = from.h(AwtUtil.d_to, 1).N(AwtUtil.d_to, 1);
|
||||
to.h(AwtUtil.d_from, -1).connect(AwtUtil.d_from, -1, newLinkCell);
|
||||
AwtLink al = new AwtLink();
|
||||
al.setCell(newLinkCell);
|
||||
al.cellRepr();
|
||||
}
|
||||
|
||||
static public void renderGrid(FlobSet into, AwtMetrics M, double x1, double
|
||||
y1, double x2, double y2, Color color, int density)
|
||||
{
|
||||
double[] coord = new double[2], cstart = new double[2], cinc = new double[2],
|
||||
d = new double[2], dh = new double[2];
|
||||
Point p1, p2;
|
||||
int i, j, a, b;
|
||||
cstart[0] = (x1 < x2) ? x1 : x2;
|
||||
cstart[1] = (y1 < y2) ? y1 : x2;
|
||||
cinc[0] = Math.abs((x2-x1) / ((double)density + 1.0));
|
||||
cinc[1] = Math.abs((y2-y1) / ((double)density + 1.0));
|
||||
d[0] = cinc[0] / 5.0;
|
||||
d[1] = cinc[1] / 5.0;
|
||||
dh[0] = d[0]/2.0;
|
||||
dh[1] = d[1]/2.0;
|
||||
|
||||
for(a=0; a<2; a++) {
|
||||
b = (a==0) ? 1 : 0;
|
||||
coord[a] = cstart[a];
|
||||
for(i=0; i<=density+1; i++) {
|
||||
coord[b] = cstart[b]+dh[b]/2.0;
|
||||
for(j=1; j<=(density+1)*5; j++) {
|
||||
p1 = M.mapToRealView(coord);
|
||||
coord[b] += dh[b];
|
||||
p2 = M.mapToRealView(coord);
|
||||
coord[b] += dh[b];
|
||||
into.add(new LineDecor(p1.x, p1.y, p2.x, p2.y, color, 2));
|
||||
}
|
||||
coord[a] += cinc[a];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
341
Modules/awtool/AwtView1.java
Normal file
341
Modules/awtool/AwtView1.java
Normal file
@@ -0,0 +1,341 @@
|
||||
/*
|
||||
AwtView1.zob
|
||||
*
|
||||
* Copyright (c) 2000-2001 Ted Nelson and Tuomas Lukka
|
||||
* Copyright (c) 2000-2001 Kimmo Wideroos
|
||||
*
|
||||
* 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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
/** View for a(ssociative) writing tool
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
//import java.lang.reflect.*;
|
||||
|
||||
public class AwtView1 extends Awtool {
|
||||
|
||||
static AwtNileView awtNile = new AwtNileView();
|
||||
|
||||
class AwtBgFlob extends CellBgFlob {
|
||||
|
||||
public AwtBgFlob(int x, int y, int d, int w, int h, ZZCell c) {
|
||||
super(x, y, d, w, h, c);
|
||||
}
|
||||
|
||||
public void render(Graphics g, int mx, int my, int md, int mw, int mh) {
|
||||
|
||||
Color[] solids = getSolidColors();
|
||||
int nsolids = 0;
|
||||
|
||||
if(solids!=null) nsolids = solids.length;
|
||||
|
||||
Color oldfg = g.getColor();
|
||||
Shape oldclip = g.getClip();
|
||||
|
||||
g.clipRect(mx, my, mw, mh);
|
||||
|
||||
if(solids != null) {
|
||||
int iq=0, id=0;
|
||||
for(int i=0; i<nsolids-1; i++) {
|
||||
g.setColor(solids[i]);
|
||||
if(mw-iq-5>0 && mh-iq-5>0) {
|
||||
g.drawRect(mx+id+1, my+id+1, mw-iq-3, mh-iq-3);
|
||||
g.drawRect(mx+id+2, my+id+2, mw-iq-5, mh-iq-5);
|
||||
id += 2;
|
||||
iq += 4;
|
||||
}
|
||||
g.setColor(bg);
|
||||
g.fillRect(mx+id+1, my+id+1, mw-iq-3, mh-iq-3);
|
||||
//g.fillRect(mx+(mw*i)/nsolids, my, mw/nsolids+1, mh);
|
||||
}
|
||||
} else {
|
||||
g.setColor(bg);
|
||||
g.fillRect(mx, my, mw, mh);
|
||||
}
|
||||
|
||||
g.setColor(oldfg);
|
||||
|
||||
renderContent(g, mx, my, mw, mh);
|
||||
|
||||
// XXX Span indication???
|
||||
|
||||
g.drawRect(mx, my, mw-1, mh-1);
|
||||
|
||||
g.setClip(oldclip);
|
||||
}
|
||||
}
|
||||
|
||||
class AwtLinkFlob extends CellBgFlob {
|
||||
|
||||
Point from, to;
|
||||
|
||||
AwtLinkFlob(Point from, Point to, ZZCell c) {
|
||||
super((from.x+to.x)>>1, (from.y+to.y)>>1, Math.abs(from.x-to.x),
|
||||
Math.abs(from.y-to.y), 2, c);
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
//super((from.x+to.x)>>1, (from.y+to.y)>>1, w, h, 2, c);
|
||||
}
|
||||
|
||||
public void render(Graphics g, int mx, int my, int md,
|
||||
int mw, int mh) {
|
||||
|
||||
Color[] solids = getSolidColors();
|
||||
int nsolids = 0;
|
||||
|
||||
if(solids!=null) nsolids = solids.length;
|
||||
|
||||
Color oldfg = g.getColor();
|
||||
//Shape oldclip = g.getClip();
|
||||
|
||||
// XXX save font?
|
||||
|
||||
//g.clipRect(mx, my, mw, mh);
|
||||
|
||||
if(solids != null) {
|
||||
int lx, ly, dw, dh;
|
||||
lx = from.x;
|
||||
ly = from.y;
|
||||
dw = lx - to.x;
|
||||
dh = ly - to.y;
|
||||
for(int i=0; i<nsolids; i++) {
|
||||
g.setColor(solids[i]);
|
||||
g.drawLine(lx, ly, lx+dw, ly+dh);
|
||||
lx +=dw;
|
||||
ly +=dh;
|
||||
}
|
||||
} else {
|
||||
//g.setColor(bg);
|
||||
g.setColor(Color.black);
|
||||
int px = from.x-to.x, py = from.y-to.y;
|
||||
g.drawLine(from.x, from.y, to.x, to.y);
|
||||
}
|
||||
|
||||
g.setColor(oldfg);
|
||||
|
||||
//g.setClip(oldclip);
|
||||
}
|
||||
|
||||
public Object hit(int x, int y) {
|
||||
double k, d;
|
||||
k = (double)(w*(y-from.y) - h*(x-from.x));
|
||||
d = Math.sqrt(k*k / (w*w+h*h));
|
||||
if(d<20.0) {
|
||||
// near enough the line
|
||||
return new ZZCursorVirtual(super.c);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void makeAwtNote(FlobSet into, ZZCell view, ZZCell noteCell,
|
||||
Rectangle rect, boolean NileOn ) {
|
||||
Flob bgfl;
|
||||
|
||||
// noteCell kind of emulates viewcell... ugly or elegant, don't know
|
||||
if(noteCell.s("d.cursor-cargo", -1)!=null) {
|
||||
ZZCell naccursed = ZZCursorReal.get(noteCell);
|
||||
awtNile.awtNileRaster(into, noteCell, naccursed, rect);
|
||||
}
|
||||
|
||||
/*
|
||||
if(NileOn) {
|
||||
bgfl = new AwtBgFlob(rect.x, rect.y, 1, rect.width,
|
||||
rect.height, noteCell) {
|
||||
public Object hit(int x0, int y0) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
bgfl = new AwtBgFlob(rect.x, rect.y, 1, rect.width,
|
||||
rect.height, noteCell);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
bgfl = new AwtBgFlob(rect.x-2, rect.y-2, 1, rect.width+4,
|
||||
rect.height+4, noteCell);
|
||||
|
||||
((CellBgFlob)bgfl).setBg(Color.white);
|
||||
CellFlobFactory2.addSolidColors(into, (CellBgFlob)bgfl);
|
||||
into.add(bgfl);
|
||||
}
|
||||
|
||||
public void raster(FlobSet into, FlobFactory fact,
|
||||
ZZCell view, String[] dims, ZZCell accursed) {
|
||||
|
||||
ZZCell awtsyslist = AwtUtil.getAwtSysList(view);
|
||||
|
||||
AwtMetrics M = AwtUtil.getAwtMetrics(awtsyslist);
|
||||
|
||||
Dimension d = into.getSize();
|
||||
if(!M.RealViewEquals(d)) {
|
||||
M.setRealView(d, true);
|
||||
M.cellRepr();
|
||||
}
|
||||
|
||||
boolean nileOn = false;
|
||||
ZZCell curb = view.h("d.bind", 1, true);
|
||||
if(curb!=null) {
|
||||
String mode = ZZCursorReal.get(curb).getText();
|
||||
if(mode.indexOf("Nile") >= 0)
|
||||
nileOn = true;
|
||||
}
|
||||
|
||||
Dimension nDim;
|
||||
Point nCoord = new Point();
|
||||
Rectangle rect;
|
||||
|
||||
// if note is dragged, draw only that one
|
||||
if(Awtool.dragNote != null) {
|
||||
nCoord = M.mapToRealView(dragNote.getX(), dragNote.getY());
|
||||
nDim = M.getRealDimension(dragNote.getX(), dragNote.getY(), dragNote.getDimension());
|
||||
rect = new Rectangle(nCoord.x-(nDim.width>>1), nCoord.y-(nDim.height>>1),
|
||||
nDim.width, nDim.height);
|
||||
makeAwtNote(into, view, dragNote.getCell(), rect, nileOn);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ZZCell activeCategory =
|
||||
AwtUtil.getCursoredCell(Awtool.c_activeCategory, awtsyslist);
|
||||
//view.getSpace().getCellByID("1051"); //getActiveCategory(view);
|
||||
if(activeCategory==null) {
|
||||
activeCategory =
|
||||
awtsyslist.h(AwtUtil.d_categories,1).
|
||||
s(AwtUtil.d_categories, -1).
|
||||
getOrNewCell(AwtUtil.d_categories);
|
||||
AwtUtil.setCursor(Awtool.c_activeCategory, activeCategory, awtsyslist);
|
||||
}
|
||||
Categories C = new Categories(activeCategory);
|
||||
|
||||
AwtNote[] validNotes = C.getValidNotes();
|
||||
|
||||
// 'renderedNotes': key = notecell, value = {int x, y, w, h}
|
||||
Hashtable renderedNotes = new Hashtable();
|
||||
|
||||
Vector notFixedNotes = new Vector();
|
||||
ZZCell noteCell, noteParams, categoryLinkCell;
|
||||
AwtLink catlink;
|
||||
AwtNote note;
|
||||
int[] noteSize;
|
||||
double y, x, yRowMax=0.0, w, h, gap=0.1;
|
||||
|
||||
for(int i=0; i<validNotes.length; i++) {
|
||||
note = validNotes[i];
|
||||
noteCell = note.getCell();
|
||||
// only category notes have fixed position
|
||||
if(note.getCategoryLink() == null) {
|
||||
notFixedNotes.addElement(note);
|
||||
continue;
|
||||
}
|
||||
nCoord = M.mapToRealView(note.getX(), note.getY());
|
||||
nDim = M.getRealDimension(note.getX(),note.getY(),note.getDimension());
|
||||
|
||||
// importtant: notes' headcells as keys
|
||||
renderedNotes.put(noteCell.h(AwtUtil.d_clone),
|
||||
new int[] { nCoord.x, nCoord.y, nDim.width, nDim.height });
|
||||
|
||||
rect = new Rectangle(nCoord.x-(nDim.width>>1), nCoord.y-(nDim.height>>1),
|
||||
nDim.width, nDim.height);
|
||||
makeAwtNote(into, view, noteCell, rect, nileOn);
|
||||
|
||||
}
|
||||
|
||||
AwtUtil.quickSort(notFixedNotes, 0, notFixedNotes.size()-1,
|
||||
new AwtUtil.ObjectComparator() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
return (( ((AwtNote)o1).getHeight() <
|
||||
((AwtNote)o2).getHeight() ) ? 1 : 0 );
|
||||
}
|
||||
});
|
||||
|
||||
y = 1.0-gap; x = gap;
|
||||
for(Enumeration e=notFixedNotes.elements(); e.hasMoreElements();){
|
||||
note = (AwtNote)e.nextElement();
|
||||
noteCell = note.getCell();
|
||||
w = note.getWidth();
|
||||
if(x+w>1.0-gap) {
|
||||
x = gap;
|
||||
y += yRowMax;
|
||||
yRowMax = 0;
|
||||
}
|
||||
h = note.getHeight();
|
||||
note.setCoord(x+(w/2.0), y+(h/2.0));
|
||||
x += (w+gap);
|
||||
if(h>yRowMax) yRowMax = h;
|
||||
|
||||
|
||||
nCoord = M.mapToRealView(note.getX(), note.getY());
|
||||
|
||||
nDim = M.getRealDimension(note.getX(), note.getY(), note.getDimension());
|
||||
|
||||
// importtant: notes' headcells as keys
|
||||
renderedNotes.put(noteCell.h(AwtUtil.d_clone),
|
||||
new int[] { nCoord.x, nCoord.y, nDim.width, nDim.height });
|
||||
|
||||
rect = new Rectangle(nCoord.x, nCoord.y, nDim.width,
|
||||
nDim.height);
|
||||
makeAwtNote(into, view, noteCell, rect, nileOn);
|
||||
//fact.centerFlob(into, noteCell, noteCell, 1,
|
||||
// nCoord, 0, 0, 1, nDim);
|
||||
}
|
||||
|
||||
// render links
|
||||
|
||||
int[] toField, fromField;
|
||||
ZZCell toc, fromc;
|
||||
AwtLink al;
|
||||
AwtLink[] validLinks = C.getAllValidLinks(true, true);
|
||||
|
||||
for(int i=0; i<validLinks.length; i++ ) {
|
||||
al = validLinks[i];
|
||||
toc = al.toHeadCell();
|
||||
fromc = al.fromHeadCell();
|
||||
//pa("LINKCELL:"+al.getCell());
|
||||
//pa("TO:"+toc);
|
||||
//pa("FROM:"+fromc);
|
||||
if(toc == null || fromc == null) continue;
|
||||
if(!renderedNotes.containsKey(toc) ||
|
||||
!renderedNotes.containsKey(fromc)) continue;
|
||||
toField = (int[])renderedNotes.get(toc);
|
||||
fromField = (int[])renderedNotes.get(fromc);
|
||||
|
||||
//pa("CELL:"+al.getCell());
|
||||
//pa("FROM(x):"+fromField[0]+" (y):"+fromField[1]);
|
||||
//pa("FROM(x):"+toField[0]+" (y):"+toField[1]);
|
||||
|
||||
Flob alinkflob = new AwtLinkFlob(new Point(fromField[0], fromField[1]),
|
||||
new Point(toField[0], toField[1]), al.getCell());
|
||||
|
||||
into.add(alinkflob);
|
||||
|
||||
}
|
||||
|
||||
if(M.GridOn) {
|
||||
AwtUtil.renderGrid(into, M, -1.0, -1.0, 1.0, 1.0, Color.gray, 10);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
1016
Modules/awtool/Awtool.java
Normal file
1016
Modules/awtool/Awtool.java
Normal file
File diff suppressed because it is too large
Load Diff
955
Modules/awtool/Awtool.zob
Normal file
955
Modules/awtool/Awtool.zob
Normal file
@@ -0,0 +1,955 @@
|
||||
/*
|
||||
Awtool.zob
|
||||
*
|
||||
* Copyright (c) 2000-2001 Ted Nelson and Tuomas Lukka
|
||||
* Copyright (c) 2000-2001 Kimmo Wideroos
|
||||
*
|
||||
* 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 Kimmo Wideroos (inspired by Benjamin Fallenstein's notemap module)
|
||||
*/
|
||||
|
||||
/** Awt = A(ssociative) writing tool -demo
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
public abstract class Awtool implements FlobView, FlobSet.DragCursor, ZOb {
|
||||
public static final String rcsid = "";
|
||||
public static boolean dbg = true;
|
||||
static void p(String s) { if(dbg) System.out.println(s); }
|
||||
static void pa(String s) { System.out.println(s); }
|
||||
|
||||
STRUCTPARAMS {
|
||||
/** View dimension (not in use now...) */
|
||||
int viewWidth
|
||||
= 600;
|
||||
int viewHeight
|
||||
= 600;
|
||||
int viewX
|
||||
= 100;
|
||||
int viewY
|
||||
= 100;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static boolean NileOn = false;
|
||||
static AwtNote dragNote;
|
||||
static Point dragOffs = new Point(0, 0);
|
||||
static Point dragCoord = new Point(0, 0);
|
||||
|
||||
static boolean creatingNote = false;
|
||||
|
||||
static long focusChangedLastTime = -1; // millisecs
|
||||
|
||||
static AwtCursor c_cursor1 = new AwtCursor(Color.red, true);
|
||||
static AwtCursor c_cursor2 = new AwtCursor(Color.gray, true);
|
||||
static AwtCursor c_activeCategory = new AwtCursor(Color.orange, false);
|
||||
static AwtCursor c_metrics = new AwtCursor(Color.white, false);
|
||||
|
||||
public boolean accept(Object o) {
|
||||
if(!(o instanceof ZZCell)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static public Hashtable categ;
|
||||
static public Hashtable notes;
|
||||
static public Hashtable validNotes;
|
||||
|
||||
static class NotemapBM extends BooleanMesh {
|
||||
public NotemapBM(ZZCell bStructure) { super(bStructure); }
|
||||
public boolean testBelonging(ZZCell nhc, ZZCell category) {
|
||||
for(ZZCell l=category.h(AwtUtil.d_clone).s(AwtUtil.d_to); l != null; l=l.s(AwtUtil.d_to) )
|
||||
if(l.h(AwtUtil.d_from,1).h(AwtUtil.d_clone).equals(nhc)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* categories are a kind of layers containing notes (i.e. (text) elements).
|
||||
* this class provides with logical operations for categories (AND, OR).
|
||||
* the resulting categories should be able to store permanently in zzspace.
|
||||
* heavily under construction ...
|
||||
*/
|
||||
public class Categories extends ZObCellRepr {
|
||||
private Hashtable AllNoteHeadCells = null;
|
||||
private Hashtable AllNotes = null;
|
||||
private Hashtable AllValidNotes = null;
|
||||
private Hashtable ValidNotes = null;
|
||||
private Hashtable K = new Hashtable();
|
||||
private NotemapBM bm;
|
||||
private String categoryName = "SCRATCH";
|
||||
|
||||
public boolean isCategory(ZZCell c) {
|
||||
return (c.h(AwtUtil.d_clone).getRankLength(AwtUtil.d_categories)>1);
|
||||
}
|
||||
|
||||
public Categories(ZZCell bStructure) {
|
||||
setCell(bStructure);
|
||||
_findCategories(bStructure);
|
||||
bm = new NotemapBM(bStructure);
|
||||
|
||||
AllNotes = new Hashtable();
|
||||
AllNoteHeadCells = new Hashtable();
|
||||
AllValidNotes = new Hashtable();
|
||||
ValidNotes = new Hashtable();
|
||||
|
||||
ZZCell note, chc, nhc;
|
||||
for(Enumeration e = K.keys(); e.hasMoreElements(); ) {
|
||||
// chc = category headcell
|
||||
chc = ((ZZCell)e.nextElement());
|
||||
for(ZZCell linkc = chc.s(AwtUtil.d_to); linkc != null;
|
||||
linkc = linkc.s(AwtUtil.d_to) )
|
||||
{
|
||||
note = linkc.h(AwtUtil.d_from, 1);
|
||||
nhc = note.h(AwtUtil.d_clone);
|
||||
AllNotes.put(note, nhc);
|
||||
if(!AllNoteHeadCells.containsKey(nhc))
|
||||
// AllNoteHeadCells must keep track of all note headcells
|
||||
AllNoteHeadCells.put(nhc, note);
|
||||
if(AllValidNotes.containsKey(nhc))
|
||||
// AllValidNotes store valid headcells AND clones
|
||||
// all together
|
||||
AllValidNotes.put(note, nhc);
|
||||
else if(bm.evaluate(nhc)) AllValidNotes.put(note, nhc);
|
||||
if(AllValidNotes.containsKey(note)) {
|
||||
// If there exist 2 or more valid note clones, ValidNotes
|
||||
// store note headcell (otherwise note clone).
|
||||
if(ValidNotes.containsKey(nhc)) ValidNotes.put(nhc, nhc);
|
||||
else ValidNotes.put(nhc, note);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _findCategories(ZZCell bStructure) {
|
||||
if(isCategory(bStructure)) {
|
||||
K.put(bStructure.h(AwtUtil.d_clone), bStructure);
|
||||
return;
|
||||
} else
|
||||
{
|
||||
_findCategories(bStructure.s("d.1"));
|
||||
_findCategories(bStructure.s("d.2"));
|
||||
}
|
||||
}
|
||||
|
||||
public ZZCell[] getNoteCells() {
|
||||
ZZCell[] n = new ZZCell[AllNotes.size()];
|
||||
Enumeration e = AllNotes.elements();
|
||||
int i = 0;
|
||||
while (e.hasMoreElements()) {
|
||||
n[i] = (ZZCell)e.nextElement(); i++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
public AwtNote[] getNotes() {
|
||||
AwtNote[] n = new AwtNote[AllNotes.size()];
|
||||
Enumeration e = AllNotes.elements();
|
||||
ZZCell ncell;
|
||||
int i = 0;
|
||||
while (e.hasMoreElements()) {
|
||||
ncell = (ZZCell)e.nextElement();
|
||||
n[i] = (AwtNote)AwtUtil.readZObClone(ncell);
|
||||
n[i].setCell(ncell);
|
||||
i++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public ZZCell[] getAllValidNoteCells() {
|
||||
ZZCell[] ln = new ZZCell[AllValidNotes.size()];
|
||||
int i = 0;
|
||||
for(Enumeration e=AllValidNotes.keys(); e.hasMoreElements();) {
|
||||
ln[i] = (ZZCell)e.nextElement();
|
||||
i++;
|
||||
}
|
||||
return ln;
|
||||
}
|
||||
|
||||
public AwtNote[] getAllValidNotes() {
|
||||
AwtNote[] ln = new AwtNote[AllValidNotes.size()];
|
||||
ZZCell ncell;
|
||||
int i = 0;
|
||||
for(Enumeration e=AllValidNotes.keys(); e.hasMoreElements();) {
|
||||
ncell = (ZZCell)e.nextElement();
|
||||
ln[i] = (AwtNote)AwtUtil.readZObClone(ncell);
|
||||
ln[i].setCell(ncell);
|
||||
i++;
|
||||
}
|
||||
return ln;
|
||||
}
|
||||
|
||||
public ZZCell[] getValidNoteCells() {
|
||||
ZZCell[] ln = new ZZCell[ValidNotes.size()];
|
||||
int i = 0;
|
||||
for(Enumeration e=ValidNotes.elements(); e.hasMoreElements(); ) {
|
||||
ln[i] = (ZZCell)e.nextElement();
|
||||
i++;
|
||||
}
|
||||
return ln;
|
||||
}
|
||||
|
||||
public AwtNote[] getValidNotes() {
|
||||
AwtNote[] ln = new AwtNote[ValidNotes.size()];
|
||||
ZZCell ncell;
|
||||
int i = 0;
|
||||
for(Enumeration e=ValidNotes.elements(); e.hasMoreElements(); ) {
|
||||
ncell = (ZZCell)e.nextElement();
|
||||
ln[i] = (AwtNote)AwtUtil.readZObClone(ncell);
|
||||
ln[i].setCell(ncell);
|
||||
i++;
|
||||
}
|
||||
return ln;
|
||||
}
|
||||
|
||||
public ZZCell[] getK() {
|
||||
ZZCell[] cat = new ZZCell[K.size()];
|
||||
Enumeration e = K.elements();
|
||||
int i = 0;
|
||||
while (e.hasMoreElements())
|
||||
cat[i] = (ZZCell)e.nextElement(); i++;
|
||||
return cat;
|
||||
}
|
||||
|
||||
public ZZCell[] getAllValidLinkCells(boolean internal, boolean external) {
|
||||
return _getvalidlinks(internal, external, AllValidNotes.keys());
|
||||
}
|
||||
|
||||
public AwtLink[] getAllValidLinks(boolean internal, boolean external)
|
||||
{
|
||||
ZZCell[] linkcells = _getvalidlinks(internal, external, AllValidNotes.keys());
|
||||
AwtLink[] links = new AwtLink[linkcells.length];
|
||||
for(int i = 0; i<linkcells.length; i++ ) {
|
||||
links[i] = (AwtLink)AwtUtil.readZObClone(linkcells[i]);
|
||||
links[i].setCell(linkcells[i]);
|
||||
}
|
||||
return links;
|
||||
}
|
||||
|
||||
public ZZCell[] getValidLinkCells(boolean internal, boolean external) {
|
||||
return _getvalidlinks(internal, external, ValidNotes.elements());
|
||||
}
|
||||
|
||||
public AwtLink[] getValidLinks(boolean internal, boolean external) {
|
||||
ZZCell[] linkcells = _getvalidlinks(internal, external, AllValidNotes.keys());
|
||||
AwtLink[] links = new AwtLink[linkcells.length];
|
||||
for(int i = 0; i<linkcells.length; i++ ) {
|
||||
links[i] = (AwtLink)AwtUtil.readZObClone(linkcells[i]);
|
||||
links[i].setCell(linkcells[i]);
|
||||
}
|
||||
return links;
|
||||
}
|
||||
|
||||
// Get the links in this category
|
||||
private ZZCell[] _getvalidlinks(boolean internal, boolean
|
||||
external, Enumeration noteEnum) {
|
||||
Hashtable links = new Hashtable();
|
||||
ZZCell nhc, note, trgnote;
|
||||
for(Enumeration e=noteEnum; e.hasMoreElements();) {
|
||||
note = (ZZCell)e.nextElement();
|
||||
nhc = note.h(AwtUtil.d_clone);
|
||||
if(external)
|
||||
for(ZZCell el=nhc.s(AwtUtil.d_to); el != null; el=el.s(AwtUtil.d_to)) {
|
||||
// note has global relations
|
||||
trgnote = el.h(AwtUtil.d_from, 1);
|
||||
if(AllNoteHeadCells.containsKey(trgnote)) links.put(el, el);
|
||||
}
|
||||
if(internal && !(external && note.equals(nhc)))
|
||||
for(ZZCell il=note.s(AwtUtil.d_to); il != null; il=il.s(AwtUtil.d_to)) {
|
||||
// note has categorywide relations
|
||||
trgnote = il.h(AwtUtil.d_from, 1);
|
||||
if(AllValidNotes.containsKey(trgnote)) links.put(il, il);
|
||||
}
|
||||
}
|
||||
int s = links.size(), i=0;
|
||||
ZZCell[] res = new ZZCell[s];
|
||||
for(Enumeration e=links.elements(); e.hasMoreElements(); ) {
|
||||
res[i] = (ZZCell)e.nextElement();
|
||||
i++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public String getZObName() {
|
||||
return "Catecory/Layer";
|
||||
}
|
||||
|
||||
/* store category back in cellstructure */
|
||||
public String cellRepr(ZZCell start, boolean clone) {
|
||||
ZZCell c, retCell, catCell = null;
|
||||
AwtLink catlink = new AwtLink();
|
||||
|
||||
catCell.setText(getZObName());
|
||||
catCell = catCell.getOrNewCell(AwtUtil.d_to);
|
||||
AwtNote note;
|
||||
AwtNote[] validNotes = getValidNotes();
|
||||
for(int i=validNotes.length; i>=0; i--) {
|
||||
note = validNotes[i];
|
||||
catlink.setX(note.getX()); catlink.setY(note.getY());
|
||||
catlink.cellRepr(catCell, false);
|
||||
// note's centralcell is a clone of its (ZOb's) original
|
||||
// central cell; that's why '...im2), true);'
|
||||
note.cellRepr(catCell.getOrNewCell(AwtUtil.d_from), true);
|
||||
catCell = catCell.getOrNewCell(AwtUtil.d_to);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/** return note cell, if possible
|
||||
*/
|
||||
static ZZCell getNoteCellOrCursor(Object ob) {
|
||||
ZZCell c = null;
|
||||
if(ob instanceof ZZCursor) c = ((ZZCursor)ob).get();
|
||||
else if(ob instanceof ZZCell) c = (ZZCell)ob;
|
||||
else return null;
|
||||
ZZCell link = c.s(AwtUtil.d_from, -1);
|
||||
if(link == null) return null;
|
||||
if(link.s(AwtUtil.d_to, -1) == null) return null;
|
||||
return c;
|
||||
}
|
||||
|
||||
static public void nile_action(String id, ZZCell vc1, ZZCell vc2, String key,
|
||||
ZZCursor cur) {
|
||||
|
||||
boolean split = false;
|
||||
|
||||
ZZCell viewCell = vc1;
|
||||
ZZCell otherCell = vc2;
|
||||
|
||||
p("Nile action: id: '"+id+"' key: '"+key);
|
||||
|
||||
StringTokenizer st = new StringTokenizer(id);
|
||||
String[] toks = new String[st.countTokens()];
|
||||
for(int i=0; i<toks.length; i++)
|
||||
toks[i] = st.nextToken();
|
||||
|
||||
int dir = 0;
|
||||
Nile2Unit unit = null;
|
||||
if(toks.length > 1) {
|
||||
if(toks[1].equals("+")) dir = 1;
|
||||
else if(toks[1].equals("-")) dir = -1;
|
||||
|
||||
if(toks.length > 2) {
|
||||
if(toks[2].equals("CHAR"))
|
||||
unit = new Nile2Unit.Char();
|
||||
else if(toks[2].equals("WORD"))
|
||||
unit = new Nile2Unit.Word();
|
||||
else if(toks[2].equals("SENT"))
|
||||
unit = new Nile2Unit.Sentence();
|
||||
else if(toks[2].equals("PARA"))
|
||||
unit = new Nile2Unit.Paragraph();
|
||||
}
|
||||
}
|
||||
|
||||
id = toks[0];
|
||||
|
||||
if(id.equals("Cursor")) {
|
||||
p("Cursor: "+dir);
|
||||
Nile2Ops.moveCursor(unit, viewCell, dir);
|
||||
ZZUpdateManager.setFast(null);
|
||||
}
|
||||
else if(id.equals("AdjLeft")) {
|
||||
Nile2Ops.adjust(unit, viewCell, -1, dir);
|
||||
ZZUpdateManager.setFast(null);
|
||||
}
|
||||
else if(id.equals("AdjRight")) {
|
||||
Nile2Ops.adjust(unit, viewCell, 1, dir);
|
||||
ZZUpdateManager.setFast(null);
|
||||
}
|
||||
else if(id.equals("Hop")) {
|
||||
Nile2Ops.hop(unit, viewCell, dir);
|
||||
}
|
||||
else if(id.equals("Mode")) {
|
||||
Nile2Ops.setCursor(unit, viewCell, null);
|
||||
if(split)
|
||||
Nile2Ops.setCursor(unit, otherCell, null);
|
||||
}
|
||||
else if(id.equals("Insert")) {
|
||||
Nile2Ops.insert(viewCell, key);
|
||||
|
||||
// Set the selection of other half to char mode, too
|
||||
if(split)
|
||||
Nile2Ops.setCursor(new Nile2Unit.Char(), otherCell, null);
|
||||
}
|
||||
else if(id.equals("BackSpace")) {
|
||||
Nile2Ops.backspace(unit, viewCell);
|
||||
}
|
||||
else if(id.equals("Delete")) {
|
||||
Nile2Ops.del(unit, viewCell);
|
||||
}
|
||||
else if(id.equals("BreakParagraph")) {
|
||||
Nile2Ops.breakParagraph(unit, viewCell);
|
||||
}
|
||||
else if(id.equals("Tunnel")) {
|
||||
if(otherCell != null) {
|
||||
Nile2Ops.tunnel(unit, otherCell, viewCell, dir, false);
|
||||
}
|
||||
}
|
||||
else if(id.equals("Transcopy")) {
|
||||
if(otherCell != null) {
|
||||
Nile2Ops.tunnel(unit, otherCell, viewCell, dir, true);
|
||||
}
|
||||
}
|
||||
else if(id.equals("PUICopy")) {
|
||||
ZZCell c = ZZCursorReal.get(viewCell);
|
||||
String s = Nile2Ops.stringify(c);
|
||||
ZZUtil.puiCopy(s);
|
||||
}
|
||||
/*
|
||||
else if(id.equals("TraverseTranscopies")) {
|
||||
Nile2Ops.traverseTranscopies(viewCell, dir);
|
||||
}
|
||||
*/
|
||||
|
||||
//Object ob = null;
|
||||
//if(pt != null)
|
||||
// ob = xi.getObjectAt(pt.x, pt.y);
|
||||
|
||||
if(id.equals("MouseSetCursor") && cur!=null) {
|
||||
p("Setting cursor from mouse! Unit: "+unit);
|
||||
if(cur.get().h("d.nile").equals(viewCell)) {
|
||||
Nile2Ops.setCursor(unit, viewCell, cur);
|
||||
} else
|
||||
if(cur.get().h("d.nile").equals(otherCell)) {
|
||||
Nile2Ops.setCursor(unit, otherCell, cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
abstract public void raster(FlobSet into, FlobFactory fact,
|
||||
ZZCell view, String[] dims, ZZCell accursed);
|
||||
|
||||
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) {
|
||||
|
||||
ZZUpdateManager.setFast(view);
|
||||
Object ob = null;
|
||||
AwtNote note = null;
|
||||
AwtMetrics M;
|
||||
ZZCell nc;
|
||||
Point noteRVCoord = null;
|
||||
double[] noteVVCoord = null;
|
||||
double deltaX, deltaY;
|
||||
|
||||
if(pt != null && xi != null) ob = xi.getObjectAt(pt.x, pt.y);
|
||||
|
||||
nc = getNoteCellOrCursor(ob);
|
||||
|
||||
if(nc != null) {
|
||||
note = (AwtNote)AwtUtil.readZObClone(nc);
|
||||
note.setCell(nc);
|
||||
}
|
||||
|
||||
boolean forceOrigoChange = false;
|
||||
ZZCell AwtSystemList;
|
||||
ZZCell vc = view.getViewcell();
|
||||
|
||||
pa("NOTECELL: "+nc);
|
||||
|
||||
pa("Note action! '"+id+"' key: "+key);
|
||||
|
||||
// is nile mode on?
|
||||
boolean nileOn = false;
|
||||
ZZCell curb = vc.h("d.bind", 1, true);
|
||||
if(curb!=null) {
|
||||
String mode = ZZCursorReal.get(curb).getText();
|
||||
if(mode.indexOf("Nile") >= 0)
|
||||
nileOn = true;
|
||||
}
|
||||
pa("OBJECT: "+ob);
|
||||
boolean isC = false;
|
||||
if(ob instanceof ZZCursor) isC = true;
|
||||
pa("IS CURSOR?: "+isC);
|
||||
// if we have object which is not cursor, then nile action is impossible
|
||||
if(nileOn && !(!(ob instanceof ZZCursor) && (ob != null)) ) {
|
||||
ZZCell nvc1 = AwtUtil.getCursoredCell(c_cursor1, vc);
|
||||
ZZCell nvc2 = AwtUtil.getCursoredCell(c_cursor2, vc);
|
||||
if(nvc1==null) return;
|
||||
|
||||
if(nvc1.s("d.cursor-cargo", -1)==null) {
|
||||
ZZCursorReal.set(nvc1, nvc1);
|
||||
ZZCursorReal.setOffs(nvc1, 0);
|
||||
}
|
||||
if(nvc2!=null)
|
||||
if(nvc2.s("d.cursor-cargo", -1)==null) {
|
||||
ZZCursorReal.set(nvc2, nvc2);
|
||||
ZZCursorReal.setOffs(nvc2, 0);
|
||||
}
|
||||
|
||||
nile_action(id, nvc1, nvc2, key, (ZZCursor)ob);
|
||||
//Nile1.module.action(id,code,target,nview,cview,key,pt,xi);
|
||||
return;
|
||||
}
|
||||
|
||||
if(id.equals("TESTWIN")) {
|
||||
AwtSystemList = target;
|
||||
|
||||
// set awt dims
|
||||
AwtUtil.addDims(ZZDefaultSpace.findDefaultDimlist(code.getHomeCell()));
|
||||
|
||||
// Cursors
|
||||
ZZCell curs = AwtSystemList.findText(AwtUtil.d_awtool, 1, "Cursors");
|
||||
if(curs == null) {
|
||||
ZZCell nCurs1, nCurs2, cat1;
|
||||
ZZCell cursors = AwtSystemList.N(AwtUtil.d_awtool);
|
||||
cursors.setText("Cursors");
|
||||
cursors.N("d.1");
|
||||
}
|
||||
|
||||
// View
|
||||
ZZCell rastname, rl, rc = AwtSystemList.findText(AwtUtil.d_awtool, 1, "View");
|
||||
if(rc == null) {
|
||||
rc = AwtSystemList.N(AwtUtil.d_awtool);
|
||||
rc.setText("View");
|
||||
rl = rc.N("d.1");
|
||||
rl.connect("d.2", 1, rl);
|
||||
rl.setText("Awtool");
|
||||
rastname = rl.N("d.1");
|
||||
rastname.setText("Awtool.View1");
|
||||
} else {
|
||||
rl = rc.s("d.1");
|
||||
rastname = rl.s("d.1");
|
||||
}
|
||||
|
||||
|
||||
// Bindings
|
||||
ZZCell bindhome = AwtSystemList.findText(AwtUtil.d_awtool, 1, "Bind");
|
||||
if(bindhome == null) {
|
||||
bindhome = AwtSystemList.N(AwtUtil.d_awtool);
|
||||
bindhome.setText("Bind");
|
||||
bindhome = bindhome.N("d.1", 1);
|
||||
|
||||
//ZZDefaultSpace.mkCorner(bindhome, actions);
|
||||
actions(bindhome.h("d.2", 1));
|
||||
} else {
|
||||
bindhome = bindhome.s("d.1");
|
||||
}
|
||||
// View metrics
|
||||
ZZCell metr = AwtSystemList.findText(AwtUtil.d_awtool, 1, "Metrics");
|
||||
if(metr == null) {
|
||||
Dimension RV = new Dimension(400, 400);
|
||||
Dimension VV = new Dimension(1000, 1000);
|
||||
// create 'metrics collection'
|
||||
metr = AwtSystemList.N(AwtUtil.d_awtool);
|
||||
metr.setText("Metrics");
|
||||
ZZCell mnew, metrList;
|
||||
|
||||
mnew = metrList = metr.N("d.1");
|
||||
|
||||
M = new AwtMetricsNormal(mnew, RV, VV, 0.0,0.0);
|
||||
M.cellRepr();
|
||||
|
||||
mnew = mnew.N("d.2");
|
||||
M = new AwtMetricsFC(mnew, RV, VV, 0.0, 0.0);
|
||||
M.cellRepr();
|
||||
|
||||
mnew = mnew.N("d.2");
|
||||
M = new AwtMetricsFC2(mnew, RV, VV, 0.0, 0.0);
|
||||
M.cellRepr();
|
||||
|
||||
// make circle
|
||||
mnew.connect("d.2", 1, metrList);
|
||||
AwtUtil.setCursor(c_metrics, metrList, AwtSystemList);
|
||||
|
||||
|
||||
} else {
|
||||
ZZCell currentMetrics =
|
||||
AwtUtil.getCursoredCell(c_metrics, AwtSystemList);
|
||||
if(currentMetrics == null) {
|
||||
currentMetrics = metr.s("d.1");
|
||||
AwtUtil.setCursor(c_metrics, currentMetrics, AwtSystemList);
|
||||
}
|
||||
M = (AwtMetrics)AwtUtil.readZObClone(currentMetrics);
|
||||
M.setCell(currentMetrics);
|
||||
}
|
||||
|
||||
// searching for active category ...
|
||||
ZZCell ac = AwtUtil.getCursoredCell(c_activeCategory, AwtSystemList);
|
||||
if(ac == null) {
|
||||
if(AwtSystemList.getRankLength(AwtUtil.d_categories)>1) {
|
||||
ac = AwtSystemList.s(AwtUtil.d_categories);
|
||||
} else {
|
||||
ac = AwtSystemList.N(AwtUtil.d_categories);
|
||||
ac.setText("* SCRATCH *");
|
||||
}
|
||||
AwtUtil.setCursor(c_activeCategory, ac, AwtSystemList);
|
||||
}
|
||||
|
||||
ZZCell v = ZZDefaultSpace.newToplevelView(rc.getSpace(),
|
||||
"awtool", 0, 0, M.RealView[0], M.RealView[1],
|
||||
rl, null,
|
||||
null, null,
|
||||
null,
|
||||
new Color(0xFFFFB1));
|
||||
|
||||
// Then, set bindings
|
||||
ZZCell bcurs = v.getOrNewCell("d.bind", 1);
|
||||
ZZCursorReal.set(bcurs, bindhome);
|
||||
ZZCursorReal.setColor(bcurs, Color.black);
|
||||
|
||||
|
||||
ZZCell awtc = v.h("d.2", 1).N("d.2");
|
||||
awtc.setText("AwtSystemList");
|
||||
ZZCursorReal.set(awtc, AwtSystemList);
|
||||
// init shared cursors
|
||||
ZZCell scursors = v.h("d.2",1).N("d.2");
|
||||
scursors.setText("SharedCursors");
|
||||
scursors.N("d.1");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
AwtSystemList = AwtUtil.getAwtSysList(view.getViewcell());
|
||||
if(AwtSystemList == null && !id.equals("TESTWIN")) {
|
||||
throw new ZZError("Awtool: AwtSystemList missing!!");
|
||||
}
|
||||
|
||||
M = AwtUtil.getAwtMetrics(AwtSystemList);
|
||||
|
||||
if(id.equals("StartDrag")) {
|
||||
if(note != null) {
|
||||
dragNote = note;
|
||||
noteRVCoord = M.mapToRealView(note.getX(), note.getY());
|
||||
dragOffs.x = noteRVCoord.x - pt.x;
|
||||
dragOffs.y = noteRVCoord.y - pt.y;
|
||||
}
|
||||
} else
|
||||
|
||||
if(id.equals("StopDrag") && dragNote != null) {
|
||||
noteVVCoord = M.mapToVirtualView(pt.x + dragOffs.x, pt.y + dragOffs.y);
|
||||
dragNote.setCoord(noteVVCoord[0], noteVVCoord[1]);
|
||||
dragNote.cellRepr();
|
||||
dragOffs.x = 0; dragOffs.y = 0;
|
||||
dragNote = null;
|
||||
} else
|
||||
|
||||
if(id.equals("Dragged") && dragNote != null) {
|
||||
noteVVCoord = M.mapToVirtualView(pt.x + dragOffs.x, pt.y + dragOffs.y);
|
||||
dragNote.setCoord(noteVVCoord[0], noteVVCoord[1]);
|
||||
ZZUpdateManager.chg();
|
||||
//dragNote.cellRepr();
|
||||
} else
|
||||
|
||||
|
||||
if(id.equals("StartResize")) {
|
||||
if(note != null) {
|
||||
dragNote = note;
|
||||
noteRVCoord = M.mapToRealView(note.getX(), note.getY());
|
||||
dragOffs.x = noteRVCoord.x - pt.x;
|
||||
dragOffs.y = noteRVCoord.y - pt.y;
|
||||
}
|
||||
} else
|
||||
|
||||
if(id.equals("StopResize") && dragNote != null) {
|
||||
noteVVCoord = M.mapToVirtualView(pt.x + dragOffs.x, pt.y + dragOffs.y);
|
||||
dragNote.setCoord(noteVVCoord[0], noteVVCoord[1]);
|
||||
dragNote.cellRepr();
|
||||
dragOffs.x = 0; dragOffs.y = 0;
|
||||
dragNote = null;
|
||||
} else
|
||||
|
||||
if(id.equals("Resizing") && dragNote != null) {
|
||||
} else
|
||||
|
||||
if(id.equals("StartCreatingNote")) {
|
||||
dragCoord = pt;
|
||||
// this is chanced to 'true' when dragging occurs
|
||||
creatingNote = false;
|
||||
} else
|
||||
|
||||
if(id.equals("CreatingNote")) {
|
||||
creatingNote = true;
|
||||
} else
|
||||
|
||||
if(id.equals("StopCreatingNote") && creatingNote) {
|
||||
ZZCell newNoteCell;
|
||||
AwtNote newNote;
|
||||
int cx = (dragCoord.x+pt.x)>>1;
|
||||
int cy = (dragCoord.y+pt.y)>>1;
|
||||
double[] ndim, nvcenter = M.mapToVirtualView(cx, cy);
|
||||
Dimension nd = new Dimension(Math.abs(dragCoord.x-pt.x), Math.abs(dragCoord.y-pt.y));
|
||||
ndim = M.getVirtualDimension(cx, cy, nd);
|
||||
|
||||
ZZCell ac = AwtUtil.getCursoredCell(c_activeCategory, vc);
|
||||
|
||||
ZZCell noteCell =
|
||||
ac.h(AwtUtil.d_to).N(AwtUtil.d_to).N(AwtUtil.d_from);
|
||||
|
||||
AwtUtil.createNewNote(noteCell, nvcenter, ndim);
|
||||
// attach new note also to 'notes' dimension along
|
||||
// active category cell.
|
||||
ac.h(AwtUtil.d_notes, 1).connect(AwtUtil.d_notes, 1, noteCell);
|
||||
dragCoord.x = 0;
|
||||
dragCoord.y = 0;
|
||||
creatingNote = false;
|
||||
|
||||
} else
|
||||
|
||||
if(id.equals("SetCursor1") && nc != null) {
|
||||
ZZCell red = AwtUtil.getCursoredCell(c_cursor1, vc);
|
||||
if(red.equals(nc)) return;
|
||||
AwtUtil.setCursor(c_cursor2, red, vc);
|
||||
AwtUtil.setCursor(c_cursor1, nc, vc);
|
||||
if(red!=null) {
|
||||
red.excise("d.nile-wins");
|
||||
nc.connect("d.nile-wins", 1, red);
|
||||
nc.connect("d.nile-wins", -1, red);
|
||||
}
|
||||
} else
|
||||
|
||||
if(id.equals("SetCursor2") && nc != null) {
|
||||
ZZCell gray = AwtUtil.getCursoredCell(c_cursor2, vc);
|
||||
if(gray.equals(nc)) return;
|
||||
AwtUtil.setCursor(c_cursor1, gray, vc);
|
||||
AwtUtil.setCursor(c_cursor2, nc, vc);
|
||||
if(gray!=null) {
|
||||
gray.excise("d.nile-wins");
|
||||
nc.connect("d.nile-wins", 1, gray);
|
||||
nc.connect("d.nile-wins", -1, gray);
|
||||
}
|
||||
|
||||
} else
|
||||
|
||||
if(id.equals("NewLink")) {
|
||||
ZZCell c1, c2;
|
||||
c1 = AwtUtil.getCursoredCell(c_cursor1, vc);
|
||||
c2 = AwtUtil.getCursoredCell(c_cursor2, vc);
|
||||
if(c1 != null && c2 != null && c1 != c2) {
|
||||
AwtUtil.createNewLink(c1, c2);
|
||||
}
|
||||
} else
|
||||
|
||||
if(id.equals("ChangeMetrics")) {
|
||||
// save current metrics (focus, origo, etc.)
|
||||
M.cellRepr();
|
||||
ZZCell mc = AwtUtil.getCursoredCell(c_metrics, vc);
|
||||
mc = mc.s("d.2");
|
||||
AwtUtil.setCursor(c_metrics, mc, vc);
|
||||
M = (AwtMetrics)AwtUtil.readZObClone(mc);
|
||||
M.setCell(mc);
|
||||
ZZUpdateManager.chg();
|
||||
} else
|
||||
|
||||
if(id.equals("ResetOrigo")) {
|
||||
//pa("ORIGO RESET!");
|
||||
M.setOrigo(0.0, 0.0);
|
||||
ZZUpdateManager.chg();
|
||||
} else
|
||||
|
||||
if(id.equals("GridOnOff")) {
|
||||
//pa("GRID ON/OFF!");
|
||||
boolean gon = M.GridOn;
|
||||
M.GridOn = gon ? false : true;
|
||||
if(M.GridOn != gon) {
|
||||
M.cellRepr();
|
||||
}
|
||||
ZZUpdateManager.chg();
|
||||
} else
|
||||
|
||||
if(id.equals("FocusOrigoAndSelect")) {
|
||||
long elapsedTime = Long.MAX_VALUE;
|
||||
long cur = System.currentTimeMillis();
|
||||
double[] vf1, vf2;
|
||||
|
||||
vf1 = M.mapToVirtualView(pt.x, pt.y);
|
||||
M.setFocusOrigo(pt.x, pt.y, nc);
|
||||
vf2 = M.mapToVirtualView(pt.x, pt.y);
|
||||
M.moveOrigo(vf1[0]-vf2[0], vf1[1]-vf2[1]);
|
||||
M.cellRepr();
|
||||
|
||||
if(focusChangedLastTime > 0) {
|
||||
elapsedTime = cur - focusChangedLastTime;
|
||||
focusChangedLastTime = -1;
|
||||
} else {
|
||||
focusChangedLastTime = cur;
|
||||
}
|
||||
|
||||
pa("ELAPSED_TIME: "+elapsedTime);
|
||||
|
||||
if(elapsedTime < 1500) {
|
||||
// 'doubleclick'-focus should change also origo
|
||||
// this does not work reasonably
|
||||
// forceOrigoChange = true;
|
||||
forceOrigoChange = false;
|
||||
} else { ZZUpdateManager.chg(); }
|
||||
}
|
||||
|
||||
|
||||
if(id.equals("ChangeOrigo") || forceOrigoChange) {
|
||||
double[] vvp = M.mapToVirtualView(pt.x, pt.y);
|
||||
// new origo is wanted to be in the center of realview
|
||||
double[] realOrigo = M.mapToVirtualView(M.RealView[0]>>1,
|
||||
M.RealView[1]>>1);
|
||||
M.moveOrigo(vvp[0]-realOrigo[0], vvp[1]-realOrigo[1]);
|
||||
M.cellRepr();
|
||||
ZZUpdateManager.chg();
|
||||
}
|
||||
}
|
||||
|
||||
public ZOb newZOb(String id) {
|
||||
if(id.equals("View1"))
|
||||
return new AwtView1();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
// This is really hacky part...
|
||||
static ZZCell curAct;
|
||||
static void a(String key, String act) { a(key, act, null); }
|
||||
static void a(String key, String act, ZZCell next) {
|
||||
curAct = curAct.N("d.2", 1);
|
||||
curAct.setText(key);
|
||||
ZZCell n = curAct.N("d.1", 1);
|
||||
n.setText("Awtool." + act);
|
||||
if(next != null)
|
||||
next.insert("d.3", 1, n);
|
||||
}
|
||||
|
||||
static void actions(ZZCell start) {
|
||||
ZZCell awtact = start; awtact.setText("Awtool mode");
|
||||
ZZCell nchar = awtact.N("d.1",1); nchar.setText("Nile char");
|
||||
ZZCell nword = nchar.N("d.1", 1); nword.setText("Nile word");
|
||||
ZZCell nsent = nword.N("d.1", 1); nsent.setText("Nile sent");
|
||||
ZZCell npara = nsent.N("d.1", 1); npara.setText("Nile para");
|
||||
|
||||
ZZCell ncommon = npara.N("d.1", 1); ncommon.setText("Nile common");
|
||||
|
||||
|
||||
|
||||
curAct = nword;
|
||||
// Annoying - these should be structurally
|
||||
// describable!!!
|
||||
a("MouseClicked1", "MouseSetCursor 0 WORD");
|
||||
a("Backspace", "BackSpace 0 WORD");
|
||||
a("Delete", "Delete 0 WORD");
|
||||
a("Alt-Backspace", "Delete 0 WORD");
|
||||
a("Ctrl-P", "Tunnel - WORD"); // P for pull
|
||||
a("Ctrl-T", "Transcopy - WORD");
|
||||
a("Left", "Cursor - WORD");
|
||||
a("Right", "Cursor + WORD");
|
||||
a("Shift-Left", "AdjLeft - WORD");
|
||||
a("Shift-Right", "AdjRight + WORD");
|
||||
a("Ctrl-Left", "AdjRight - WORD");
|
||||
a("Ctrl-Right", "AdjLeft + WORD");
|
||||
a("Alt-Left", "Hop - WORD");
|
||||
a("Alt-Right", "Hop + WORD");
|
||||
a("Enter", "BreakParagraph 0 WORD");
|
||||
|
||||
a("Up", "Cursor - SENT");
|
||||
a("Down", "Cursor + SENT");
|
||||
a("Alt-Up", "Hop - SENT");
|
||||
a("Alt-Down", "Hop + SENT");
|
||||
|
||||
a("INSERT", "Insert", nchar);
|
||||
a("Tab", "Mode 0 SENT", nsent);
|
||||
// awtool specific
|
||||
a("Alt-N", "NileOnOff", awtact);
|
||||
|
||||
curAct = nsent;
|
||||
a("MouseClicked1", "MouseSetCursor 0 SENT");
|
||||
a("Backspace", "BackSpace 0 SENT");
|
||||
a("Delete", "Delete 0 SENT");
|
||||
a("Alt-Backspace", "Delete 0 SENT");
|
||||
a("Ctrl-P", "Tunnel - SENT"); // P for push
|
||||
a("Ctrl-T", "Transcopy - SENT");
|
||||
a("Left", "Cursor - SENT");
|
||||
a("Right", "Cursor + SENT");
|
||||
a("Shift-Left", "AdjLeft - SENT");
|
||||
a("Shift-Right", "AdjRight + SENT");
|
||||
a("Ctrl-Left", "AdjRight - SENT");
|
||||
a("Ctrl-Right", "AdjLeft + SENT");
|
||||
a("Alt-Left", "Hop - SENT");
|
||||
a("Alt-Right", "Hop + SENT");
|
||||
a("Enter", "BreakParagraph 0 SENT");
|
||||
|
||||
a("Up", "Cursor - PARA");
|
||||
a("Down", "Cursor + PARA");
|
||||
a("Alt-Up", "Hop - PARA");
|
||||
a("Alt-Down", "Hop + PARA");
|
||||
|
||||
a("INSERT", "Insert", nchar);
|
||||
a("Tab", "Mode 0 CHAR", nchar);
|
||||
// awtool specific
|
||||
a("Alt-N", "NileOnOff", awtact);
|
||||
|
||||
/*
|
||||
curAct = npara;
|
||||
a("MouseClicked1", "MouseSetCursor 0 PARA");
|
||||
a("Backspace", "BackSpace 0 PARA");
|
||||
a("Delete", "Delete 0 PARA");
|
||||
a("Alt-Backspace", "Delete 0 PARA");
|
||||
a("Left", "Cursor - PARA");
|
||||
a("Right", "Cursor + PARA");
|
||||
a("Shift-Left", "AdjLeft - PARA");
|
||||
a("Shift-Right", "AdjRight + PARA");
|
||||
a("Ctrl-Left", "AdjRight - PARA");
|
||||
a("Ctrl-Right", "AdjLeft + PARA");
|
||||
a("Alt-Left", "Hop - PARA");
|
||||
a("Alt-Right", "Hop + PARA");
|
||||
|
||||
a("INSERT", "Insert");
|
||||
a("Tab", "Mode 0 CHAR", nchar);
|
||||
*/
|
||||
|
||||
curAct = nchar;
|
||||
a("MouseClicked1", "MouseSetCursor 0 CHAR");
|
||||
a("Left", "Cursor - CHAR");
|
||||
a("Right", "Cursor + CHAR");
|
||||
a("Backspace", "BackSpace 0 CHAR");
|
||||
a("Delete", "Delete 0 CHAR");
|
||||
a("Alt-Backspace", "Delete 0 CHAR");
|
||||
a("INSERT", "Insert");
|
||||
a("Tab", "Mode 0 WORD", nword);
|
||||
a("Enter", "BreakParagraph 0 CHAR");
|
||||
|
||||
a("Ctrl-C", "PUICopy 0 CHAR");
|
||||
|
||||
a("Up", "Cursor - WORD");
|
||||
a("Down", "Cursor + WORD");
|
||||
// awtool specific
|
||||
a("Alt-N", "NileOnOff", awtact);
|
||||
|
||||
// awtool acts
|
||||
curAct = awtact;
|
||||
a("MouseStartDrag", "StartDrag");
|
||||
a("MouseDragged1", "Dragged");
|
||||
a("MouseReleased1", "StopDrag");
|
||||
a("Shift-MouseStartDrag", "StartCreatingNote");
|
||||
a("Shift-MouseDragged1", "CreatingNote");
|
||||
a("Shift-MouseReleased1", "StopCreatingNote");
|
||||
a("Shift-MouseClicked3", "ChangeOrigo");
|
||||
a("MouseClicked3", "FocusOrigoAndSelect");
|
||||
a("Shift-MouseClicked1", "SetCursor2");
|
||||
a("MouseClicked1", "SetCursor1");
|
||||
a("l", "NewLink");
|
||||
a("m", "ChangeMetrics");
|
||||
a("g", "GridOnOff");
|
||||
a("r", "ResetOrigo");
|
||||
a("Alt-N", "NileOnOff", nchar);
|
||||
|
||||
}
|
||||
}
|
||||
78
Modules/awtool/BooleanMesh.java
Normal file
78
Modules/awtool/BooleanMesh.java
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
BooleanMesh.java
|
||||
*
|
||||
* Copyright (c) 2000-2001 Ted Nelson and Tuomas Lukka
|
||||
* Copyright (c) 2000-2001 Benjamin 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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class BooleanMesh {
|
||||
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); }
|
||||
|
||||
static String d_1 = "d.1"; static String d_2 = "d.2";
|
||||
static public ZZCell bStructure = null;
|
||||
static public Hashtable bOperators = new Hashtable();
|
||||
|
||||
/*
|
||||
*/
|
||||
public BooleanMesh(ZZCell bs) {
|
||||
bStructure = bs;
|
||||
bOperators.put("AND", new boolean[][]{{false, false}, {false, true}});
|
||||
bOperators.put("OR", new boolean[][]{{false, true}, {true, true}});
|
||||
bOperators.put("XOR", new boolean[][]{{false, true}, {true, false}});
|
||||
}
|
||||
|
||||
public boolean evaluate(ZZCell nhc) { return evaluate(bStructure, nhc); }
|
||||
|
||||
private boolean evaluate(ZZCell bElem, ZZCell nhc) {
|
||||
String bt = bElem.getText();
|
||||
p("belem:"+bt+" c:"+nhc.getText());
|
||||
ZZCell arg1, arg2;
|
||||
int i = 0, j = 0;
|
||||
if(bOperators.containsKey(bt)) {
|
||||
// add exception handling here!
|
||||
arg1 = bElem.s(d_1); arg2 = bElem.s(d_2);
|
||||
p("arg1:"+arg1.getText());
|
||||
p("arg2:"+arg2.getText());
|
||||
if(evaluate(arg1, nhc)) i = 1;
|
||||
if(evaluate(arg2, nhc)) j = 1;
|
||||
p("i:"+i+" j:"+j);
|
||||
boolean retv = ((boolean[][])bOperators.get(bt))[i][j];
|
||||
p("RETV: "+retv);
|
||||
return retv;
|
||||
} else {
|
||||
// compare bElem (=categoryname) and c
|
||||
p("TEST! "+nhc.getText()+" =?= "+bElem.getText());
|
||||
return testBelonging(nhc, bElem);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract boolean testBelonging(ZZCell c, ZZCell category);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
58
Modules/awtool/README
Normal file
58
Modules/awtool/README
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
A(ssociative) writing tool -demo
|
||||
--------------------------------
|
||||
|
||||
Althought you cannot actually write with this demo at the moment,
|
||||
it is (however) possible to
|
||||
|
||||
- create new notes by dragging mouse and keeping
|
||||
mouse1-key pressed
|
||||
- drag and drop notes created before
|
||||
- link notes by attaching cursors (click mouse1 / shift-mouse1
|
||||
on a note) to a pair of notes and pressing 'l' (uncapitalized 'L')
|
||||
- change metrics by pressing 'm' (currently 3 possibilities)
|
||||
- change focus (click mouse3-button)
|
||||
- change origo (click shift-mouse3)
|
||||
|
||||
To start:
|
||||
- create new action 'Awtool.TESTWIN' in zz-system
|
||||
- use it to invoke awtool
|
||||
|
||||
About the view:
|
||||
- Real view (rendered part) is mutable
|
||||
- Virtual view is fixed, all objects' places
|
||||
are based on virtual view coordinates (-1.0<x,y<1.0),
|
||||
These in turn correspond with some pixel-coordinates.
|
||||
- Origo (o) is related to Virtual view
|
||||
- Focus (f) is related to Real view
|
||||
|
||||
|
||||
------------------------------------
|
||||
|(Virtual view 800x600, -1 ... 1) |
|
||||
| ________________________ |
|
||||
| |Real view | |
|
||||
| |400x300 | |
|
||||
| | | |
|
||||
| | | |
|
||||
| | | |
|
||||
| | o=(0.0, 0.0)| |
|
||||
| | | |
|
||||
| | | |
|
||||
| | f=(50, 250) | |
|
||||
| | | |
|
||||
| | | |
|
||||
| ------------------------- |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
------------------------------------
|
||||
|
||||
|
||||
|
||||
Misc:
|
||||
Special dimensions. Awtool uses its own system-dimension
|
||||
'd.awtool', which stores the state of the applitude. So,
|
||||
if you quit awtool and start it newly with datacursor pointing
|
||||
to the same cell, you should end up with the old working-view
|
||||
(layer or category of notes).
|
||||
|
||||
14
Modules/awtool/TODO
Normal file
14
Modules/awtool/TODO
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
TODO:
|
||||
|
||||
- Navigation between layers (=categories)
|
||||
- Creation of new layers
|
||||
- Logical operations (AND, OR, ..) between layers
|
||||
-
|
||||
- (more) ...
|
||||
- ...
|
||||
- rethink
|
||||
- (more) ...
|
||||
- ...
|
||||
|
||||
|
||||
57
Modules/awtool/ZObCellRepr.java
Normal file
57
Modules/awtool/ZObCellRepr.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
ZOb.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 Kimmo Wideroos
|
||||
*/
|
||||
|
||||
package org.gzigzag.module;
|
||||
import org.gzigzag.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
/** Absract class for ZObs which are able to be rolled back into the cellstructure.
|
||||
*/
|
||||
|
||||
public abstract class ZObCellRepr {
|
||||
private ZZCell _rootcell = null;
|
||||
public ZZCell getCell() { return this._rootcell; }
|
||||
public void setCell(ZZCell c) { this._rootcell = c; }
|
||||
|
||||
public String getZObClassName() {
|
||||
String cn = getClass().getName();
|
||||
int i = cn.lastIndexOf(".");
|
||||
return cn.substring(i+1, cn.length());
|
||||
}
|
||||
|
||||
abstract String getZObName();
|
||||
|
||||
/** Write the parameters of this ZOb back in the cellstructure.
|
||||
* Returns a string describing the errors encountered, or null if
|
||||
* everything went fine..
|
||||
* @param start starting cell
|
||||
* @param clone whether or not to make the new ZOb centralcell a clone
|
||||
* of the former centralcell (if cells equal, the whole
|
||||
* issue is trivial).
|
||||
*/
|
||||
abstract String cellRepr(ZZCell start, boolean clone);
|
||||
|
||||
public String cellRepr() {return cellRepr(getCell(), false); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user