gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gzz/modules/pp PPCellView.java PPMouseEvent...


From: Matti Katila
Subject: [Gzz-commits] gzz/gzz/modules/pp PPCellView.java PPMouseEvent...
Date: Tue, 14 Jan 2003 13:30:06 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Matti Katila <address@hidden>   03/01/14 13:30:04

Modified files:
        gzz/modules/pp : PPCellView.java PPMouseEvents.java PPView2.java 
                         demotest.py 
        gzz/modules/pp/vob: VobCSGenerator.java 

Log message:
        cellview + cs generator fix

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/pp/PPCellView.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/pp/PPMouseEvents.java.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/pp/PPView2.java.diff?tr1=1.60&tr2=1.61&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/pp/demotest.py.diff?tr1=1.65&tr2=1.66&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/pp/vob/VobCSGenerator.java.diff?tr1=1.11&tr2=1.12&r1=text&r2=text

Patches:
Index: gzz/gzz/modules/pp/PPCellView.java
diff -u gzz/gzz/modules/pp/PPCellView.java:1.2 
gzz/gzz/modules/pp/PPCellView.java:1.3
--- gzz/gzz/modules/pp/PPCellView.java:1.2      Tue Jan 14 08:36:06 2003
+++ gzz/gzz/modules/pp/PPCellView.java  Tue Jan 14 13:30:04 2003
@@ -42,6 +42,11 @@
            float anotherWidth = style.getWidth(s.substring(linebreak+1, 
s.length()), scale);
            if (w < anotherWidth) w = anotherWidth;
        }
+       
+       w += style.getWidth(" ", scale);
+       if (w > style.getWidth(widthString, scale))
+           w = style.getWidth(widthString, scale);
+
 
        float h;
        if(c != null)
Index: gzz/gzz/modules/pp/PPMouseEvents.java
diff -u gzz/gzz/modules/pp/PPMouseEvents.java:1.23 
gzz/gzz/modules/pp/PPMouseEvents.java:1.24
--- gzz/gzz/modules/pp/PPMouseEvents.java:1.23  Sat Jan 11 12:35:33 2003
+++ gzz/gzz/modules/pp/PPMouseEvents.java       Tue Jan 14 13:30:04 2003
@@ -16,10 +16,10 @@
 import java.awt.event.*;
 
 // needed by swing and JFileChooser
-/** uncomment if you need for demo
+//** uncomment if you need for demo
    import java.io.*;
    import javax.swing.JFileChooser;
-*/
+//*/
 
 
 
@@ -28,7 +28,7 @@
  */
 
 public class PPMouseEvents {
-public static final String rcsid = "$Id: PPMouseEvents.java,v 1.23 2003/01/11 
17:35:33 mudyc Exp $";
+public static final String rcsid = "$Id: PPMouseEvents.java,v 1.24 2003/01/14 
18:30:04 mudyc Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.out.println(s); }
 
@@ -157,7 +157,7 @@
             *  ----------------------------------
             */
 
-           /*
+//         /*
            try {
                JFileChooser fc = new JFileChooser();
                int returnVal = fc.showOpenDialog(null);
@@ -174,7 +174,7 @@
                }
            } catch (Exception e) { pa(e.getMessage()); }
            AbstractUpdateManager.chg();
-           */
+//         */
        }
     }
 
Index: gzz/gzz/modules/pp/PPView2.java
diff -u gzz/gzz/modules/pp/PPView2.java:1.60 
gzz/gzz/modules/pp/PPView2.java:1.61
--- gzz/gzz/modules/pp/PPView2.java:1.60        Tue Jan 14 08:36:06 2003
+++ gzz/gzz/modules/pp/PPView2.java     Tue Jan 14 13:30:04 2003
@@ -36,7 +36,7 @@
 import java.util.*;
 
 public class PPView2 implements View {
-public static final String rcsid = "$Id: PPView2.java,v 1.60 2003/01/14 
13:36:06 tjl Exp $";
+public static final String rcsid = "$Id: PPView2.java,v 1.61 2003/01/14 
18:30:04 mudyc Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.err.println(s); }
 
