<commit_before>package com.haxademic.core.draw.image;

import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Robot;

import com.haxademic.core.system.SystemUtil;

import processing.core.PApplet;
import processing.core.PGraphics;
import processing.core.PImage;

public class ScreenUtil {
	
	public static String saveScreenshot( PApplet p, String outputDir ) {
		String filename = outputDir + SystemUtil.getTimestampFine( p ) + ".png";
		p.saveFrame( filename );
		return filename;
	}
	
	public static void screenshotHiRes( PApplet p, int scaleFactor, String p5Renderer, String outputDir ) {
		// from: http://amnonp5.wordpress.com/2012/01/28/25-life-saving-tips-for-processing/
		PGraphics hires = p.createGraphics(p.width*scaleFactor, p.height*scaleFactor, p5Renderer );
		hires.beginDraw();
		p.beginRecord(hires);
		hires.scale(scaleFactor);
		p.smooth();
		p.draw();
		p.endRecord();
		hires.endDraw();
		hires.save( outputDir + SystemUtil.getTimestamp(p) + "-hires.png" );
		p.noSmooth();
	}

	public static PImage getScreenAsPImage( PApplet p ) {
		return p.get();
	}
	
	public static PImage getScreenShotAsPImage( PApplet p ) {
		try {
			Robot robot = new Robot();
			PImage screenshot = new PImage(robot.createScreenCapture(new Rectangle(0,0,p.width,p.height)));
			return screenshot;
		} catch (AWTException e) { }
		return null;
	}

}
<commit_msg>Add a screenshot method for multiple monitors<commit_after>package com.haxademic.core.draw.image;

import java.awt.AWTException;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.geom.Rectangle2D;

import com.haxademic.core.system.SystemUtil;

import processing.core.PApplet;
import processing.core.PGraphics;
import processing.core.PImage;

public class ScreenUtil {

	public static String saveScreenshot( PApplet p, String outputDir ) {
		String filename = outputDir + SystemUtil.getTimestampFine( p ) + ".png";
		p.saveFrame( filename );
		return filename;
	}

	public static void screenshotHiRes( PApplet p, int scaleFactor, String p5Renderer, String outputDir ) {
		// from: http://amnonp5.wordpress.com/2012/01/28/25-life-saving-tips-for-processing/
		PGraphics hires = p.createGraphics(p.width*scaleFactor, p.height*scaleFactor, p5Renderer );
		hires.beginDraw();
		p.beginRecord(hires);
		hires.scale(scaleFactor);
		p.smooth();
		p.draw();
		p.endRecord();
		hires.endDraw();
		hires.save( outputDir + SystemUtil.getTimestamp(p) + "-hires.png" );
		p.noSmooth();
	}

	public static PImage getScreenShotAsPImage( PApplet p ) {
		try {
			Robot robot = new Robot();
			PImage screenshot = new PImage(robot.createScreenCapture(new Rectangle(0,0,p.width,p.height)));
			return screenshot;
		} catch (AWTException e) { }
		return null;
	}

	public static PImage getScreenShotAllMonitors() {
		return getScreenShotAllMonitors(0,0);
	}
	
	public static PImage getScreenShotAllMonitors(int x, int y) {
		// NOTE! main monitor must be top left, otherwise, override x+y position  
		try {
			Rectangle2D result = new Rectangle2D.Double();
			GraphicsEnvironment localGE = GraphicsEnvironment.getLocalGraphicsEnvironment();
			for (GraphicsDevice gd : localGE.getScreenDevices()) {
				for (GraphicsConfiguration graphicsConfiguration : gd.getConfigurations()) {
					Rectangle2D.union(result, graphicsConfiguration.getBounds(), result);
				}
			}

			Robot robot = new Robot();
			PImage screenshot = new PImage(robot.createScreenCapture(new Rectangle(x, y,(int) result.getWidth(), (int) result.getHeight())));
			return screenshot;
		} catch (AWTException e) { }
		return null;
	}

}

{'fraction_non_alphanumeric': 0.1185888738127544, 'fraction_numerical': 0.00976933514246947, 'mean_word_length': 4.610350076103501, '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': '3219871', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1210, 'n_words': 267}