<commit_before>/*
 * ChipRendererDisplayMethod.java
 *
 * Created on May 4, 2006, 9:07 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 *
 *
 *Copyright May 4, 2006 <NAME>, Inst. of Neuroinformatics, UNI-ETH Zurich
 */
package net.sf.jaer.graphics;

import java.awt.Font;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;

import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GL2ES1;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.fixedfunc.GLMatrixFunc;

import com.jogamp.opengl.util.awt.TextRenderer;
import java.awt.geom.Point2D;

/**
 * Renders using OpenGL the RGB histogram values from Chip2DRenderer.

 * @author <NAME>
 * @see net.sf.jaer.graphics.Chip2DRenderer
 * @see net.sf.jaer.graphics.AEChipRenderer
 */
public class ChipRendererDisplayMethodRGBA extends DisplayMethod implements DisplayMethod2D {

    private TextRenderer textRenderer = null;
    public final float SPECIAL_BAR_LOCATION_X = -5;
    public final float SPECIAL_BAR_LOCATION_Y = 0;
    public final float SPECIAL_BAR_LINE_WIDTH=8;
    private boolean renderSpecialEvents=true;
    

    /**
     * Creates a new instance of ChipRendererDisplayMethodRGBA
     */
    public ChipRendererDisplayMethodRGBA(ChipCanvas chipCanvas) {
        super(chipCanvas);
    }

    /** called by ChipCanvas.display(GLAutoDrawable) to draw the RGB fr histogram values. The GL context is assumed to already be
    transformed so that chip pixel x,y values can be used for coordinate values, with 0,0 at LL corner.
     */
    @Override
    public void display(GLAutoDrawable drawable) {
//        displayPixmap(drawable);
     
       displayQuad(drawable);
    }

    private float clearDisplay(Chip2DRenderer renderer, GL gl) {
        float gray = renderer.getGrayValue();
        gl.glClearColor(gray, gray, gray, 0f);
        gl.glClear(GL.GL_COLOR_BUFFER_BIT);
        return gray;
    }

    private boolean isValidRasterPosition(GL gl) {
        boolean validRaster;
        ByteBuffer buf = ByteBuffer.allocate(1);
        gl.glGetBooleanv(GL2.GL_CURRENT_RASTER_POSITION_VALID, buf);
        buf.rewind();
        byte b = buf.get();
        validRaster = b != 0;
        return validRaster;
    }

