<commit_before>/**
 *
 * FreeTransform class contains quad objects distinguishes quads between
 * selected and/or focused for interaction routines saves/loads coordinates
 * to/from external json file
 * 
 * @author <NAME>
 * @version 0.3.0
 * @since 2016-04-30
 * 
 * @example Hello 
 * 
 * 
 */

package bare.utils;

import processing.data.JSONArray;
import processing.data.JSONObject;
import processing.event.KeyEvent;
import java.util.ArrayList;
import java.util.Iterator;

import processing.core.*;

public class FreeTransform {

	// myParent is a reference to the parent sketch
	PApplet myParent;

	PVector P; // user input vector (mouse)
	PVector beginP; // inial P position (before making offset)
	PVector offsetP; // offset made by moving P from initial position

	int myVariable = 0;

	public final static String VERSION = "##library.prettyVersion##";

	ArrayList<Polygon> quads;
	int selectedQuad;
	boolean helpMode = false; //
	JSONArray coordinateValues;
	public boolean isEnabled = false;

	Events events; //

	int defaultSize = 50;

	// load image cursors (they should be as png files in data/ folder
	Cursors cursors;

	/**
	 * a Constructor, usually called in the setup() method in your sketch to
	 * initialize and start the Library.
	 * 
	 * @example Hello
	 * @param theParent
	 *            parent Processing object
	 */

	public FreeTransform(PApplet theParent) {
		this.myParent = theParent;
		welcome();
		quads = new ArrayList<Polygon>();

		// load cooradinates for all quads points from external JSON file
		loadValues();

		// enable mouse and key events (unregistered by default)
		events = new Events(this);
		this.myParent.registerMethod("keyEvent", this);
		System.out.println("[notice ] Press t to enable/disable Free Transform.. ");

		// create Cursors object
		cursors = new Cursors();
		cursors.loadCursors(theParent, this);
	}

	public void toggleTransform() {
		isEnabled = !isEnabled;

		// enable or disable transformation mouse / key events
		if (isEnabled)
			events.register();
		else {
			events.unregister();
			myParent.cursor();
		}
	}

	public void draw() {
		update(); //
		render(); //
	}

	void update() {
		// interate backwards to avoid out of bounds exceptions when removieng
		// from arraylist
		Iterator<Polygon> quadsIterator = quads.iterator();
		while (quadsIterator.hasNext()) {
			// System.out.println(quadsIterator.next());
			// }
			// for (int i = quads.size()-1; i >= 0; i--) {
			// Polygon quad = quads.get(i); //

			Polygon quad = quadsIterator.next(); //
			// update quad points (neede to transform textures)
			quad.update();

			// display quad ,cursors
			if (isEnabled) {
				quad.render(); //
				cursors.render();
			}
		}
	}

	void render() {
		showDebugInfo();
	}

	// return the currently mouse selected quad
	int selectedQuadId() {

		for (int i = 0; i < quads.size(); i++) {
			Polygon quad = quads.get(i); //
			if (quad.dragLock) {
				selectedQuad = quad.id;
				quad.isSelected = true; //
			} else
				quad.isSelected = false;
		}
		return selectedQuad;
	}
<commit_msg>added render() function to render images loaded from json file<commit_after>/**
 *
 * FreeTransform class contains quad objects distinguishes quads between
 * selected and/or focused for interaction routines saves/loads coordinates
 * to/from external json file
 * 
 * @author <NAME>
 * @version 0.3.0
 * @since 2016-04-30
 * 
 * @example Hello 
 * 
 * 
 */

package bare.utils;

import processing.data.JSONArray;
import processing.data.JSONObject;
import processing.event.KeyEvent;
import java.util.ArrayList;
import java.util.Iterator;

import processing.core.*;

public class FreeTransform {

	// myParent is a reference to the parent sketch
	PApplet myParent;

	PVector P; // user input vector (mouse)
	PVector beginP; // inial P position (before making offset)
	PVector offsetP; // offset made by moving P from initial position

	int myVariable = 0;

	public final static String VERSION = "##library.prettyVersion##";

	ArrayList<Polygon> quads;
	int selectedQuad;
	boolean helpMode = false; //
	JSONArray coordinateValues;
	public boolean isEnabled = false;

	Events events; //

	int defaultSize = 50;

	// load image cursors (they should be as png files in data/ folder
	Cursors cursors;

	/**
	 * a Constructor, usually called in the setup() method in your sketch to
	 * initialize and start the Library.
	 * 
	 * @example Hello
	 * @param theParent
	 *            parent Processing object
	 */

	public FreeTransform(PApplet theParent) {
		this.myParent = theParent;
		welcome();
		quads = new ArrayList<Polygon>();

		// load cooradinates for all quads points from external JSON file
		loadValues();

		// enable mouse and key events (unregistered by default)
		events = new Events(this);
		this.myParent.registerMethod("keyEvent", this);
		System.out.println("[notice ] Press t to enable/disable Free Transform.. ");

		// create Cursors object
		cursors = new Cursors();
		cursors.loadCursors(theParent, this);
	}

	public void toggleTransform() {
		isEnabled = !isEnabled;

		// enable or disable transformation mouse / key events
		if (isEnabled)
			events.register();
		else {
			events.unregister();
			myParent.cursor();
		}
	}
	
	public void draw()
	{
		update();
		render();
	}

	public void update() {
		// interate backwards to avoid out of bounds exceptions when removieng
		// from arraylist
		Iterator<Polygon> quadsIterator = quads.iterator();
		while (quadsIterator.hasNext()) {
			
			Polygon quad = quadsIterator.next(); //
			// update quad points (neede to transform textures)
			quad.update();

			// display quad ,cursors
			if (isEnabled) {
				quad.render(); //
				cursors.render();
			}
		}
		
		// diplay help and debug information
		showDebugInfo();
	}

	// display images loaded from json file
	void render() {
		Iterator<Polygon> quadsIterator = quads.iterator();
		while (quadsIterator.hasNext()) {
		
			Polygon quad = quadsIterator.next(); //
			// update quad points (neede to transform textures)
			quad.update();
		}
	}

	// return the currently mouse selected quad
	int selectedQuadId() {

		for (int i = 0; i < quads.size(); i++) {
			Polygon quad = quads.get(i); //
			if (quad.dragLock) {
				selectedQuad = quad.id;
				quad.isSelected = true; //
			} else
				quad.isSelected = false;
		}
		return selectedQuad;
	}

{'fraction_non_alphanumeric': 0.11332385016595543, 'fraction_numerical': 0.005057689268215584, 'mean_word_length': 3.2412868632707776, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 13, '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': '4918233', 'n_tokens_mistral': 2146, 'n_tokens_neox': 1874, 'n_words': 618}