@@ -344,7 +344,7 @@
 
                    vs.map.put(filletState);
                    int curs = coordinatePlaneView.getCursorBox();
-                   pa("Fillet curs: "+curs);
+                   if (dbg) pa("Fillet curs: "+curs);
                    vs.map.put(fillet, anchorUnit, vs.unitSqCS(curs, "AUSQ"));
                    vs.map.put(postFilletState);
                }
@@ -504,9 +504,9 @@
            if (paper_count > 0) { paper_count--; accursed_paper_count--; }
            
            float home_paper_bottom = 210;
-           int papers_sq = vs.orthoCS(0, "empty", 0,
-                                0, home_paper_bottom,
-                                leftPanelWidth, mainHeight - 
home_paper_bottom);
+           int papers_sq = vs.orthoCS(0, "empty", 100,
+                                      0, home_paper_bottom, 
+                                leftPanelWidth, mainHeight - home_paper_bottom 
+ 100);
            VobCSGenerator cs_gen = 
                new VobCSGenerator(vs, papers_sq, paper_count, 
accursed_paper_count,
                                   leftPanelRealWidth, leftPanelRealHeight);
@@ -525,16 +525,11 @@
                                       -leftPanelRealWidth/2, 
-leftPanelRealHeight/2,
                                       1, 1, leftPanelRealWidth, 
leftPanelRealHeight);
                    vs.matcher.add(ctr, "ctr");
-
-                   //((DefaultVobMatcher)vs.matcher).dumpByParent(fr);
-
                }
                else {
                    fr = cs_gen.getNextCS();
-                   //ctrl = vs.map.
                    ctr = ((GLVobCoorder)vs.coords).getParent(fr);
                }
-
                vs.activate(fr);
                int c2f = vs.coords.ortho(0, 11, 0, 0, 
                                          leftPanelZoom, leftPanelZoom);
Index: gzz/gzz/modules/pp/demotest.py
diff -u gzz/gzz/modules/pp/demotest.py:1.65 gzz/gzz/modules/pp/demotest.py:1.66
--- gzz/gzz/modules/pp/demotest.py:1.65 Mon Jan 13 03:01:17 2003
+++ gzz/gzz/modules/pp/demotest.py      Tue Jan 14 13:30:04 2003
@@ -319,6 +319,13 @@
 gzz.modules.pp.vob.BgVob.dbg = 0
 gzz.modules.pp.vob.CalendarBg.dbg = 0
 
+gzz.modules.pp.vob.VobCSGenerator.noFocus_biggest_percent = 0.85
+gzz.modules.pp.vob.VobCSGenerator.biggest_percent = 0.55
+gzz.modules.pp.vob.VobCSGenerator.percent_of_predecessor = 0.75
+gzz.modules.pp.vob.VobCSGenerator.smallest_percent = 0.36
+
+
+
 currentScene = PPView2Scene()
 
 
Index: gzz/gzz/modules/pp/vob/VobCSGenerator.java
diff -u gzz/gzz/modules/pp/vob/VobCSGenerator.java:1.11 
gzz/gzz/modules/pp/vob/VobCSGenerator.java:1.12
--- gzz/gzz/modules/pp/vob/VobCSGenerator.java:1.11     Tue Jan  7 06:27:29 2003
+++ gzz/gzz/modules/pp/vob/VobCSGenerator.java  Tue Jan 14 13:30:04 2003
@@ -23,11 +23,16 @@
 
 package gzz.modules.pp.vob;
 
+import java.lang.Math;
+
 import gzz.vob.*;
 import gzz.gfx.gl.*;
 
