|
jAER project on SourceForge | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jaer.graphics.ChipCanvas
public class ChipCanvas
Superclass for classes that paint rendered AE data to graphics devices.
This is Canvas (AWT component) for rendering retina events. Note this is a heavyweight componnent and doesn't understand Swing layering. Thus care must be taken to ensure Swing components show over it. This component also uses a page-flipping BufferStrategy to eliminate tearing by flipping pages on monitor refresh.
The graphics context is obtained here in the component and its origin is the UL corner of the component when using Java2D rendering, or LL corner if using OpenGL rendering. The context is translated to center the rendering in the Canvas. This canvas can either use Java2D or OpenGL to render, and it can either actively or passively render.
If 3-d event rendering is enabled, the raw events are painted out in space-time, with time axis defined by duration from first to last event in the packet.
If 3-d histogramming is enabled, then the image frame from the ChipRenderer is rendered as a 3-d surface that the user can rotate as desired.
Nested Class Summary | |
---|---|
class |
ChipCanvas.Zoom
Encapsulates zooming the view |
Field Summary | |
---|---|
protected AEViewer |
aeViewer
|
protected float |
anglex
|
protected float |
angley
|
protected int |
BORDER3D
border in screen pixels when in 3d space-time rendering mode |
protected int |
colorScale
|
protected javax.media.opengl.GLCanvas |
drawable
|
protected float[][][] |
fr
fr is the rendered event data that we draw. |
protected RenderingFrame |
frameData
|
protected javax.media.opengl.glu.GLU |
glu
|
protected com.sun.opengl.util.GLUT |
glut
|
protected java.awt.Insets |
insets
Insets of the drawn chip canvas in the window |
protected float |
j2dScale
|
protected java.util.logging.Logger |
log
|
static int |
MIN_DIMENSION
defines the minimum canvas size in pixels; used when chip size has not been set to non zero value |
protected boolean |
openGLEnabled
|
protected int |
pheight
|
protected int[] |
pixels
|
protected java.util.prefs.Preferences |
prefs
|
protected int |
pwidth
width and height of pixel array in canvas in screen pixels. |
protected static float |
SCALE_DEFAULT
Default scaling from chip pixel to screen pixels |
protected static java.awt.Color |
selectedPixelColor
|
protected javax.media.opengl.glu.GLUquadric |
selectedQuad
|
java.awt.image.BufferStrategy |
strategy
|
protected int |
xt
the translation of the actual chip drawing area in the canvas, in screen pixels |
protected int |
yt
the translation of the actual chip drawing area in the canvas, in screen pixels |
protected boolean |
zoomMode
|
Constructor Summary | |
---|---|
ChipCanvas(Chip2D chip)
Creates a new instance of ChipCanvas |
Method Summary | |
---|---|
void |
addDisplayMethod(DisplayMethod m)
adds a display method to this canvas |
void |
addGLEventListener(javax.media.opengl.GLEventListener listener)
|
protected void |
annotate(javax.media.opengl.GLAutoDrawable drawable)
First, calls annotate(GLAutoDrawable) for all FrameAnnotators that have been added explicitly to the current DisplayMethod. |
protected void |
annotate(java.awt.Graphics2D g2)
Iterates through the FilterChain associated with the AEChip to call all the enabled filter annotations |
void |
checkGLError(javax.media.opengl.GL g,
javax.media.opengl.glu.GLU glu,
java.lang.String msg)
Utility method to check for GL errors. |
void |
cycleDisplayMethod()
cycle to the next display method |
void |
display(javax.media.opengl.GLAutoDrawable drawable)
opengl calls this when it wants to redraw, and we call it when we actively render. |
void |
displayChanged(javax.media.opengl.GLAutoDrawable drawable,
boolean modeChanged,
boolean deviceChanged)
|
float |
getAnglex()
|
float |
getAngley()
|
int |
getBorderSpacePixels()
Returns minimum space around pixel array in screen pixels |
java.awt.Canvas |
getCanvas()
The actual drawing surface is a Canvas and this method returns a reference to it. |
Chip2D |
getChip()
gets the chip we are rendering for. |
DisplayMethod |
getCurrentDisplayMethod()
returns the current display method |
javax.swing.JMenu |
getDisplayMethodMenu()
|
java.util.ArrayList<DisplayMethod> |
getDisplayMethods()
|
float[][][] |
getFr()
Returns the rendered histogram data in case this is what is being rendered |
com.sun.opengl.util.GLUT |
getGlut()
|
java.awt.image.BufferedImage |
getImageOpenGL()
|
java.awt.Point |
getMousePixel()
Finds the current AEChip pixel mouse position. |
float |
getOrigin3dx()
|
float |
getOrigin3dy()
|
protected java.awt.Color |
getPixelColor(float red,
float green,
float blue)
A utility method that returns an AWT Color from float rgb values |
java.awt.Point |
getPixelFromMouseEvent(java.awt.event.MouseEvent evt)
Takes a MouseEvent and returns the AEChip pixel. |
java.awt.Point |
getPixelFromPoint(java.awt.Point mp)
Finds the chip pixel from a ChipCanvas point. |
protected int |
getPixelRGB(float red,
float green,
float blue)
|
Chip2DRenderer |
getRenderer()
|
float |
getScale()
Pixel drawing j2dScale. |
ChipCanvas.Zoom |
getZoom()
|
void |
grabNextImage()
call this method so that next open gl rendering by display(GLAutoDrawable) writes imageOpenGL |
void |
init(javax.media.opengl.GLAutoDrawable drawable)
|
protected void |
initComponents()
|
boolean |
is3DEnabled()
|
boolean |
isFillsHorizontally()
Chip fills drawable horizontally. |
boolean |
isFillsVertically()
Chip fills drawable vertically. |
boolean |
isOpenGLEnabled()
|
boolean |
isZoomMode()
|
protected void |
paint()
use to paint with Java2D using BufferStrategy |
void |
paint(java.awt.Graphics g)
used for active and passive rendering by Java2D. |
void |
paintFrame()
Used for active rendering. |
void |
removeGLEventListener(javax.media.opengl.GLEventListener listener)
|
void |
repaint()
calls repaint on the drawable |
void |
repaint(long tm)
calls repaint on the drawable |
void |
reshape(javax.media.opengl.GLAutoDrawable drawable,
int x,
int y,
int width,
int height)
Called on reshape of canvas. |
protected java.lang.String |
scalePrefsKey()
|
protected void |
set3dOrigin(int x,
int y)
|
void |
setAnglex(float anglex)
|
void |
setAngley(float angley)
|
void |
setBorderSpacePixels(int borderSpacePixels)
Sets the border around the drawn pixel canvas. |
void |
setChip(Chip2D chip)
|
protected void |
setDefaultProjection(javax.media.opengl.GL g,
javax.media.opengl.GLAutoDrawable d)
Sets the projection matrix so that we get an orthographic projection that is the size of the canvas with z volume -ZCLIP to ZCLIP padded with extra space around the sides. |
void |
setDisplayMethod(DisplayMethod m)
sets the display method |
protected void |
setDisplayMethod(int index)
sets the current display method to a particular item |
void |
setDisplayMethod(java.lang.String description)
sets the display method using the menu name |
void |
setDisplayMethods(java.util.ArrayList<DisplayMethod> displayMethods)
|
void |
setOpenGLEnabled(boolean openGLEnabled)
|
void |
setOrigin3dx(float origin3dx)
|
void |
setOrigin3dy(float origin3dy)
|
void |
setRenderer(Chip2DRenderer renderer)
|
void |
setScale(float s)
This method sets the pixel drawing j2dScale so that e.g. |
void |
setZoom(ChipCanvas.Zoom zoom)
|
protected void |
showSpike(javax.media.opengl.GL gl)
Shows selected pixel spike count by drawn circle |
protected void |
showSpike(javax.media.opengl.GL gl,
int x,
int y,
int size)
draws a circle at pixel x,y of size+.5 radius. |
void |
unzoom()
|
void |
update(java.util.Observable o,
java.lang.Object arg)
|
void |
zoomIn()
|
void |
zoomOut()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.prefs.Preferences prefs
protected static final float SCALE_DEFAULT
protected AEViewer aeViewer
protected float anglex
protected float angley
protected final int colorScale
protected javax.media.opengl.GLCanvas drawable
protected float[][][] fr
protected RenderingFrame frameData
protected javax.media.opengl.glu.GLU glu
protected com.sun.opengl.util.GLUT glut
protected java.util.logging.Logger log
protected boolean openGLEnabled
protected int pheight
protected int[] pixels
public static final int MIN_DIMENSION
protected int pwidth
protected float j2dScale
protected static final java.awt.Color selectedPixelColor
protected javax.media.opengl.glu.GLUquadric selectedQuad
public java.awt.image.BufferStrategy strategy
protected int xt
protected int yt
protected boolean zoomMode
protected final int BORDER3D
protected java.awt.Insets insets
Constructor Detail |
---|
public ChipCanvas(Chip2D chip)
Method Detail |
---|
public void grabNextImage()
public javax.swing.JMenu getDisplayMethodMenu()
public void addDisplayMethod(DisplayMethod m)
m
- the methodpublic DisplayMethod getCurrentDisplayMethod()
public void cycleDisplayMethod()
public void setDisplayMethod(DisplayMethod m)
m
- the method to usepublic void setDisplayMethod(java.lang.String description)
description
- the nameprotected void setDisplayMethod(int index)
index
- the index of the method in the list of methodspublic void display(javax.media.opengl.GLAutoDrawable drawable)
display
in interface javax.media.opengl.GLEventListener
drawable
- the surface from which we can get the context with getGLwhich sets up GL context for display methods
public void displayChanged(javax.media.opengl.GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
displayChanged
in interface javax.media.opengl.GLEventListener
public float getAnglex()
public float getAngley()
public java.awt.Canvas getCanvas()
public float[][][] getFr()
public float getScale()
protected final java.awt.Color getPixelColor(float red, float green, float blue)
public java.awt.Point getPixelFromPoint(java.awt.Point mp)
mp
- a Point in ChipCanvas pixels.
public java.awt.Point getMousePixel()
public java.awt.Point getPixelFromMouseEvent(java.awt.event.MouseEvent evt)
protected final int getPixelRGB(float red, float green, float blue)
public void init(javax.media.opengl.GLAutoDrawable drawable)
init
in interface javax.media.opengl.GLEventListener
protected void initComponents()
public boolean is3DEnabled()
public boolean isOpenGLEnabled()
public boolean isZoomMode()
protected void paint()
public void paint(java.awt.Graphics g)
g
- null to use BufferStrategy graphics (created on demand), non-null to paint to some other rendering context, e.g. an Image that can be written to a filepublic void paintFrame()
public void removeGLEventListener(javax.media.opengl.GLEventListener listener)
public void repaint()
public void repaint(long tm)
public void reshape(javax.media.opengl.GLAutoDrawable drawable, int x, int y, int width, int height)
reshape
in interface javax.media.opengl.GLEventListener
protected java.lang.String scalePrefsKey()
protected void set3dOrigin(int x, int y)
public void setAnglex(float anglex)
public void setAngley(float angley)
public void setOpenGLEnabled(boolean openGLEnabled)
protected void setDefaultProjection(javax.media.opengl.GL g, javax.media.opengl.GLAutoDrawable d)
g
- the GL contextd
- the GLAutoDrawable canvaspublic void setScale(float s)
s
- size of chip pixel in screen pixels.protected void showSpike(javax.media.opengl.GL gl)
protected void showSpike(javax.media.opengl.GL gl, int x, int y, int size)
public void zoomIn()
public void zoomOut()
public void unzoom()
public void update(java.util.Observable o, java.lang.Object arg)
update
in interface java.util.Observer
public Chip2DRenderer getRenderer()
public void setRenderer(Chip2DRenderer renderer)
public java.util.ArrayList<DisplayMethod> getDisplayMethods()
public void setDisplayMethods(java.util.ArrayList<DisplayMethod> displayMethods)
public int getBorderSpacePixels()
public void setBorderSpacePixels(int borderSpacePixels)
borderSpacePixels
- in screen pixels.public ChipCanvas.Zoom getZoom()
public void setZoom(ChipCanvas.Zoom zoom)
public boolean isFillsHorizontally()
public boolean isFillsVertically()
public void addGLEventListener(javax.media.opengl.GLEventListener listener)
protected void annotate(javax.media.opengl.GLAutoDrawable drawable)
drawable
- the contextprotected void annotate(java.awt.Graphics2D g2)
g2
- the graphics context passed to the EventFilter annotatorspublic void checkGLError(javax.media.opengl.GL g, javax.media.opengl.glu.GLU glu, java.lang.String msg)
g
- the GL contextglu
- the GLU used to obtain the error stringsmsg
- an error message to log to e.g., show the contextpublic float getOrigin3dx()
public void setOrigin3dx(float origin3dx)
public float getOrigin3dy()
public void setOrigin3dy(float origin3dy)
public java.awt.image.BufferedImage getImageOpenGL()
public com.sun.opengl.util.GLUT getGlut()
public Chip2D getChip()
public void setChip(Chip2D chip)
|
jAER project on SourceForge | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |