<commit_before>package de.hshannover.operation_muehle.gui;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;


/** Provides the canvas to display the current Gameboard
 * 
 * @author mrzyx
 *
 */
public class Board extends Canvas {
	private static final long serialVersionUID = 1L;

	@Override
	public void paint(Graphics pen) {		
		int width = getWidth();
		int height = getHeight();
		int horizontalSpacing = 50;
		int verticalSpacing = 50;
		
		pen.setColor(Color.BLACK);
		
		pen.drawRect(horizontalSpacing, verticalSpacing,
					 width-2*horizontalSpacing, 
					 height-2*verticalSpacing);
		
		pen.drawRect(2*horizontalSpacing, 2*verticalSpacing,
				     width-4*horizontalSpacing,
				     height-4*verticalSpacing);
		
		
		pen.drawRect(4*horizontalSpacing, 4*verticalSpacing,
				     width-8*horizontalSpacing,
				     height-8*verticalSpacing);
	}
}<commit_msg>toying a bit with the Board canvas in order to come up with a sensible interface structure<commit_after>package de.hshannover.operation_muehle.gui;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;


/** Provides the canvas to display the current Gameboard
 * 
 * @author <NAME>
 *
 */
public class Board extends Canvas {
	private static final long serialVersionUID = 1L;
	private int spacing;

	private Spot spots[];
	private int width;
	private int height;
	
	public Board() {
		super();
		addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent event) {
				Point clicked = new Point(event.getX(), event.getY());
				for (Spot spot : spots) {
					if (clicked.x > spot.position.x-15 &&
						clicked.x < spot.position.x+15 &&
						clicked.y > spot.position.y-15 &&
						clicked.y < spot.position.y+15) {
						System.out.printf("Clicked %s%d\n", spot.column, spot.row);
						return;
					}
				}
				System.out.println("Nothing at "+clicked);
			}
		});
	}

	@Override
	public void paint(Graphics pen) {
		width = getWidth();
		height = getHeight();
		spacing = (width+height)/20; // TODO: better algorithm, maybe separate border and inner spacing
		
		recreateSpots();
		
		drawBackground(pen);
		drawBoard(pen);
		drawStones(pen);
	}

	private void recreateSpots() {
		spots = new Spot[24];
		int index = 0;
		
		for (int row = 1; row <= 3; row++) {
			spots[index++] = new Spot( // A1, B2, C3
				new Point(row*spacing, height-row*spacing),
				(char) (64+row), row);
			spots[index++] = new Spot( // A4, B4, C4 
				new Point(row*spacing, height/2), (char) (64+row), 4);
			spots[index++] = new Spot( // A7, B6, C5
				new Point(row*spacing, row*spacing),
				(char) (64+row), 8-row);
			
			spots[index++] = new Spot( // D1, D2, D3
				new Point(width/2, height-row*spacing), 'D', row);
			spots[index++] = new Spot( // D7, D6, D5
				new Point(width/2, row*spacing), 'D', 8-row);
			
			spots[index++] = new Spot( // G1, F2, E3
				new Point(width-row*spacing, height-row*spacing),
				(char) (72-row), row);
			spots[index++] = new Spot( // E4, F5, G4
				new Point(width-row*spacing, height/2), (char) (72-row), 4);
			spots[index++] = new Spot( // E5, F6, G7
				new Point(width-row*spacing, row*spacing),
				(char) (72-row), 8-row);
		}
	}

	private void drawBackground(Graphics pen) {
		pen.setColor(Color.DARK_GRAY);
		
		pen.fillRect(0, 0, width, height);
	}

	private void drawBoard(Graphics pen) {
		pen.setColor(Color.BLACK);
		
		pen.drawRect(spacing, spacing,
					 width-2*spacing, 
					 height-2*spacing);
		
		pen.drawRect(2*spacing, 2*spacing,
				     width-4*spacing,
				     height-4*spacing);
		
		
		pen.drawRect(3*spacing, 3*spacing,
				     width-6*spacing,
				     height-6*spacing);
		
		pen.drawLine(spacing, height/2, 3*spacing, height/2);
		pen.drawLine(width-3*spacing, height/2, width-spacing, height/2);
		pen.drawLine(width/2, spacing, width/2, 3*spacing);
		pen.drawLine(width/2, height-3*spacing, width/2, height-spacing);
	}

	private void drawStones(Graphics pen) {
		pen.setColor(Color.WHITE);
		
		
		for (Spot spot : spots) {
			pen.fillOval(spot.position.x-15, spot.position.y-15, 30, 30);
		}
	}
}

class Spot {
	Point position;
	char column;
	int row;
	
	public Spot(Point position, char column, int row) {
		this.position = position;
		this.column = column;
		this.row = row;
	}
}
{'fraction_non_alphanumeric': 0.14305239179954443, 'fraction_numerical': 0.02460136674259681, 'mean_word_length': 3.29227761485826, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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': '3428181', 'n_tokens_mistral': 1852, 'n_tokens_neox': 1504, 'n_words': 368}