<commit_before>package com.functiongrapher.ui;

import static org.lwjgl.glfw.GLFW.glfwWindowShouldClose;

import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import javax.imageio.ImageIO;

import org.lwjgl.BufferUtils;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.glfw.GLFWImage.Buffer;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GL11;
import org.lwjgl.system.MemoryUtil;

import com.functiongrapher.callbacks.KeyCallback;
import com.functiongrapher.function.FunctionManager;
import com.functiongrapher.main.ProgramInfo;

public class GraphWindow {

	private static long windowID;
	private static boolean is3D = false;
	private static boolean isfullscreen = false;
	private static boolean controlslocked = false;
	private static boolean takescreenshot = false;
	private static BufferedImage screenshot = null;
	private static float yawspeed = 0.0f;

	private static float camerapitch = -50.0f;
	private static float camerayaw = 0.0f;
	private static float cameraroll = 0.0f;
	private static float camerafov = 70.0f;
	private static float camerazoom = 30.0f;

	private static int fpscnt = 0;
	private static long totfps = 0;

	private static float temppitch;
	private static float tempyaw;

	private static int mousex;
	private static int mousey;

	private static int mouse1state;
	private static int prevmouse1state;

	public static void init() {
		GLFWErrorCallback.createPrint(System.err).set();

		boolean initResult = GLFW.glfwInit();
		if (initResult == false) {
			throw new IllegalStateException("GLFW init failed");
		}

		//GLFW.glfwWindowHint(GLFW.GLFW_STENCIL_BITS, 8);
		GLFW.glfwWindowHint(GLFW.GLFW_SAMPLES, 16);
		try {
			InputStream s = GraphWindow.class.getResourceAsStream(ProgramInfo.ICON32_PATH);
			BufferedImage i = ImageIO.read(s);
			byte[] pixelData = ((DataBufferByte) i.getRaster().getDataBuffer()).getData();
			ByteBuffer buf = ByteBuffer.allocateDirect(pixelData.length);
			buf.order(ByteOrder.nativeOrder());
			buf.put(pixelData);
			buf.flip();
			Buffer img = new Buffer(buf);
			GLFW.glfwSetWindowIcon(windowID, img);
		} catch (Exception e) {
			System.out.println("Could not set window icon!");
			e.printStackTrace();
		}

		windowID = GLFW.glfwCreateWindow(640, 480, ProgramInfo.PROGRAM_NAME, MemoryUtil.NULL, MemoryUtil.NULL);
		if (windowID == MemoryUtil.NULL) {
			throw new IllegalStateException("Window creation failed");
		}

		GLFW.glfwSetKeyCallback(windowID, new KeyCallback() {
			@Override
			public void invoke(long window, int key, int scancode, int action, int mods) {
				System.out.println(String.valueOf(key) + " pressed");
				if (action == GLFW.GLFW_PRESS) {

					switch (key) {
					case GLFW.GLFW_KEY_F11:
						if (isfullscreen) {
							GLFW.glfwSetWindowMonitor(windowID, GLFW.glfwGetPrimaryMonitor(), 0, 0, 1920, 1080, (int) MemoryUtil.NULL);
						} else {
							GLFW.glfwSetWindowMonitor(windowID, MemoryUtil.NULL, 100, 100, 640, 480, (int) MemoryUtil.NULL);
						}
						isfullscreen = !isfullscreen;
						break;
					}
				}
			}

		});

		GLFW.glfwMakeContextCurrent(windowID);
		GLFW.glfwSwapInterval(1);
		GLFW.glfwShowWindow(windowID);

		GL.createCapabilities();
		GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
		GL11.glClearDepth(1.0f);
		GL11.glEnable(GL11.GL_DEPTH_TEST);
		GL11.glDepthFunc(GL11.GL_LEQUAL);
		GL11.glShadeModel(GL11.GL_SMOOTH);<commit_msg>Made some callback changes to GraphWindow.<commit_after>package com.functiongrapher.ui;

import static org.lwjgl.glfw.GLFW.glfwWindowShouldClose;

import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import javax.imageio.ImageIO;

import org.lwjgl.BufferUtils;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.glfw.GLFWImage.Buffer;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GL11;
import org.lwjgl.system.MemoryUtil;

import com.functiongrapher.callbacks.KeyCallback;
import com.functiongrapher.function.FunctionManager;
import com.functiongrapher.main.ProgramInfo;

public class GraphWindow {

	private static long windowID;
	private static boolean is3D = false;
	private static boolean isfullscreen = false;
	private static boolean controlslocked = false;
	private static boolean takescreenshot = false;
	private static BufferedImage screenshot = null;
	private static float yawspeed = 0.0f;

	private static float camerapitch = -50.0f;
	private static float camerayaw = 0.0f;
	private static float cameraroll = 0.0f;
	private static float camerafov = 70.0f;
	private static float camerazoom = 30.0f;

	private static int fpscnt = 0;
	private static long totfps = 0;

	private static float temppitch;
	private static float tempyaw;

	private static int mousex;
	private static int mousey;

	private static int mouse1state;
	private static int prevmouse1state;

	public static void init() {
		GLFWErrorCallback.createPrint(System.err).set();

		boolean initResult = GLFW.glfwInit();
		if (initResult == false) {
			throw new IllegalStateException("GLFW init failed");
		}

		//GLFW.glfwWindowHint(GLFW.GLFW_STENCIL_BITS, 8);
		GLFW.glfwWindowHint(GLFW.GLFW_SAMPLES, 16);
		try {
			InputStream s = GraphWindow.class.getResourceAsStream(ProgramInfo.ICON32_PATH);
			BufferedImage i = ImageIO.read(s);
			byte[] pixelData = ((DataBufferByte) i.getRaster().getDataBuffer()).getData();
			ByteBuffer buf = ByteBuffer.allocateDirect(pixelData.length);
			buf.order(ByteOrder.nativeOrder());
			buf.put(pixelData);
			buf.flip();
			Buffer img = new Buffer(buf);
			GLFW.glfwSetWindowIcon(windowID, img);
		} catch (Exception e) {
			System.out.println("Could not set window icon!");
			e.printStackTrace();
		}

		windowID = GLFW.glfwCreateWindow(640, 480, ProgramInfo.PROGRAM_NAME, MemoryUtil.NULL, MemoryUtil.NULL);
		if (windowID == MemoryUtil.NULL) {
			throw new IllegalStateException("Window creation failed");
		}

		GLFW.glfwSetKeyCallback(windowID, new KeyCallback() {
			@Override
			public void invoke(long window, int key, int scancode, int action, int mods) {
				System.out.println("invoke() method called");
				if (action == GLFW.GLFW_PRESS) {

					switch (key) {
					case GLFW.GLFW_KEY_F11:
						isfullscreen = !isfullscreen;
						if (isfullscreen) {
							GLFW.glfwSetWindowMonitor(windowID, GLFW.glfwGetPrimaryMonitor(), 0, 0, 1920, 1080, (int) MemoryUtil.NULL);
						} else {
							GLFW.glfwSetWindowMonitor(windowID, MemoryUtil.NULL, 100, 100, 640, 480, (int) MemoryUtil.NULL);
						}
						break;
					}
				}
			}
			
			@Override
			public void callback(long arg0) {
				System.out.println("callback() method called");
			}

		});

		GLFW.glfwMakeContextCurrent(windowID);
		GLFW.glfwSwapInterval(1);
		GLFW.glfwShowWindow(windowID);

		GL.createCapabilities();
		GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
		GL11.glClearDepth(1.0f);
		GL11.glEnable(GL11.GL_DEPTH_TEST);
		GL11.glDepthFunc(GL11.GL_LEQUAL);
		GL11.glShadeModel(GL11.GL_SMOOTH);
{'fraction_non_alphanumeric': 0.1094716132658797, 'fraction_numerical': 0.02374929735806633, 'mean_word_length': 4.5, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5097361', 'n_tokens_mistral': 2815, 'n_tokens_neox': 2431, 'n_words': 529}