com.partnersoft.gui
Class EZ2DGL

java.lang.Object
  extended by com.partnersoft.gui.EZ2DGL
All Implemented Interfaces:
RoverConstants

public abstract class EZ2DGL
extends java.lang.Object
implements RoverConstants

A wrapper for GLCanvas that provides a simpler, 2D-only API. Takes care of fonts, textures, events, etc.

Author:
Paul Reavis Copyright 2004 Partner Software, Inc.

Field Summary
 float bgBluef
           
 float bgGreenf
           
 float bgRedf
           
 net.java.games.jogl.GLCanvas canvas
           
 double centerX
           
 double centerY
           
 GLFont currentFont
           
 int currentFontID
           
 GLTexture currentTexture
           
 int currentTextureID
           
 com.partnersoft.gui.EZ2DGL.DisplayListCache displayListCache
           
 OneToOneMapping displayListMapping
           
 float fgAlphaf
           
 float fgBluef
           
 float fgGreenf
           
 float fgRedf
           
 java.util.HashMap fontMap
           
 java.util.ArrayList fonts
           
 net.java.games.jogl.GL gl
           
 net.java.games.jogl.GLU glu
           
 boolean highQuality
           
 com.partnersoft.gui.EZ2DGL.InnerEar innerEar
           
 int maxTextureID
           
 double rotation
           
 double scale
           
protected  java.nio.ByteBuffer selectionBufferBytes
           
 java.util.HashMap textureKeys
           
 java.util.HashMap textureMap
           
 java.util.HashMap textures
           
 
Fields inherited from interface com.partnersoft.io.formats.rover.RoverConstants
ALIGN_BOTTOM_CENTER, ALIGN_BOTTOM_FIT, ALIGN_BOTTOM_LEFT, ALIGN_BOTTOM_RIGHT, ALIGN_CENTER, ALIGN_CENTER_LEFT, ALIGN_CENTER_RIGHT, ALIGN_CODE_CENTER, ALIGN_CODE_FIT, ALIGN_CODE_HIGH, ALIGN_CODE_LOW, ALIGN_FIT, ALIGN_FIT_LEFT, ALIGN_FIT_RIGHT, ALIGN_TOP_CENTER, ALIGN_TOP_FIT, ALIGN_TOP_LEFT, ALIGN_TOP_RIGHT, COMMENT, DATA_FIELDS_MAX, EOF, FLOAT_COORDS, GEOMETRY_TYPE_NAMES, HAS_DATA, HAS_OFFSET, HAS_ROTATION, LIST, MASK_TYPECODE, NAMING, POINT, POLYGON, POLYLINE, POP, PUSH, RENDER_FINDITEM, RENDER_INDICATION, RENDER_NORMAL, RENDER_SELECTION, ROTATION_MULT, TEXEL_COORD_MAX, TEXEL_COORD_SIZE, TEXT, TILE_COORD_MAX, TILE_SIZE_PIXELS, VALUE
 
Constructor Summary
EZ2DGL(boolean softwareRendering, boolean animated)
           
EZ2DGL(boolean softwareRendering, boolean animated, boolean highQuality)
           
 
Method Summary
 int addFont(java.awt.Font font)
           
 int addFont(GLFont font, java.lang.Object key)
          Registers a font as a set of GL textures, one per character.
 int addTexture(GLTexture texture, java.lang.Object key)
           
 int addTexture(java.awt.Image image, boolean modulate)
           
 int addTexture(java.awt.Image image, java.lang.Object key)
          Registers an image as a GL texture.
 void clear()
          Clears the buffer and sets it to the background color.
 void close()
           
static void close(net.java.games.jogl.GLCanvas canvas)
           
 void display()
          Call this to trigger a repaint.
protected abstract  void displayImp()
          This must be overridden to perform the actual drawing.
 int displayListFor(java.lang.Object key)
           
 void displayThumbTwiddle()
           
 void drawBullseye()
           
 void drawCircle(int dataID, double centerX, double centerY, double radius)
           
 void drawDisplayList(int displayListID)
           
 void drawPolygon(int dataID, DoubleBuffer coords)
          Draws a filled polygon in the foreground color.
 void drawPolyline(int dataID, DoubleBuffer coords)
          Draws a filled polyline in the foreground color.
