1 |
/* |
/* |
2 |
ColoredSquareSectorVob.java |
ColoredSquareSectorVob.java |
3 |
* |
* |
4 |
* Copyright (c) 2003, Asko Soukka |
* Copyright (c) 2003 by Asko Soukka |
5 |
* |
* |
6 |
* This file is part of Gzz. |
* This file is part of Gzz. |
7 |
* |
* |
27 |
*/ |
*/ |
28 |
|
|
29 |
package gzz.vob.vobs; |
package gzz.vob.vobs; |
30 |
|
|
31 |
import gzz.vob.*; |
import gzz.vob.*; |
|
import gzz.*; |
|
|
import gzz.util.*; |
|
|
import gzz.errors.*; |
|
|
import gzz.vob.*; |
|
|
import gzz.client.*; |
|
32 |
import gzz.gfx.gl.*; |
import gzz.gfx.gl.*; |
33 |
import java.awt.*; |
|
34 |
import java.awt.event.*; |
import gzz.util.ColorUtil; |
35 |
import java.util.*; |
import java.awt.Shape; |
36 |
import java.lang.Math; |
import java.awt.Color; |
37 |
|
import java.awt.Graphics; |
38 |
|
import java.awt.Rectangle; |
39 |
import gzz.client.GraphicsAPI; |
import gzz.client.GraphicsAPI; |
40 |
|
|
41 |
/** A vob with a square background and frame, but colors |
/** A vob with a square background and frame, but colors |
42 |
* drawn as sectors. |
* drawn as sectors. |
43 |
*/ |
*/ |
|
|
|
44 |
public class ColoredSquareSectorVob extends ColoredSectorVob { |
public class ColoredSquareSectorVob extends ColoredSectorVob { |
45 |
public static final String rcsid = "$Id$"; |
public static final String rcsid = "$Id$"; |
46 |
|
public static boolean dbg = false; |
47 |
public ColoredSquareSectorVob() { |
private static final void p(String s) { if(dbg) System.out.println(s); } |
|
super(90, 360, 10); |
|
|
start = 90; |
|
|
sector = 360; |
|
|
step = 10; |
|
|
} |
|
48 |
|
|
49 |
public void render(Graphics g, |
public void render(Graphics g, |
50 |
boolean fast, |
boolean fast, |
57 |
Color oldfg = g.getColor(); |
Color oldfg = g.getColor(); |
58 |
g.setColor(info1.getBgColor()); |
g.setColor(info1.getBgColor()); |
59 |
|
|
60 |
|
// Draw a rectangle in the background color, wiping out |
61 |
|
// the already drawn stuff a little wider than we will draw. |
62 |
|
g.setColor(info1.getBgColor()); |
63 |
if (mh > 14) g.fillRect(mx-2, my-2, mw+4, mh+4); |
if (mh > 14) g.fillRect(mx-2, my-2, mw+4, mh+4); |
64 |
else g.fillRect(mx-1, my-1, mw+2, mh+2); |
else g.fillRect(mx-1, my-1, mw+2, mh+2); |
65 |
|
|
66 |
if(nsolids == 0) { |
if(colors == null || NColors == 0) { |
67 |
g.setColor(bg); |
g.setColor(bgColor); |
68 |
g.fillRect(mx, my, mw, mh); |
g.fillRect(mx, my, mw, mh); |
69 |
} else if (my+mh > 0) { |
} else if (my+mh > 0) { |
|
System.out.println("FOO!:" + my + " " +mh); |
|
70 |
Shape oldClip = g.getClip(); |
Shape oldClip = g.getClip(); |
71 |
g.clipRect(mx+1, my+1, mw-2, mh-2); |
g.clipRect(mx+1, my+1, mw-2, mh-2); |
72 |
int arc = sector / nsolids; |
int arc = sector / NColors; |
73 |
int r = (int)Math.sqrt((mw/2)*(mw/2) + (mh/2)*(mh/2)); |
int r = (int)Math.sqrt((mw/2)*(mw/2) + (mh/2)*(mh/2)); |
74 |
for(int i=0; i<nsolids; i++) { |
for(int i=0; i<NColors; i++) { |
75 |
g.setColor(solids[i]); |
g.setColor((Color)colors[i]); |
76 |
g.fillArc(mx-(r-mw/2), my-(r-mh/2), |
g.fillArc(mx-(r-mw/2), my-(r-mh/2), |
77 |
2*r, 2*r, |
2*r, 2*r, |
78 |
start + arc * i, arc); |
start + arc * i, arc); |
91 |
} |
} |
92 |
|
|
93 |
public int putGL(final VobScene vs, final int coordsys1) { |
public int putGL(final VobScene vs, final int coordsys1) { |
94 |
if(dbg) pa("Addtolistgl coloredsectorvob "+coordsys1); |
p("Addtolistgl coloredsectorvob "+coordsys1); |
95 |
if(glList == null) { |
if(glList == null) { |
96 |
if (!circleGLReady) prepareCircleGL((float)Math.sqrt(50)/10); |
if (!circleGLReady) prepareCircleGL((float)Math.sqrt(50)/10); |
97 |
|
|
98 |
String bgcall = ""; |
String bgcall = ""; |
99 |
if(nsolids > 0) { |
if(colors != null && NColors > 0) { |
100 |
bgcall += glSolidsString(); |
bgcall += glColorsString(); |
101 |
} else bgcall += glBgString(); |
} else bgcall += glRectBgString(); |
102 |
if(drawBorder) bgcall += glBorderString(); |
if(drawBorder) bgcall += glBorderString(); |
103 |
|
|
104 |
glList = GLRen.createCallListBoxCoorded( |
glList = GLRen.createCallListBoxCoorded( |
125 |
return 0; |
return 0; |
126 |
} |
} |
127 |
|
|
|
protected String glBgString() { |
|
|
String glString = ""; |
|
|
glString += ( |
|
|
"Color "+ColorUtil.colorGLString(bg)+" 1\n" + |
|
|
"Begin QUAD_STRIP\n"+ |
|
|
"Vertex 1 1\nVertex 1 0\n"+ |
|
|
"Vertex 0 1\nVertex 0 0\n"+ |
|
|
"End\n"); |
|
|
return glString; |
|
|
} |
|
|
|
|
128 |
protected String glBorderString() { |
protected String glBorderString() { |
129 |
String glString = ""; |
String glString = ""; |
130 |
glString += ( |
glString += ( |
140 |
return glString; |
return glString; |
141 |
} |
} |
142 |
} |
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|