[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gzz view/CellVobFactory.java view/DimDecora...
From: |
Benja Fallenstein |
Subject: |
[Gzz-commits] gzz/gzz view/CellVobFactory.java view/DimDecora... |
Date: |
Wed, 25 Sep 2002 15:27:32 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Benja Fallenstein <address@hidden> 02/09/25 15:27:32
Modified files:
gzz/view : CellVobFactory.java DimDecorator.java
LastOpDecorator.java
gzz/vob : DefaultVobMatcher.java
Log message:
Simplify, fix hierarchy
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/CellVobFactory.java.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/DimDecorator.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/LastOpDecorator.java.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/DefaultVobMatcher.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: gzz/gzz/view/CellVobFactory.java
diff -c gzz/gzz/view/CellVobFactory.java:1.10
gzz/gzz/view/CellVobFactory.java:1.11
*** gzz/gzz/view/CellVobFactory.java:1.10 Wed Sep 25 10:45:43 2002
--- gzz/gzz/view/CellVobFactory.java Wed Sep 25 15:27:32 2002
***************
*** 46,52 ****
*/
public class CellVobFactory implements CellView {
! public static final String rcsid = "$Id: CellVobFactory.java,v 1.10
2002/09/25 14:45:43 tjl Exp $";
public static boolean dbg = false;
private static void p(String s) { if(dbg) pa(s); }
private static void pa(String s) { System.err.println(s); }
--- 46,52 ----
*/
public class CellVobFactory implements CellView {
! public static final String rcsid = "$Id: CellVobFactory.java,v 1.11
2002/09/25 19:27:32 benja Exp $";
public static boolean dbg = false;
private static void p(String s) { if(dbg) pa(s); }
private static void pa(String s) { System.err.println(s); }
***************
*** 167,175 ****
Vob.RenderInfo info = v.coords.getRenderInfo(cs);
info.getExtRect(rect);
! final int content_cs = v.coords.coordsys(cs, 0, 5, 5,
rect.width-10, rect.height-10);
- v.matcher.add(content_cs, CONTENT_KEY);
if(!(GraphicsAPI.getInstance() instanceof gzz.client.gl.GLAPI)) {
if(content != null)
--- 167,174 ----
Vob.RenderInfo info = v.coords.getRenderInfo(cs);
info.getExtRect(rect);
! final int content_cs = v.coordsys(cs, CONTENT_KEY, 0, 5, 5,
rect.width-10, rect.height-10);
if(!(GraphicsAPI.getInstance() instanceof gzz.client.gl.GLAPI)) {
if(content != null)
Index: gzz/gzz/view/DimDecorator.java
diff -c gzz/gzz/view/DimDecorator.java:1.4 gzz/gzz/view/DimDecorator.java:1.5
*** gzz/gzz/view/DimDecorator.java:1.4 Wed Sep 25 10:45:43 2002
--- gzz/gzz/view/DimDecorator.java Wed Sep 25 15:27:32 2002
***************
*** 32,38 ****
* vob scene.
*/
public class DimDecorator implements FallbackSceneDecorator {
! String rcsid = "$Id: DimDecorator.java,v 1.4 2002/09/25 14:45:43 tjl Exp $";
public static boolean dbg = true;
private static void p(String s) { if(dbg) pa(s); }
private static void pa(String s) { System.err.println(s); }
--- 32,38 ----
* vob scene.
*/
public class DimDecorator implements FallbackSceneDecorator {
! String rcsid = "$Id: DimDecorator.java,v 1.5 2002/09/25 19:27:32 benja Exp $";
public static boolean dbg = true;
private static void p(String s) { if(dbg) pa(s); }
private static void pa(String s) { System.err.println(s); }
***************
*** 59,82 ****
int w = size.width, h = size.height;
// The coordinate system where the lines start
! int orig = sc.coords.coordsys(into, 0, 0, 0, w, h);
! sc.matcher.add(orig, origKey);
// The coordinate systems of the dimensions
int[] targ = {
! sc.coords.coordsys(into, 0, w, 0, w, h),
! sc.coords.coordsys(into, 0, 0, h, w, h),
! sc.coords.coordsys(into, 0, w, h, w, h)
};
for(int i=0; i<3; i++) {
- sc.matcher.add(targ[i], dimKeys[i]);
sc.map.put(conn, targ[i], orig);
sc.map.put(bg, targ[i]);
! int cs = sc.coords.coordsys(targ[i], 0, 0, 0,
style.getWidth(dims[i].name, 1),
style.getHeight(1));
- sc.matcher.add(cs, dimKeys[i]);
sc.map.put(new TextVob(style, dims[i].name), cs);
}
--- 59,79 ----
int w = size.width, h = size.height;
// The coordinate system where the lines start
! int orig = sc.coordsys(into, origKey, 0, 0, 0, w, h);
// The coordinate systems of the dimensions
int[] targ = {
! sc.coordsys(into, dimKeys[0], 0, w, 0, w, h),
! sc.coordsys(into, dimKeys[1], 0, 0, h, w, h),
! sc.coordsys(into, dimKeys[2], 0, w, h, w, h)
};
for(int i=0; i<3; i++) {
sc.map.put(conn, targ[i], orig);
sc.map.put(bg, targ[i]);
! int cs = sc.coordsys(targ[i], dimKeys[i], 0, 0, 0,
style.getWidth(dims[i].name, 1),
style.getHeight(1));
sc.map.put(new TextVob(style, dims[i].name), cs);
}
Index: gzz/gzz/view/LastOpDecorator.java
diff -c gzz/gzz/view/LastOpDecorator.java:1.9
gzz/gzz/view/LastOpDecorator.java:1.10
*** gzz/gzz/view/LastOpDecorator.java:1.9 Wed Sep 25 10:45:43 2002
--- gzz/gzz/view/LastOpDecorator.java Wed Sep 25 15:27:32 2002
***************
*** 32,38 ****
* directional op entered.
*/
public class LastOpDecorator implements FallbackSceneDecorator {
! String rcsid = "$Id: LastOpDecorator.java,v 1.9 2002/09/25 14:45:43 tjl Exp
$";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
--- 32,38 ----
* directional op entered.
*/
public class LastOpDecorator implements FallbackSceneDecorator {
! String rcsid = "$Id: LastOpDecorator.java,v 1.10 2002/09/25 19:27:32 benja
Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
***************
*** 106,113 ****
float x = padding;
float y = size.height - padding - h;
! int cs = sc.coords.coordsys(into, 0, x, y, w, h);
! sc.matcher.add(cs, key);
br.put(sc, cs);
--- 106,112 ----
float x = padding;
float y = size.height - padding - h;
! int cs = sc.coordsys(into, key, 0, x, y, w, h);
br.put(sc, cs);
Index: gzz/gzz/vob/DefaultVobMatcher.java
diff -c gzz/gzz/vob/DefaultVobMatcher.java:1.3
gzz/gzz/vob/DefaultVobMatcher.java:1.4
*** gzz/gzz/vob/DefaultVobMatcher.java:1.3 Wed Sep 25 14:29:53 2002
--- gzz/gzz/vob/DefaultVobMatcher.java Wed Sep 25 15:27:32 2002
***************
*** 24,88 ****
import java.awt.*;
import java.util.*;
public class DefaultVobMatcher implements VobMatcher {
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
! Object[] keys = new Object[10000];
! HashMap inds = new HashMap();
int maxcs = 0;
! static public int mix(int i1, int i2, int i3) {
! return (i1 * 5124723 + 9812375) % 5350917 +
! (i2 * 127401 + 897124) % 1128501 +
! (i3 * 317819 + 1897124) % 12501 ;
}
// --- implement VobMatcher
public void add(int cs, Object key) {
! if(cs > maxcs) maxcs = cs;
! keys[cs] = key;
! if(key!=null) inds.put(key, new Integer(cs));
}
public void addSub(int into, int cs, Object key) {
! // Create a new key in a somewhat silly way
! // a REAL kludge
! if(dbg) pa("Passed key: "+key);
! key = new Integer(
! mix(key.hashCode(),
! keys[into] != null ? 1 : 0,
! keys[into] != null ? keys[into].hashCode() : 0));
! if(dbg) {
! pa("Old key: "+keys[into]);
! pa("New key: "+key);
! }
! add(cs, key);
}
! protected int getCSByInt(Object key) {
! Integer i = (Integer)inds.get(key);
if(i==null) return -1;
return i.intValue();
}
public int getCS(Object key) {
! // XXX ARGH
! return getCSByInt(new Integer(mix(key.hashCode(), 0, 0)));
}
public Object getKey(int cs) {
! return keys[cs];
}
public int[] interpList(VobMatcher other0) {
DefaultVobMatcher other = (DefaultVobMatcher)other0;
! int[] interpList = new int[maxcs];
! for(int i=0; i<maxcs; i++) {
! if(keys[i] == null)
interpList[i] = -1;
! else
! interpList[i] = other.getCSByInt(keys[i]);
}
return interpList;
}
--- 24,115 ----
import java.awt.*;
import java.util.*;
+ /** A simple hierarchical implementation of VobMatcher.
+ */
public class DefaultVobMatcher implements VobMatcher {
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
!
! static final int INITIAL_SIZE = 20;
! static final Object NULL = new Object();
!
! Key[] keyByCs = new Key[INITIAL_SIZE];
! Map csByKey = new HashMap();
!
int maxcs = 0;
+ class Key {
+ Object key; int parent;
+ Key(Object k, int p) { key=k; parent=p; }
+ public int hashCode() { return key.hashCode() ^ parent; }
+ public boolean equals(Object o) {
+ if(!(o instanceof Key)) return false;
+ Key k = (Key)o;
+ return parent == k.parent && key.equals(k.key);
+ }
+ }
+ void ensure(int n) {
+ if(n+1 > keyByCs.length) {
+ Key[] nu = new Key[2*n+1];
+ System.arraycopy(keyByCs, 0, nu, 0, maxcs);
+ keyByCs = nu;
+ }
+ if(n > maxcs) maxcs = n;
+ }
! public DefaultVobMatcher() {
! addSub(-1, 0, null);
}
// --- implement VobMatcher
public void add(int cs, Object key) {
! addSub(0, cs, key);
}
public void addSub(int into, int cs, Object key) {
! ensure(cs);
! if(key == null) key = NULL;
! keyByCs[cs] = new Key(key, into);
! csByKey.put(keyByCs[cs], new Integer(cs));
}
! protected int getCSByKeyObject(Key key) {
! Integer i = (Integer)csByKey.get(key);
if(i==null) return -1;
return i.intValue();
}
public int getCS(Object key) {
! if(key == null) key = NULL;
! return getCSByKeyObject(new Key(key, 0));
}
public Object getKey(int cs) {
! Object k = keyByCs[cs].key;
! return k == NULL ? null : k;
}
public int[] interpList(VobMatcher other0) {
DefaultVobMatcher other = (DefaultVobMatcher)other0;
! int[] interpList = new int[maxcs+1];
! for(int i=1; i<maxcs+1; i++) {
! if(keyByCs[i] == null)
interpList[i] = -1;
! else {
! Key k = keyByCs[i];
!
! if(k.parent < 0 || k.parent >= i)
! throw new Error("argh "+k.parent);
!
! // XXX assumes that parent is set already
! int other_parent = interpList[k.parent];
!
! Key other_key = new Key(k.key, other_parent);
! interpList[i] = other.getCSByKeyObject(other_key);
!
! if(dbg) pa(i+" "+k.parent+" "+other_parent+" "+
! interpList[i]+" "+k.key);
! }
}
return interpList;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/gzz view/CellVobFactory.java view/DimDecora...,
Benja Fallenstein <=