+/** Coordsystem generator prototype 
+ * -used in pp.
+ */
 public class VobCSGenerator {
-public static final String rcsid = "$Id: VobCSGenerator.java,v 1.11 2003/01/07 
11:27:29 mudyc Exp $";
+public static final String rcsid = "$Id: VobCSGenerator.java,v 1.12 2003/01/14 
18:30:04 mudyc Exp $";
     static public boolean dbg=false;
     static public void p(String s) { System.out.print(s); }
     static public void pa(String s) { System.out.println(s); }
@@ -35,35 +40,45 @@
     static public final int HORIZONTAL = 1;
     static public final int VERTICAL = 2;
 
-    public float biggest_percent = 0.5f;
-    public float percent_of_predecessor = 0.7f;
-    public float smallest_percent = 0.2f;
+    private int mode = HORIZONTAL;
 
+    static public float small_area = 2.0f/5.0f;
+    static public float noFocus_biggest_percent = 0.72f;
+    static public float biggest_percent = 0.69f;
+    static public float percent_of_predecessor = 0.72f;
+    static public float smallest_percent = 0.4f;
 
-    private int vob_cs[];
 
+    private int vob_cs[];
+    private boolean noFocus;
 
 
-    /** @params 
-     * focus_index begins from 0
-     * or -1 if focus in home paper.
+    /** Generates coordsystems
+     * @param vs current VobScene.
+     * @param cs_into (orthoCS).
+     * @param vob_count count of vobs.
+     * @param focus_index begins from 0 or -1 if no focus.
+     * @param vob_width 1:1 size of biggest vob.
+     * @param vob_height 1:1 size of biggest vob.
      */
     public VobCSGenerator(VobScene vs, int cs_into, int vob_count,
                          int focus_index, float vob_width, float vob_height) {
 
        if (dbg) pa("Vobs: "+ vob_count+" focus on: "+ focus_index);
-       if ( vob_count == 0) {
+       if (vob_count <= 0) {
            pa("DEBUG: Might be an error - but there are no vob around!");
            return; 
        }
 
+       // check:   -1 is exception
+       if (focus_index == -1) {
+           focus_index++;
+           noFocus = true;
+       } else noFocus = false;
 
-       // check out..  -1 is exception
-       if (focus_index == -1) focus_index++;
        if ( 0 <= focus_index && focus_index < vob_count); 
        else throw new Error("Focus out of vobs");
-
-       GLVobCoorder glc = (GLVobCoorder)vs.coords;
+       VobCoorder glc = vs.coords;
 
        // count how long the width is in given cs
        float [] coords = { 0,0,0,  1,1,0 };
@@ -72,88 +87,77 @@
        glc.transformPoints3(cs_into, coords, trans);
        float x_diff = trans[3] - trans[0]; 
        float y_diff = trans[4] - trans[1];
-
-
-
-
-       final int fake_count = 2 + vob_count;
-       final int fake_focus = focus_index + 2;
-
+       if (dbg) pa("x: "+x_diff+" y: "+y_diff);
 
        float spare_space = y_diff/vob_height - 1;
-       pa("spare: " + spare_space);
-
-
-       
-
-
-
-       float [] rations = new float[vob_count];
-       //float[] sigs = countSigmund(fake_focus);
-
-       float[] sigs = countBoxAlgorithm(fake_focus/fake_count * spare_space,
-                                        fake_focus, vob_height);
-
+       if (dbg) pa("spare: " + spare_space);
+       vob_cs = new int[vob_count];
 
-       for (int i=focus_index; i>=0; i--) {
-           rations[i] = sigs[focus_index-i];
-       }
 
-       //sigs = countSigmund(fake_count - fake_focus);
-       sigs = countBoxAlgorithm((fake_count - fake_focus)/fake_count * 
spare_space,
-                                fake_count-fake_focus, vob_height);
-       for (int i=focus_index; i<vob_count; i++) {
-           rations[i] = sigs[Math.abs(focus_index - i)];
+       /* If so few vobs that they fit well in given space. Fill it 100%
+        */
+       if (vob_count <= spare_space + 1) {
+           for(int i=0; i<spare_space+1 && i<vob_count; i++) {
+               float y = trans[1] + .9f * i * vob_height + 0.5f*vob_height;
+               if (dbg) pa(i+" Y: "+y);
+
+               int a_cs = ((GLVobCoorder)vs.coords).affineCoordsys(0, 100, 
trans[0]+x_diff/2, y,
+                                                                   1,0,0,1);
+               vob_cs[i] = vs.orthoBoxCS(a_cs, "frame"+i, 100, -vob_width/2, 
-vob_height/2,
+                                         1,1, vob_width,vob_height);
+               vs.matcher.add(a_cs, "ctr"+i);
+           }
+           return;
        }
 
-       //for (int i=0; i<vob_count; i++) { p("["+rations[i]+"],");}
-
-
 
-       // focus is number ONE(the biggest) - "Uuno on numero yksi..." =)
-       rations[focus_index] = 1.0f;
-       //proportion(rations, focus_index, y_diff/vob_height );
+       /* Count rations 
+        */
+       float [] rations = new float[vob_count];
+       if (noFocus) {
+           rations = countBoxAlgorithm(vob_count, spare_space + 1);
+       } else {
+           float hi = (vob_count - (float)focus_index-1)/vob_count * 
spare_space;
+           float lo = (float)focus_index/vob_count * spare_space;
+           // pa("hi "+hi+", low"+lo+" area "+(small_area*spare_space));
+           if (lo < small_area * spare_space && focus_index != 0 ||
+               hi < small_area * spare_space && focus_index+1 != vob_count) {
+               hi = spare_space/2;
+               lo = spare_space/2;
+           }
 
-       for (int i=0; i<vob_count; i++) { 
-           if (dbg) p("["+rations[i]+"],");
+           float [] low = countBoxAlgorithm(focus_index, lo);
+           int j=0;
+           for (int i=low.length-1; i>=0; i--) {
+               rations[j++] = low[i];
+           }
+           float [] high = countBoxAlgorithm(vob_count-focus_index-1, hi);
+           for (int i=0; i<high.length; i++) {
+               rations[focus_index + i +1] = high[i];
+           }
+           // focus is number ONE(the biggest) - "Uuno on numero yksi..." =)
+           rations[focus_index] = 1;
        }
 
-       float sum = 0;
-       for (int i=0; i<rations.length; i++) {
-           sum += rations[i];
+       if (dbg) {
+           pa("******FINAL");
+           for (int i=0; i<rations.length; i++) { p("["+rations[i]+"],");}
+           pa("\nFINAL******");
        }
 
-       vob_cs = new int[vob_count];
-
-       float real_ratio = y_diff/sum;
-
        float x_center = trans[0] + x_diff/2;
-       float y_tmp = trans[1];
-
-       float vob_x0 = x_center - vob_width/2;
-
+       float summ = 0;
        for (int i=0; i<vob_count; i++) {
-           float muutos = rations[i] * real_ratio;
-           float y = muutos + y_tmp; 
-
-           float y_d = y - y_tmp;
-
-           int ctr = ((GLVobCoorder)vs.coords).affineCoordsys(0, 100,
-                                                              x_center, y_tmp 
+ muutos/2,  
-                                                              1, 0, 0, 1);
+           float y_center = trans[1] + summ + vob_height * rations[i]/2;
+           float yd = vob_height * rations[i];
+           int ctr =
+               ((GLVobCoorder)vs.coords).affineCoordsys(0, 100, x_center, 
y_center,  
+                                                        1,0,0,1);
            vs.matcher.add(ctr, "ctrl"+i);
-
            vob_cs[i] = vs.orthoBoxCS(ctr, "frame", 100, 
-                         -vob_width/2, -y_d/2, 1,1,
-                         vob_width, y_d);
-
-           if (dbg) {
-               if (i == focus_index) pa("y_tmp: "+ y_tmp +" y_cent: " 
+(y-muutos/2) +
-                                        " y: "+y +" koko: "+(y-y_tmp)+ " 
FOCUS");
-               else pa("y_tmp: "+ y_tmp +" y_cent: " +(y-muutos/2) +" y: "+y 
+" koko: "+(y-y_tmp));
-           }
-           
-           y_tmp = y;
+                         -vob_width/2, -yd/2, 1,1,
+                         vob_width, yd);
+           summ += vob_height * rations[i];
        }
     }
 
@@ -163,31 +167,35 @@
      */
     public int getNextCS() {
        int i = index;
-       if (i < 0 || i >= vob_cs.length) throw new Error("index: "+index+ " out 
of vob_cs.length");
+       if (i < 0 || i >= vob_cs.length) 
+           throw new Error("index: "+index+ " out of vob_cs.length");
        return vob_cs[index++];
     }
 
     /** Easy algorithm 
      */
-    private float[] countBoxAlgorithm(float f, int count, float length) {
-
-       if (count <= 1) return new float[]{ biggest_percent };
-
-       // first index is fake or smthng..
+    private float[] countBoxAlgorithm(int count, float length) {
+       if (dbg) pa("count:"+count+" length:"+length);
+       if (count == 0) return new float[]{};
+       if (count == 1) {
+           if (noFocus) return new float[]{ biggest_percent * 
percent_of_predecessor};
+           else return new float[]{ biggest_percent};
+       }
 
        float[] retArray = new float[count];
-       retArray[1] = biggest_percent;
-
-       float summ = retArray[1] * length;
        float percent = biggest_percent;
-       int i= 2;
+         if (noFocus) {
+             retArray[0] = noFocus_biggest_percent;
+         } else retArray[0] = biggest_percent;
 
+       float summ = retArray[0];
+       int i= 1;
        while (summ < length && i < retArray.length) {
            retArray[i] = percent * percent_of_predecessor;
            if (retArray[i] < smallest_percent)
                retArray[i] = smallest_percent;
 
-           summ += retArray[i] * length;
+           summ += retArray[i];
            percent = retArray[i];
            i++;
        }
@@ -195,56 +203,6 @@
        for (int j=i; j<retArray.length; j++) {
            retArray[j] = 0;
        }
-
-       return retArray;
-    }
-
-
-
-    /** Check out the sigmund function." y0 = tanh(y1)" if you like to 
understand ;)
-     */
-    private float[] countSigmund(int ratio) {
-       float [] retArray = new float[ratio];
-
-       float I = 10.0f;
-       float sigm = I*(float)Math.PI;
-       float start = 3.0f*(float)Math.PI;
-
-       if (ratio < 5) start = 6.5f*(float)Math.PI;
-       else if (ratio < 10) start = 5.0f*(float) Math.PI;
-       if (ratio > 50) start = 1.2f*(float)Math.PI;
-
-       float dx = sigm/ratio;
-
-       for (int i=0; i<ratio; i++) {
-           retArray[i] = (float)  (1/(1+Math.exp(-(start - i*dx))));
-
-           if (dbg) pa(i+"Sigm:" +retArray[i]);
-       }
        return retArray;
-    }
-
-
-    /* Recursive */
-    private void proportion(float[] arr, int focus, float ideal_ratio) {
-       if ( arr.length == 1) return;
-
-       float sum = 0;
-       for (int i=0; i<arr.length; i++) {
-           sum += arr[i];
-       }
-
-       if (dbg) pa("ideal: "+ ideal_ratio + " this ratio: "+ (sum/arr[focus]) 
);
-
-       // normally just make things smaller
-       if (ideal_ratio < (sum/arr[focus]) ) {
-           for (int i=0; i<arr.length; i++) {
-               if (arr[i] == 1.0f) continue;
-               arr[i] *= 0.9f;
-           }
-           if (dbg) pa("smaller recursive");
-           proportion(arr, focus, ideal_ratio); 
-           return;
-       }
     }
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]