<commit_before>package com.ralitski.util.gui;

import com.ralitski.util.doc.TODO;

public enum BoxPosition {
	CENTER(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int x = (window.getWidth() - toPosition.getWidth()) / 2;
			int y = (window.getHeight() - toPosition.getHeight()) / 2;
			toPosition.setPosition(x + window.getMinX(), y + window.getMinY());
		}
	},
	CENTER_WIDE(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int x = (window.getWidth() - toPosition.getWidth()) / 2;
			toPosition.setX(x + window.getMinX());
		}
	},
	CENTER_HIGH(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int y = (window.getHeight() - toPosition.getHeight()) / 2;
			toPosition.setY(y + window.getMinY());
		}
	},
	LEFT(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			toPosition.translateX(space - toPosition.getMinX() + window.getMinX());
		}
	},
	RIGHT(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			toPosition.translateX(window.getMaxX() - toPosition.getMaxX() - space);
		}
	},
	TOP(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			toPosition.translateY(window.getMaxY() - toPosition.getMaxY() - space);
		}
	},
	BOTTOM(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			toPosition.translateY(space - toPosition.getMinY() + window.getMinY());
		}
	},
	ABOVE(true) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMaxY() + space - toPosition.getMinY();
			toPosition.setCenterY(Math.max(toPosition.getCenterY(), pos));
		}
	},
	ABOVE_STRICT(true) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMaxY() + space - toPosition.getMinY();
			toPosition.setCenterY(pos);
		}
	},
	LEFT_OF(true) {
		@Override
                    @TODO
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMinX() - space - toPosition.getMaxX();
			toPosition.setCenterX(Math.min(toPosition.getCenterX(), pos));
		}
	},
	LEFT_OF_STRICT(true) {
		@Override
                    @TODO
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMinX() - space - toPosition.getMaxX();
			toPosition.setCenterX(pos);
		}
	},
	RIGHT_OF(true) {
		@Override
                    @TODO
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMaxX() + space - toPosition.getMinX();
			toPosition.setCenterX(Math.max(toPosition.getCenterX(), pos));
		}
	},
	RIGHT_OF_STRICT(true) {
		@Override
                    @TODO
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMaxX() + space - toPosition.getMinX();
			toPosition.setCenterX(pos);
		}
	},
	BELOW(true) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMinY() - space - toPosition.getMaxY();
			toPosition.setCenterY(Math.min(toPosition.getCenterY(), pos));
		}
	},
	BELOW_STRICT(true) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMinY() - space - toPosition.getMaxY();
			toPosition.setCenterY(pos);
		}
	},
	WITHIN(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			if(toPosition.getMinX() < window.getMinX() + space) {
				toPosition.translateX(window.getMinX() - toPosition.getMinX() + space);
			} else if(toPosition.getMaxX() > window.getMaxX() - space) {
				toPosition.translateX(window.getMaxX() - toPosition.getMaxX() - space);
			}
			if(toPosition.getMinY() < window.getMinY() + space) {
				toPosition.translateY(window.getMinY() - toPosition.getMinY() + space);
			} else if(toPosition.getMaxY() > window.getMaxY() - space) {
				toPosition.translateY(window.getMaxY() - toPosition.getMaxY() - space);
			}
		}
	},
	WITHIN_STRICT(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			//x
			if(toPosition.getWidth() > window.getWidth()) {
				toPosition.setMinX(window.getMinX());
				toPosition.setMaxX(window.getMaxX());
			} else if(toPosition.getMinX() < window.getMinX() + space) {
				toPosition.translateX(window.getMinX() - toPosition.getMinX() + space);<commit_msg>BoxPosition needs testing<commit_after>package com.ralitski.util.gui;

import com.ralitski.util.doc.TODO;

public enum BoxPosition {
	CENTER(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int x = (window.getWidth() - toPosition.getWidth()) / 2;
			int y = (window.getHeight() - toPosition.getHeight()) / 2;
			toPosition.setPosition(x + window.getMinX(), y + window.getMinY());
		}
	},
	CENTER_WIDE(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int x = (window.getWidth() - toPosition.getWidth()) / 2;
			toPosition.setX(x + window.getMinX());
		}
	},
	CENTER_HIGH(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int y = (window.getHeight() - toPosition.getHeight()) / 2;
			toPosition.setY(y + window.getMinY());
		}
	},
	LEFT(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			toPosition.translateX(space - toPosition.getMinX() + window.getMinX());
		}
	},
	RIGHT(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			toPosition.translateX(window.getMaxX() - toPosition.getMaxX() - space);
		}
	},
	TOP(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			toPosition.translateY(window.getMaxY() - toPosition.getMaxY() - space);
		}
	},
	BOTTOM(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			toPosition.translateY(space - toPosition.getMinY() + window.getMinY());
		}
	},
	ABOVE(true) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMaxY() + space - toPosition.getMinY();
			toPosition.setCenterY(Math.max(toPosition.getCenterY(), pos));
		}
	},
	ABOVE_STRICT(true) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMaxY() + space - toPosition.getMinY();
			toPosition.setCenterY(pos);
		}
	},
	LEFT_OF(true) {
		@Override
                    @TODO
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMinX() - space - toPosition.getMaxX();
			toPosition.setCenterX(Math.min(toPosition.getCenterX(), pos));
		}
	},
	LEFT_OF_STRICT(true) {
		@Override
                    @TODO
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMinX() - space - toPosition.getMaxX();
			toPosition.setCenterX(pos);
		}
	},
	RIGHT_OF(true) {
		@Override
                    @TODO
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMaxX() + space - toPosition.getMinX();
			toPosition.setCenterX(Math.max(toPosition.getCenterX(), pos));
		}
	},
	RIGHT_OF_STRICT(true) {
		@Override
                    @TODO
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMaxX() + space - toPosition.getMinX();
			toPosition.setCenterX(pos);
		}
	},
	BELOW(true) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMinY() - space - toPosition.getMaxY();
			toPosition.setCenterY(Math.min(toPosition.getCenterY(), toPosition.getCenterY() + pos));
		}
	},
	BELOW_STRICT(true) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			int pos = relative.getMinY() - space - toPosition.getMaxY();
			toPosition.translateY(pos);
		}
	},
	WITHIN(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			if(toPosition.getMinX() < window.getMinX() + space) {
				toPosition.translateX(window.getMinX() - toPosition.getMinX() + space);
			} else if(toPosition.getMaxX() > window.getMaxX() - space) {
				toPosition.translateX(window.getMaxX() - toPosition.getMaxX() - space);
			}
			if(toPosition.getMinY() < window.getMinY() + space) {
				toPosition.translateY(window.getMinY() - toPosition.getMinY() + space);
			} else if(toPosition.getMaxY() > window.getMaxY() - space) {
				toPosition.translateY(window.getMaxY() - toPosition.getMaxY() - space);
			}
		}
	},
	WITHIN_STRICT(false) {
		@Override
		public void position(Box toPosition, Box relative, int space, Box window) {
			//x
			if(toPosition.getWidth() > window.getWidth()) {
				toPosition.setMinX(window.getMinX());
				toPosition.setMaxX(window.getMaxX());
			} else if(toPosition.getMinX() < window.getMinX() + space) {
				toPosition.translateX(window.getMinX() - toPosition.getMinX() + space);
{'fraction_non_alphanumeric': 0.13905579399141632, 'fraction_numerical': 0.0008583690987124463, 'mean_word_length': 3.76046986721144, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6334025', 'n_tokens_mistral': 3437, 'n_tokens_neox': 3136, 'n_words': 692}