<commit_before>/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2012-2014 <NAME>
 * Part of the jTRFP.org project
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     chuck - initial API and implementation
 ******************************************************************************/
package org.jtrfp.trcl;

import java.util.Arrays;

import org.jtrfp.trcl.core.TR;

public class CharLineDisplay {
    private char[] 		content;
    private final CharDisplay[] displays;
    double[] 			position 
    	= new double[] { 0, 0, 0 };
    private GLFont 		font;
    private double 		glSize;
    private double 		totGlLen = 0;
    private boolean 		centered = false;

    public CharLineDisplay(TR tr, RenderableSpacePartitioningGrid grid,
	    double glSize, int lengthInChars, GLFont font) {
	content = new char[lengthInChars];
	displays = new CharDisplay[lengthInChars];
	this.font = font;
	for (int i = 0; i < lengthInChars; i++) {
	    content[i] = 'X';
	    displays[i] = new CharDisplay(tr, grid, glSize, font);
	    displays[i].setChar('X');
	    grid.add(displays[i]);
	}// end for(lengthInChars)

	this.glSize = glSize;
	updatePositions();
    }// end LineDisplay(...)

    public void setContent(String content) {
	for (int i = 0; i < this.content.length; i++) {
	    char newContent=0;
	    if (i < content.length()) {
		final char c = content.charAt(i);
		if(c>32 || c<127)
		    newContent = content.charAt(i);
	    }
	    this.content[i] = newContent;
	    displays[i].setChar(newContent);
	}// end for(length)
	updatePositions();
    }// end setContent(...)

    private void updatePositions() {
	final double[] charPosition = Arrays.copyOf(position, 3);
	totGlLen = 0;
	// Determine total length;
	for (int i = 0; i < displays.length; i++) {
	    char _content = content[i];
	    if (_content != 0) {
		final double progress = ((double) glSize)
			* font.glWidthOf(_content) * 1.1;// 1.1 fudge factor for
							 // space between
							 // letters
		totGlLen += progress;
	    }
	}// end for(displays)
	if (centered)
	    charPosition[0] -= totGlLen / 2.;
	for (int i = 0; i < displays.length; i++) {
	    final double[] dispPos = displays[i].getPosition();<commit_msg>Made sure CharLineDisplay includes ASCII [SPACE] char 32.<commit_after>/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2012-2014 <NAME>
 * Part of the jTRFP.org project
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     chuck - initial API and implementation
 ******************************************************************************/
package org.jtrfp.trcl;

import java.util.Arrays;

import org.jtrfp.trcl.core.TR;

public class CharLineDisplay {
    private char[] 		content;
    private final CharDisplay[] displays;
    double[] 			position 
    	= new double[] { 0, 0, 0 };
    private GLFont 		font;
    private double 		glSize;
    private double 		totGlLen = 0;
    private boolean 		centered = false;

    public CharLineDisplay(TR tr, RenderableSpacePartitioningGrid grid,
	    double glSize, int lengthInChars, GLFont font) {
	content = new char[lengthInChars];
	displays = new CharDisplay[lengthInChars];
	this.font = font;
	for (int i = 0; i < lengthInChars; i++) {
	    content[i] = 'X';
	    displays[i] = new CharDisplay(tr, grid, glSize, font);
	    displays[i].setChar('X');
	    grid.add(displays[i]);
	}// end for(lengthInChars)

	this.glSize = glSize;
	updatePositions();
    }// end LineDisplay(...)

    public void setContent(String content) {
	for (int i = 0; i < this.content.length; i++) {
	    char newContent=0;
	    if (i < content.length()) {
		final char c = content.charAt(i);
		if(c>31 || c<127)
		    newContent = content.charAt(i);
	    }
	    this.content[i] = newContent;
	    displays[i].setChar(newContent);
	}// end for(length)
	updatePositions();
    }// end setContent(...)

    private void updatePositions() {
	final double[] charPosition = Arrays.copyOf(position, 3);
	totGlLen = 0;
	// Determine total length;
	for (int i = 0; i < displays.length; i++) {
	    char _content = content[i];
	    if (_content != 0) {
		final double progress = ((double) glSize)
			* font.glWidthOf(_content) * 1.1;// 1.1 fudge factor for
							 // space between
							 // letters
		totGlLen += progress;
	    }
	}// end for(displays)
	if (centered)
	    charPosition[0] -= totGlLen / 2.;
	for (int i = 0; i < displays.length; i++) {
	    final double[] dispPos = displays[i].getPosition();
{'fraction_non_alphanumeric': 0.18335993615323223, 'fraction_numerical': 0.013567438148443736, 'mean_word_length': 3.3402597402597403, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2361655', 'n_tokens_mistral': 1707, 'n_tokens_neox': 1528, 'n_words': 456}