/[libvob]/libvob/org/nongnu/libvob/vobs/OvalBgVob.java
ViewVC logotype

Diff of /libvob/org/nongnu/libvob/vobs/OvalBgVob.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by tjl, Tue Apr 8 20:25:02 2003 UTC revision 1.4 by humppake, Thu Apr 10 20:01:49 2003 UTC
# Line 41  import java.lang.Math; Line 41  import java.lang.Math;
41   * Draws a filled (possibly with several colors) background circle,   * Draws a filled (possibly with several colors) background circle,
42   * surrounded by a circle of the current foreground color.   * surrounded by a circle of the current foreground color.
43   */   */
44  public class OvalBgVob extends AbstractVob {  public class OvalBgVob extends AbstractColorableVob {
45  public static final String rcsid = "$Id$";  public static final String rcsid = "$Id$";
46      public static boolean dbg = false;      public static boolean dbg = false;
47      private static final void p(String s) { if(dbg) System.out.println(s); }      private static final void p(String s) { if(dbg) System.out.println(s); }
48    
     int NColors = 0;  
     Color[] colors;  
   
49      /** Background color */      /** Background color */
50      protected final Color bgColor;      protected final Color bgColor;
51    
# Line 133  public static final String rcsid = "$Id$ Line 130  public static final String rcsid = "$Id$
130          if(mh >= 14) g.fillOval(mx-2, my-2, mw+4, mh+4);          if(mh >= 14) g.fillOval(mx-2, my-2, mw+4, mh+4);
131          else g.fillOval(mx-1, my-1, mw+2, mh+2);          else g.fillOval(mx-1, my-1, mw+2, mh+2);
132    
133          if(colors == null || NColors == 0) {          if(colors == null || colors.length == 0) {
134              g.setColor(bgColor);              g.setColor(bgColor);
135              g.fillOval(mx, my, mw, mh);              g.fillOval(mx, my, mw, mh);
136          } else {          } else {
# Line 150  public static final String rcsid = "$Id$ Line 147  public static final String rcsid = "$Id$
147               */               */
148              g.setColor(colors[0]);              g.setColor(colors[0]);
149              g.fillArc(mx, my, mw, mh, -90, 180);              g.fillArc(mx, my, mw, mh, -90, 180);
150              g.setColor(colors[NColors-1]);              g.setColor(colors[colors.length-1]);
151              g.fillArc(mx, my, mw, mh, 90, 180);              g.fillArc(mx, my, mw, mh, 90, 180);
152              int lastColor = NColors-1;              int lastColor = colors.length-1;
153              int colorWidth = mw / NColors;              int colorWidth = mw / colors.length;
154              float a = mw/2;              float a = mw/2;
155              float b = mh/2;              float b = mh/2;
156              for(int i=1; i<lastColor; i++) {              for(int i=1; i<lastColor; i++) {
# Line 199  public static final String rcsid = "$Id$ Line 196  public static final String rcsid = "$Id$
196          if(glList == null) {          if(glList == null) {
197              if (!circleGLReady) prepareCircleGL(0.5f);              if (!circleGLReady) prepareCircleGL(0.5f);
198              String bgcall = "";              String bgcall = "";
199              if(colors != null && NColors > 0) {              if(colors != null && colors.length > 0) {
200                  bgcall += glColorsString();                  bgcall += glColorsString();
201              } else bgcall += glRectBgString();              } else bgcall += glRectBgString();
202                            
# Line 293  public static final String rcsid = "$Id$ Line 290  public static final String rcsid = "$Id$
290      }      }
291    
292      protected String glColorsString() {      protected String glColorsString() {
293          double w = 1.0 / NColors;          double w = 1.0 / colors.length;
294          String glString = "";          String glString = "";
295          for(int i=0; i<NColors; i++) {          for(int i=0; i<colors.length; i++) {
296              double x1 = i*w;              double x1 = i*w;
297              double x2 = x1 + w;              double x2 = x1 + w;
298              Color c = colors[i];              Color c = colors[i];
# Line 314  public static final String rcsid = "$Id$ Line 311  public static final String rcsid = "$Id$
311          }          }
312          return glString;          return glString;
313      }      }
   
     /** Adds one more solid color to be drawn inside  
      * the cell.  
      */  
     public boolean addColor(Color c) {  
         if(colors == null || NColors >= colors.length) {  
             Color[] n= new Color[NColors + 10];  
             if(colors != null) System.arraycopy(colors, 0, n, 0, NColors);  
             colors = n;  
         }  
         colors[NColors++] = c;  
         return false;  
     }  
     /** The currently put solid colors.  
      * null = none. There may be null references near the end  
      * of the array. Mostly useful for checking for nullness.  
      */  
     public Color[] getSolidColors() { return colors; }  
314  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26