    private void displayQuad(GLAutoDrawable drawable){
        Chip2DRenderer renderer = getChipCanvas().getRenderer();
        FloatBuffer pixmap = renderer.getPixmap();
        FloatBuffer onMap = null;
        FloatBuffer offMap = null;
        boolean displayEvents = false;
        boolean displayFrames = true;
        if(renderer instanceof AEFrameChipRenderer){
            AEFrameChipRenderer frameRenderer = (AEFrameChipRenderer) renderer;
            onMap = frameRenderer.getOnMap();
            offMap = frameRenderer.getOffMap();
            displayFrames = frameRenderer.isDisplayFrames();
            displayEvents = frameRenderer.isDisplayEvents();
        }
        int width = renderer.getWidth();
        int height = renderer.getHeight();
        if((width == 0) || (height == 0)) {
			return;
		}

        GL2 gl = drawable.getGL().getGL2();
        clearDisplay(renderer, gl);

        getChipCanvas().checkGLError(gl, glu, "before quad");

        gl.glDisable(GL.GL_DEPTH_TEST);
        gl.glBlendFunc (GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
        gl.glEnable (GL.GL_BLEND);

        final int nearestFilter=GL.GL_NEAREST; // tobi changed to GL_NEAREST so that pixels are not intepolated but rather are rendered exactly as they come from data not matter what zoom.
        final int linearFilter=GL.GL_LINEAR; // tobi changed to GL_NEAREST so that pixels are not intepolated but rather are rendered exactly as they come from data not matter what zoom.
        if(displayFrames){
            gl.glPushMatrix();
            if(imageTransform!=null){
                int sx=chip.getSizeX()/2, sy=chip.getSizeY()/2;
//                gl.glTranslatef(chip.getSizeX()/2, chip.getSizeY()/2, 0);
                gl.glTranslatef(sx,sy, 0);
                gl.glRotatef((float)(imageTransform.rotationRad*180/Math.PI), 0,0, 1);<commit_msg>changed comment about interpolation method for rendering image<commit_after>/*
 * ChipRendererDisplayMethod.java
 *
 * Created on May 4, 2006, 9:07 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 *
 *
 *Copyright May 4, 2006 <NAME>, Inst. of Neuroinformatics, UNI-ETH Zurich
 */
package net.sf.jaer.graphics;

import java.awt.Font;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;

import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GL2ES1;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.fixedfunc.GLMatrixFunc;

import com.jogamp.opengl.util.awt.TextRenderer;
import java.awt.geom.Point2D;

/**
 * Renders using OpenGL the RGB histogram values from Chip2DRenderer.

 * @author <NAME>
 * @see net.sf.jaer.graphics.Chip2DRenderer
 * @see net.sf.jaer.graphics.AEChipRenderer
 */
public class ChipRendererDisplayMethodRGBA extends DisplayMethod implements DisplayMethod2D {

    private TextRenderer textRenderer = null;
    public final float SPECIAL_BAR_LOCATION_X = -5;
    public final float SPECIAL_BAR_LOCATION_Y = 0;
    public final float SPECIAL_BAR_LINE_WIDTH=8;
    private boolean renderSpecialEvents=true;
    

    /**
     * Creates a new instance of ChipRendererDisplayMethodRGBA
     */
    public ChipRendererDisplayMethodRGBA(ChipCanvas chipCanvas) {
        super(chipCanvas);
    }

    /** called by ChipCanvas.display(GLAutoDrawable) to draw the RGB fr histogram values. The GL context is assumed to already be
    transformed so that chip pixel x,y values can be used for coordinate values, with 0,0 at LL corner.
     */
    @Override
    public void display(GLAutoDrawable drawable) {
//        displayPixmap(drawable);
     
       displayQuad(drawable);
    }

    private float clearDisplay(Chip2DRenderer renderer, GL gl) {
        float gray = renderer.getGrayValue();
        gl.glClearColor(gray, gray, gray, 0f);
        gl.glClear(GL.GL_COLOR_BUFFER_BIT);
        return gray;
    }

    private boolean isValidRasterPosition(GL gl) {
        boolean validRaster;
        ByteBuffer buf = ByteBuffer.allocate(1);
        gl.glGetBooleanv(GL2.GL_CURRENT_RASTER_POSITION_VALID, buf);
        buf.rewind();
        byte b = buf.get();
        validRaster = b != 0;
        return validRaster;
    }

    private void displayQuad(GLAutoDrawable drawable){
        Chip2DRenderer renderer = getChipCanvas().getRenderer();
        FloatBuffer pixmap = renderer.getPixmap();
        FloatBuffer onMap = null;
        FloatBuffer offMap = null;
        boolean displayEvents = false;
        boolean displayFrames = true;
        if(renderer instanceof AEFrameChipRenderer){
            AEFrameChipRenderer frameRenderer = (AEFrameChipRenderer) renderer;
            onMap = frameRenderer.getOnMap();
            offMap = frameRenderer.getOffMap();
            displayFrames = frameRenderer.isDisplayFrames();
            displayEvents = frameRenderer.isDisplayEvents();
        }
        int width = renderer.getWidth();
        int height = renderer.getHeight();
        if((width == 0) || (height == 0)) {
			return;
		}

        GL2 gl = drawable.getGL().getGL2();
        clearDisplay(renderer, gl);

        getChipCanvas().checkGLError(gl, glu, "before quad");

        gl.glDisable(GL.GL_DEPTH_TEST);
        gl.glBlendFunc (GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
        gl.glEnable (GL.GL_BLEND);

        final int nearestFilter=GL.GL_NEAREST; // tobi changed to GL_NEAREST so that pixels are not intepolated but rather are rendered exactly as they come from data not matter what zoom.
        final int linearFilter=GL.GL_LINEAR; // does linear interpolation of value, to make image that looks smoother
        if(displayFrames){
            gl.glPushMatrix();
            if(imageTransform!=null){
                int sx=chip.getSizeX()/2, sy=chip.getSizeY()/2;
//                gl.glTranslatef(chip.getSizeX()/2, chip.getSizeY()/2, 0);
                gl.glTranslatef(sx,sy, 0);
                gl.glRotatef((float)(imageTransform.rotationRad*180/Math.PI), 0,0, 1);
{'fraction_non_alphanumeric': 0.09387065637065638, 'fraction_numerical': 0.011341698841698842, 'mean_word_length': 2.98893166506256, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3400306', 'n_tokens_mistral': 2612, 'n_tokens_neox': 2440, 'n_words': 631}