gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gzz/vob/vobs ColoredSectorVob.java ColoredS...


From: Asko Soukka
Subject: [Gzz-commits] gzz/gzz/vob/vobs ColoredSectorVob.java ColoredS...
Date: Wed, 05 Mar 2003 04:37:30 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Asko Soukka <address@hidden>    03/03/05 04:37:29

Modified files:
        gzz/vob/vobs   : ColoredSectorVob.java 
                         ColoredSquareSectorVob.java 

Log message:
        abstracting

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/vobs/ColoredSectorVob.java.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/vobs/ColoredSquareSectorVob.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: gzz/gzz/vob/vobs/ColoredSectorVob.java
diff -u gzz/gzz/vob/vobs/ColoredSectorVob.java:1.7 
gzz/gzz/vob/vobs/ColoredSectorVob.java:1.8
--- gzz/gzz/vob/vobs/ColoredSectorVob.java:1.7  Wed Mar  5 04:23:44 2003
+++ gzz/gzz/vob/vobs/ColoredSectorVob.java      Wed Mar  5 04:37:29 2003
@@ -46,7 +46,7 @@
  */
 
 public class ColoredSectorVob extends Vob {
-public static final String rcsid = "$Id: ColoredSectorVob.java,v 1.7 
2003/03/05 09:23:44 humppake Exp $";
+public static final String rcsid = "$Id: ColoredSectorVob.java,v 1.8 
2003/03/05 09:37:29 humppake Exp $";
     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); }
