<commit_before>package com.cazsius.solcarrot.client.gui.elements;

import java.awt.*;
import java.util.List;

public class UIStack extends UIElement {
	public Axis axis = Axis.HORIZONTAL;
	public int spacing = 1;
	
	public UIStack() {
		super(new Rectangle(0, 0));
	}
	
	public void addChild(UIElement child) {
		children.add(child);
		updateFrames();
	}
	
	public List<UIElement> getChildren() {
		return children;
	}
	
	public void updateFrames() {
		switch (axis) {
			case HORIZONTAL:
				int x = 0;
				int height = children.stream().mapToInt(child -> child.frame.height).max().orElse(0);
				for (UIElement child : children) {
					child.frame.x = frame.x + x;
					child.frame.y = frame.y + (height - child.frame.height) / 2;
					x += child.frame.width;
					x += spacing;
				}
				frame.width = x - spacing;
				frame.height = height;
				break;
			case VERTICAL:
				int y = 0;
				int width = children.stream().mapToInt(child -> child.frame.height).max().orElse(0);
				for (UIElement child : children) {
					child.frame.x = frame.x + (width - child.frame.width) / 2;
					child.frame.y = frame.y + y;
					y += child.frame.height;
					y += spacing;
				}
				frame.width = width;
				frame.height = y - spacing;
				break;
		}
	}
	
	enum Axis {
		HORIZONTAL, VERTICAL
	}
}<commit_msg>fixed several issues with `UIStack`<commit_after>package com.cazsius.solcarrot.client.gui.elements;

import java.awt.*;
import java.util.List;

public class UIStack extends UIElement {
	public Axis axis = Axis.HORIZONTAL;
	public int spacing = 1;
	
	public UIStack() {
		super(new Rectangle(0, 0));
	}
	
	public void addChild(UIElement child) {
		children.add(child);
		updateFrames();
	}
	
	public List<UIElement> getChildren() {
		return children;
	}
	
	public void updateFrames() {
		switch (axis) {
			case HORIZONTAL:
				int x = 0;
				int height = children.stream().mapToInt(child -> child.frame.height).max().orElse(0);
				for (UIElement child : children) {
					child.frame.x = frame.x + x;
					child.frame.y = frame.y + (height - child.frame.height) / 2;
					if (child instanceof UIStack) {
						((UIStack) child).updateFrames();
					}
					x += child.frame.width;
					x += spacing;
				}
				frame.width = x - spacing;
				frame.height = height;
				break;
			case VERTICAL:
				int y = 0;
				int width = children.stream().mapToInt(child -> child.frame.width).max().orElse(0);
				for (UIElement child : children) {
					child.frame.x = frame.x + (width - child.frame.width) / 2;
					child.frame.y = frame.y + y;
					if (child instanceof UIStack) {
						((UIStack) child).updateFrames();
					}
					y += child.frame.height;
					y += spacing;
				}
				frame.width = width;
				frame.height = y - spacing;
				break;
		}
	}
	
	public enum Axis {
		HORIZONTAL, VERTICAL
	}
}
{'fraction_non_alphanumeric': 0.1395848246241947, 'fraction_numerical': 0.006442376521116679, 'mean_word_length': 2.697089947089947, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6961694', 'n_tokens_mistral': 1213, 'n_tokens_neox': 963, 'n_words': 229}