<commit_before>package gcm2sbml.gui.modelview.movie.visualizations.component;

import java.awt.Color;
import java.util.ArrayList;
import java.util.HashMap;

import parser.TSDParser;

import gcm2sbml.gui.modelview.movie.visualizations.ColorScheme;

/**
 * Components can be colored based on multiple color schemes relating to multiple of their sub-species.
 * This class represents one of the color schemes for one sub-species.
 * @author Tyler
 *
 */
public class ComponentSchemePart {

	private String tsdKey;
	private ColorScheme colorScheme;
	

	public String getTsdKey() {
		return tsdKey;
	}

	public void setTsdKey(String tsdKey) {
		this.tsdKey = tsdKey;
	}

	public ColorScheme getColorScheme() {
		return colorScheme;
	}

	public void setColorScheme(ColorScheme colorScheme) {
		this.colorScheme = colorScheme;
	}

	public ComponentSchemePart(){
		tsdKey = null;
		colorScheme = new ColorScheme();
	}
	
	public Color getColor(HashMap<String, ArrayList<Double>> dataHash, int frameIndex){
		
		String key = getTsdKey();
		double val = dataHash.get(key).get(frameIndex);
		return colorScheme.getColor(val);
	}
}<commit_msg>fixed null pointer error that happened if you didn't have a tsd key chosen for a component.<commit_after>package gcm2sbml.gui.modelview.movie.visualizations.component;

import java.awt.Color;
import java.util.ArrayList;
import java.util.HashMap;

import parser.TSDParser;

import gcm2sbml.gui.modelview.movie.visualizations.ColorScheme;

/**
 * Components can be colored based on multiple color schemes relating to multiple of their sub-species.
 * This class represents one of the color schemes for one sub-species.
 * @author Tyler
 *
 */
public class ComponentSchemePart {

	private String tsdKey;
	private ColorScheme colorScheme;
	

	public String getTsdKey() {
		return tsdKey;
	}

	public void setTsdKey(String tsdKey) {
		this.tsdKey = tsdKey;
	}

	public ColorScheme getColorScheme() {
		return colorScheme;
	}

	public void setColorScheme(ColorScheme colorScheme) {
		this.colorScheme = colorScheme;
	}

	public ComponentSchemePart(){
		tsdKey = null;
		colorScheme = new ColorScheme();
	}
	
	public Color getColor(HashMap<String, ArrayList<Double>> dataHash, int frameIndex){
		
		String key = getTsdKey();
		// if the user hasn't chosen a species, don't use this color.
		if(key == null)
			return null;
		double val = dataHash.get(key).get(frameIndex);
		return colorScheme.getColor(val);
	}
}
{'fraction_non_alphanumeric': 0.09072249589490969, 'fraction_numerical': 0.0016420361247947454, 'mean_word_length': 4.526077097505669, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3527429', 'n_tokens_mistral': 799, 'n_tokens_neox': 736, 'n_words': 217}