protected  void drawSelectionBox()
           
 void drawString(int fontID, double x, double y, float rotation, int alignment, double fontScale, java.lang.String text)
           
 void drawTexture(int dataID, int textureID, double x, double y, double rotation, double scale)
          Just draws the given texture as a rotated, scaled icon.
 void drawTriangle(double x1, double y1, double x2, double y2, double x3, double y3, double z)
           
 void endDisplayList()
           
 int[][] endSelection()
           
protected  void finalize()
           
 int fontIDFor(java.lang.Object key)
           
 double getFrameCount()
          Get the global average frame count.
 double getRecentFrameCount()
          Get the recent (last 100 frames) average frame count.
 void gotoPixelScale()
          Throws you in pixel scaled mode, offset so that the origin given is (0, 0) in pixel space.
 void init()
           
protected abstract  void initializeImp()
          This must be overridden to perform any initial setup.
 boolean isAnimated()
           
 void logInfo()
           
static void main(java.lang.String[] args)
          just for testing.
 void popMatrix()
           
 void popName()
           
 void pushMatrix()
           
 void pushName(int ID)
           
 void removeAllTextures()
           
 void removeDisplayList(int displayListID)
           
 void removeTexture(int textureID)
           
 int[][] select(int x, int y)
          Selects items near the given pixel coordinates.
 void setActive(boolean isActive)
           
 void setBackgroundColor(int rgb)
           
 void setCurrentTexture(int textureID)
          Sets up for drawing with textures.
 void setForegroundColor(int rgb)
           
 void setLineStipple(int stipple)
           
 void setLineWidth(float newWidth)
           
 void setMarchingAnts(boolean marching)
           
 void setModelView(double centerX, double centerY, double rotation, double scale)
          This sets the viewing parameters, specified as a centerpoint, rotation, and scale.
 void sizeChanged()
          This is run whenever the canvas is resized.
 int startDisplayList(java.lang.Object key)
           
 void startSelection(int x, int y)
           
 int textureIDFor(java.lang.Object key)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

canvas

public net.java.games.jogl.GLCanvas canvas

gl

public net.java.games.jogl.GL gl

glu

public net.java.games.jogl.GLU glu

centerX

public double centerX

centerY

public double centerY

rotation

public double rotation

scale

public double scale

bgRedf

public float bgRedf

bgGreenf

public float bgGreenf

bgBluef

public float bgBluef

fgRedf

public float fgRedf

fgGreenf

public float fgGreenf

fgBluef

public float fgBluef

fgAlphaf

public float fgAlphaf

maxTextureID

public int maxTextureID

textures

public java.util.HashMap textures

textureKeys

public java.util.HashMap textureKeys

textureMap

public java.util.HashMap textureMap

currentTextureID

public int currentTextureID

currentTexture

public GLTexture currentTexture

fonts

public java.util.ArrayList fonts

fontMap

public java.util.HashMap fontMap

currentFontID

public int currentFontID

currentFont

public GLFont currentFont

displayListMapping

public OneToOneMapping displayListMapping

displayListCache

public com.partnersoft.gui.EZ2DGL.DisplayListCache displayListCache

innerEar

public com.partnersoft.gui.EZ2DGL.InnerEar innerEar

highQuality

public boolean highQuality

selectionBufferBytes

protected transient java.nio.ByteBuffer selectionBufferBytes
Constructor Detail

EZ2DGL

public EZ2DGL(boolean softwareRendering,
              boolean animated)

EZ2DGL

public EZ2DGL(boolean softwareRendering,
              boolean animated,
              boolean highQuality)
Method Detail

close

public static void close(net.java.games.jogl.GLCanvas canvas)

displayListFor

public int displayListFor(java.lang.Object key)

startDisplayList

public int startDisplayList(java.lang.Object key)