@@ -154,51 +154,11 @@
         if(dbg) pa("Addtolistgl coloredsectorvob "+coordsys1);
        if(glList == null) {
            if (!circleGLReady) prepareCircleGL(0.5f);
-           String bgcall = "";
-           if(nsolids > 0) {
-               int arc = sector / nsolids;
-               for(int i=0; i<nsolids; i++) {
-                   Color c = solids[i];
-                    bgcall += (
-                              "Color "+ColorUtil.colorGLString(solids[i])+" 
1\n"+
-                              "Begin POLYGON\n"+
-                              "Vertex 0.5 0.5\n");
-                   for (int j=i*arc;j<(i+1)*arc;j+=step) {
-                       bgcall += ("Vertex " + circleGL[(j+start)%360][0] +
-                                  " " + circleGL[(j+start)%360][1] + "\n");
-                   }
-                   int last = (i+1)*arc-1;
-                   if (sector == 360) last++;
-                   if (last == 360) last = 0;
-                   bgcall += ("Vertex " + circleGL[(last+start)%360][0] +
-                              " " + circleGL[(last+start)%360][1] + "\n" +
-                              "End\n");
-               }
-           } else {
-               bgcall = (
-                   "Color "+ColorUtil.colorGLString(bg)+" 1\n" +
-                   "Begin POLYGON\n");
-               if (sector < 360) bgcall += ("Vertex 0.5 0.5\n");
-               for (int i=0;i<sector;i+=step) {
-                   bgcall += ("Vertex " + circleGL[(i+start)%360][0] +
-                              " " + circleGL[(i+start)%360][1] + "\n");
-               }
-               bgcall += ("Vertex " + circleGL[(sector-1+start)%360][0] +
-                          " " + circleGL[(sector-1+start)%360][1] + "\n" +
-                          "End\n");
-           }
 
-           bgcall += (
-                     "Color 0 0 0 1\n" +
-                     "Begin LINE_LOOP\n");
-           if (sector < 360) bgcall += ("Vertex 0.5 0.5\n");
-           for (int i=0;i<sector;i+=step) {
-               bgcall += ("Vertex " + circleGL[(i+start)%360][0] +
-                              " " + circleGL[(i+start)%360][1] + "\n");
-           }
-           bgcall += ("Vertex " + circleGL[(sector-1+start)%360][0] +
-                      " " + circleGL[(sector-1+start)%360][1] + "\n" +
-                      "End\n");
+           String bgcall = "";
+           if(nsolids > 0) bgcall += glSolidsString();
+           else bgcall += glBgString();
+           if(drawBorder) bgcall += glBorderString();
                    
            glList = GLRen.createCallListBoxCoorded(
                "PushAttrib CURRENT_BIT ENABLE_BIT\n"+
@@ -209,6 +169,61 @@
        }
        vs.map.put(glList, coordsys1);
        return 0;
+    }
+
+    protected String glBorderString() {
+       String glString = "";
+       glString += (
+                    "Color 0 0 0 1\n" +
+                    "Begin LINE_LOOP\n");
+       if (sector < 360) glString += ("Vertex 0.5 0.5\n");
+       for (int i=0;i<sector;i+=step) {
+           glString += ("Vertex " + circleGL[(i+start)%360][0] +
+                      " " + circleGL[(i+start)%360][1] + "\n");
+       }
+       glString += ("Vertex " + circleGL[(sector-1+start)%360][0] +
+                  " " + circleGL[(sector-1+start)%360][1] + "\n" +
+                  "End\n");
+       return glString;
+    }
+
+    protected String glBgString() {
+       String glString = "";
+       glString = (
+                   "Color "+ColorUtil.colorGLString(bg)+" 1\n" +
+                   "Begin POLYGON\n");
+       if (sector < 360) glString += ("Vertex 0.5 0.5\n");
+       for (int i=0;i<sector;i+=step) {
+           glString += ("Vertex " + circleGL[(i+start)%360][0] +
+                      " " + circleGL[(i+start)%360][1] + "\n");
+       }
+       glString += ("Vertex " + circleGL[(sector-1+start)%360][0] +
+                    " " + circleGL[(sector-1+start)%360][1] + "\n" +
+                    "End\n");
+       return glString;
+    }
+
+    protected String glSolidsString() {
+       int arc = sector / nsolids;
+       String glString = "";
+       for(int i=0; i<nsolids; i++) {
+           Color c = solids[i];
+           glString += (
+                      "Color "+ColorUtil.colorGLString(solids[i])+" 1\n"+
+                      "Begin POLYGON\n"+
+                      "Vertex 0.5 0.5\n");
+           for (int j=i*arc;j<(i+1)*arc;j+=step) {
+               glString += ("Vertex " + circleGL[(j+start)%360][0] +
+                            " " + circleGL[(j+start)%360][1] + "\n");
+           }
+           int last = (i+1)*arc-1;
+           if (sector == 360) last++;
+           if (last == 360) last = 0;
+           glString += ("Vertex " + circleGL[(last+start)%360][0] +
+                        " " + circleGL[(last+start)%360][1] + "\n" +
+                        "End\n");
+       }
+       return glString;
     }
 
     /** Adds one more solid color to be drawn inside
Index: gzz/gzz/vob/vobs/ColoredSquareSectorVob.java
diff -u gzz/gzz/vob/vobs/ColoredSquareSectorVob.java:1.3 
gzz/gzz/vob/vobs/ColoredSquareSectorVob.java:1.4
--- gzz/gzz/vob/vobs/ColoredSquareSectorVob.java:1.3    Wed Mar  5 04:23:44 2003
+++ gzz/gzz/vob/vobs/ColoredSquareSectorVob.java        Wed Mar  5 04:37:29 2003
@@ -45,7 +45,7 @@
  */
 
 public class ColoredSquareSectorVob extends ColoredSectorVob {
-public static final String rcsid = "$Id: ColoredSquareSectorVob.java,v 1.3 
2003/03/05 09:23:44 humppake Exp $";
+public static final String rcsid = "$Id: ColoredSquareSectorVob.java,v 1.4 
2003/03/05 09:37:29 humppake Exp $";
 
     public ColoredSquareSectorVob() {
        super(90, 360, 10);
@@ -100,51 +100,11 @@
         if(dbg) pa("Addtolistgl coloredsectorvob "+coordsys1);
        if(glList == null) {
            if (!circleGLReady) prepareCircleGL((float)Math.sqrt(50)/10);
-           String bgcall = "";
-           if(nsolids > 0) {
-               int arc = sector / nsolids;
-               for(int i=0; i<nsolids; i++) {
-                   Color c = solids[i];
-                    bgcall += (
-                              "Color "+ColorUtil.colorGLString(solids[i])+" 
1\n"+
-                              "Begin POLYGON\n"+
-                              "Vertex 0.5 0.5\n");
-                   for (int j=i*arc;j<(i+1)*arc;j+=step) {
-                       bgcall += ("Vertex " + circleGL[(j+start)%360][0] +
-                                  " " + circleGL[(j+start)%360][1] + "\n");
-                   }
-                   int last = (i+1)*arc-1;
-                   if (sector == 360) last++;
-                   if (last == 360) last = 0;
-                   bgcall += ("Vertex " + circleGL[(last+start)%360][0] +
-                              " " + circleGL[(last+start)%360][1] + "\n" +
-                              "End\n");
-               }
-           } else {
-               bgcall = (
-                   "Color "+ColorUtil.colorGLString(bg)+" 1\n" +
-                   "Begin POLYGON\n");
-               if (sector < 360) bgcall += ("Vertex 0.5 0.5\n");
-               for (int i=0;i<sector;i+=step) {
-                   bgcall += ("Vertex " + circleGL[(i+start)%360][0] +
-                              " " + circleGL[(i+start)%360][1] + "\n");
-               }
-               bgcall += ("Vertex " + circleGL[(sector-1+start)%360][0] +
-                          " " + circleGL[(sector-1+start)%360][1] + "\n" +
-                          "End\n");
-           }
 
-           bgcall += (
-                     "Color 0 0 0 1\n" +
-                     "Begin LINE_LOOP\n");
-           if (sector < 360) bgcall += ("Vertex 0.5 0.5\n");
-           for (int i=0;i<sector;i+=step) {
-               bgcall += ("Vertex " + circleGL[(i+start)%360][0] +
-                              " " + circleGL[(i+start)%360][1] + "\n");
-           }
-           bgcall += ("Vertex " + circleGL[(sector-1+start)%360][0] +
-                      " " + circleGL[(sector-1+start)%360][1] + "\n" +
-                      "End\n");
+           String bgcall = "";
+           if(nsolids > 0) bgcall += glSolidsString();
+           else bgcall += glBgString();
+           if(drawBorder) bgcall += glBorderString();
                    
            glList = GLRen.createCallListBoxCoorded(
                "PushAttrib CURRENT_BIT ENABLE_BIT\n"+




reply via email to

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