Class JavaApplication2D
- java.lang.Object
-
- WildMagic.LibApplications.OpenGLApplication.Application
-
- WildMagic.LibApplications.OpenGLApplication.JavaApplication
-
- WildMagic.LibApplications.OpenGLApplication.JavaApplication2D
-
- All Implemented Interfaces:
java.awt.event.KeyListener
,java.io.Serializable
,java.util.EventListener
public abstract class JavaApplication2D extends JavaApplication implements java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
m_akFlipScreen
For right-handed drawing.protected byte[]
m_akScreen
Screen polygonprotected boolean
m_bClampToWindow
Screen wraps or is clampedprotected boolean
m_bFlipScreen
Set to true to flip the screen:protected int
m_iScrHeight
Screen width, heightprotected int
m_iScrWidth
Screen width, heightprivate static long
serialVersionUID
-
Fields inherited from class WildMagic.LibApplications.OpenGLApplication.JavaApplication
m_acWindowTitle, m_eBuffering, m_eDepth, m_eFormat, m_eMultisampling, m_eStencil, m_iHeight, m_iWidth, m_iXPosition, m_iYPosition, m_kBackgroundColor, m_pkRenderer
-
-
Constructor Summary
Constructors Constructor Description JavaApplication2D(java.lang.String acWindowTitle, int iXPosition, int iYPosition, int iWidth, int iHeight, ColorRGBA rkBackgroundColor)
Constructs a 2D application.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
ClampToWindow()
Returns if the Screen wraps or is clampedvoid
ClearScreen()
Clears the screen polygon.void
dispose()
Delete memory.void
DoFlip(boolean bDoFlip)
For right-handed drawing.void
DrawCircle(int iXCenter, int iYCenter, int iRadius, ColorRGB kColor, boolean bSolid)
Draw a circle centered at iXCenter, iYCentervoid
DrawLine(int iX0, int iY0, int iX1, int iY1, ColorRGB kColor)
Draw a line from (iX0,iY0) to (iX1,iY1).void
DrawRectangle(int iXMin, int iYMin, int iXMax, int iYMax, ColorRGB kColor, boolean bSolid)
Draw a rectangle with lower-left corner (iXMin,iYMin) and upper-right corner (iXMax,iYMax).void
Fill(int iX, int iY, ColorRGB kFColor, ColorRGB kBColor)
Flood fill operation.ColorRGB
GetPixel(int iX, int iY)
Returns the pixel color at the specified location.protected int
Index(int iX, int iY)
left-handed screen coordinatesprotected int
IndexFlip(int iX, int iY)
right-handed screen coordinatesvoid
OnDisplay()
Display event callback.boolean
OnInitialize()
Initialize event callback.void
OnResize(int iWidth, int iHeight)
Resize event callback.void
OnTerminate()
Terminate event callback.void
ScreenOverlay()
Allows you to do additional drawing after the screen polygon is drawn.void
SetPixel(int iX, int iY, ColorRGB kColor)
Sets the pixel color.void
SetThickPixel(int iX, int iY, int iThick, ColorRGB kColor)
Sets a thick pixel color.-
Methods inherited from class WildMagic.LibApplications.OpenGLApplication.JavaApplication
GetAspectRatio, GetHeight, GetRenderer, GetWidth, GetWindowTitle, GetXPosition, GetYPosition, keyPressed, keyReleased, keyTyped, OnIdle, OnMove, OnPrecreate, SetRenderer
-
Methods inherited from class WildMagic.LibApplications.OpenGLApplication.Application
reloadShaders, TestStreaming
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
m_iScrWidth
protected int m_iScrWidth
Screen width, height
-
m_iScrHeight
protected int m_iScrHeight
Screen width, height
-
m_akScreen
protected byte[] m_akScreen
Screen polygon
-
m_bClampToWindow
protected boolean m_bClampToWindow
Screen wraps or is clamped
-
m_bFlipScreen
protected boolean m_bFlipScreen
Set to true to flip the screen:
-
m_akFlipScreen
protected byte[] m_akFlipScreen
For right-handed drawing. The array m_akScreen is copied to m_akFlipScreen so that the rows are reversed.
-
-
Constructor Detail
-
JavaApplication2D
public JavaApplication2D(java.lang.String acWindowTitle, int iXPosition, int iYPosition, int iWidth, int iHeight, ColorRGBA rkBackgroundColor)
Constructs a 2D application.- Parameters:
acWindowTitle
- the window titleiXPosition
- window screen x-positioniYPosition
- window screen y-positioniWidth
- window widthiHeight
- window heightrkBackgroundColor
- background color
-
-
Method Detail
-
ClampToWindow
public boolean ClampToWindow()
Returns if the Screen wraps or is clamped- Returns:
- true if the Screen is clamped, false if it wraps.
-
ClearScreen
public void ClearScreen()
Clears the screen polygon.
-
dispose
public void dispose()
Delete memory.- Overrides:
dispose
in classJavaApplication
-
DoFlip
public void DoFlip(boolean bDoFlip)
For right-handed drawing. You need only call DoFlip(true) once for an application. The default is 'false'.- Parameters:
bDoFlip
- sets the flip screen flag.
-
DrawCircle
public void DrawCircle(int iXCenter, int iYCenter, int iRadius, ColorRGB kColor, boolean bSolid)
Draw a circle centered at iXCenter, iYCenter- Parameters:
iXCenter
- center x-positioniYCenter
- center y-positioniRadius
- circle radiuskColor
- color.bSolid
- when true the circle is solid, when false it is an outline.
-
DrawLine
public void DrawLine(int iX0, int iY0, int iX1, int iY1, ColorRGB kColor)
Draw a line from (iX0,iY0) to (iX1,iY1).- Parameters:
iX0
- start x-location.iY0
- start y-location.iX1
- end x-location.iY1
- end y-location.kColor
- line color.
-
DrawRectangle
public void DrawRectangle(int iXMin, int iYMin, int iXMax, int iYMax, ColorRGB kColor, boolean bSolid)
Draw a rectangle with lower-left corner (iXMin,iYMin) and upper-right corner (iXMax,iYMax).- Parameters:
iXMin
- lower-left corner x-positioniYMin
- lower-left corner y-positioniXMax
- upper-right corner x-positioniYMax
- upper-right corner y-positionkColor
- color.bSolid
- when true the rectangle is solid, when false it is an outline.
-
Fill
public void Fill(int iX, int iY, ColorRGB kFColor, ColorRGB kBColor)
Flood fill operation.- Parameters:
iX
- start x-coordinate in pixelsiY
- start y-coordinate in pixelskFColor
- the fill color.kBColor
- the back-ground color.
-
GetPixel
public ColorRGB GetPixel(int iX, int iY)
Returns the pixel color at the specified location.- Parameters:
iX
- pixel x-location.iY
- pixel y-location.- Returns:
- the new pixel color.
-
OnDisplay
public void OnDisplay()
Display event callback.- Overrides:
OnDisplay
in classJavaApplication
-
OnInitialize
public boolean OnInitialize()
Initialize event callback.- Overrides:
OnInitialize
in classJavaApplication
- Returns:
- true if successful initialization, false otherwise.
-
OnResize
public void OnResize(int iWidth, int iHeight)
Resize event callback.- Overrides:
OnResize
in classJavaApplication
- Parameters:
iWidth
- new window widthiHeight
- new window height
-
OnTerminate
public void OnTerminate()
Terminate event callback.- Overrides:
OnTerminate
in classJavaApplication
-
ScreenOverlay
public void ScreenOverlay()
Allows you to do additional drawing after the screen polygon is drawn.
-
SetPixel
public void SetPixel(int iX, int iY, ColorRGB kColor)
Sets the pixel color.- Parameters:
iX
- pixel x-location.iY
- pixel y-location.kColor
- new pixel color.
-
SetThickPixel
public void SetThickPixel(int iX, int iY, int iThick, ColorRGB kColor)
Sets a thick pixel color.- Parameters:
iX
- pixel x-location.iY
- pixel y-location.iThick
- pixel thickness.kColor
- new pixel color.
-
Index
protected int Index(int iX, int iY)
left-handed screen coordinates- Parameters:
iX
- screen coordinateiY
- screen coordinate- Returns:
- left-handed screen coordinates.
-
IndexFlip
protected int IndexFlip(int iX, int iY)
right-handed screen coordinates- Parameters:
iX
- screen coordinateiY
- screen coordinate- Returns:
- right-handed screen coordinates.
-
-