endDisplayList

public void endDisplayList()

drawDisplayList

public void drawDisplayList(int displayListID)

removeDisplayList

public void removeDisplayList(int displayListID)

displayThumbTwiddle

public void displayThumbTwiddle()

clear

public void clear()
Clears the buffer and sets it to the background color.


setActive

public void setActive(boolean isActive)

logInfo

public void logInfo()

setBackgroundColor

public void setBackgroundColor(int rgb)

setForegroundColor

public void setForegroundColor(int rgb)

setLineWidth

public void setLineWidth(float newWidth)

setLineStipple

public void setLineStipple(int stipple)

addTexture

public int addTexture(java.awt.Image image,
                      java.lang.Object key)
Registers an image as a GL texture. Returns the textureID, which should be used when referring to the texture afterwards.


addTexture

public int addTexture(java.awt.Image image,
                      boolean modulate)

textureIDFor

public int textureIDFor(java.lang.Object key)

fontIDFor

public int fontIDFor(java.lang.Object key)

addTexture

public int addTexture(GLTexture texture,
                      java.lang.Object key)

removeTexture

public void removeTexture(int textureID)

removeAllTextures

public void removeAllTextures()

addFont

public int addFont(java.awt.Font font)

addFont

public int addFont(GLFont font,
                   java.lang.Object key)
Registers a font as a set of GL textures, one per character. Returns an ID you should use to set the current font for drawString().


drawTexture

public void drawTexture(int dataID,
                        int textureID,
                        double x,
                        double y,
                        double rotation,
                        double scale)
Just draws the given texture as a rotated, scaled icon.


drawPolygon

public void drawPolygon(int dataID,
                        DoubleBuffer coords)
Draws a filled polygon in the foreground color.


drawCircle

public void drawCircle(int dataID,
                       double centerX,
                       double centerY,
                       double radius)

drawPolyline

public void drawPolyline(int dataID,
                         DoubleBuffer coords)
Draws a filled polyline in the foreground color.


drawString

public void drawString(int fontID,
                       double x,
                       double y,
                       float rotation,
                       int alignment,
                       double fontScale,
                       java.lang.String text)

displayImp

protected abstract void displayImp()
This must be overridden to perform the actual drawing.


initializeImp

protected abstract void initializeImp()
This must be overridden to perform any initial setup.


init

public void init()

setModelView

public void setModelView(double centerX,
                         double centerY,
                         double rotation,
                         double scale)
This sets the viewing parameters, specified as a centerpoint, rotation, and scale.


sizeChanged

public void sizeChanged()
This is run whenever the canvas is resized.


getFrameCount

public double getFrameCount()
Get the global average frame count.


getRecentFrameCount

public double getRecentFrameCount()
Get the recent (last 100 frames) average frame count.


display

public void display()
Call this to trigger a repaint.


drawTriangle

public void drawTriangle(double x1,
                         double y1,
                         double x2,
                         double y2,
                         double x3,
                         double y3,
                         double z)

select

public int[][] select(int x,
                      int y)
Selects items near the given pixel coordinates. Returns an array of hits, each is the number as passed in as IDs to the draw commands.


startSelection

public void startSelection(int x,
                           int y)

endSelection

public int[][] endSelection()

setCurrentTexture

public void setCurrentTexture(int textureID)
Sets up for drawing with textures. TextureID 0 disabled.


gotoPixelScale

public void gotoPixelScale()
Throws you in pixel scaled mode, offset so that the origin given is (0, 0) in pixel space. This allows drawing pixel-sized (rather than world-sized) icons and text.


drawSelectionBox

protected void drawSelectionBox()

drawBullseye

public void drawBullseye()

setMarchingAnts

public void setMarchingAnts(boolean marching)

isAnimated

public boolean isAnimated()

pushName

public void pushName(int ID)

popName

public void popName()

pushMatrix

public void pushMatrix()

popMatrix

public void popMatrix()

close

public void close()

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

main

public static void main(java.lang.String[] args)
just for testing.