<commit_before>package net.kiberion.swampmachine.assets;

import java.nio.file.Path;

import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;

import lombok.Getter;
import lombok.Setter;
import net.kiberion.swampmachine.styling.StyleFactory;

/**
 * Ui manager. Currently just initializes skins; Note that this implementation
 * will be replaced with using external one. This class is meant to be used
 * statically, because it stores information that is used by separate UI
 * elements, which wouldn't participate in injection.
 * 
 * @author caryoscelus
 */
public class UiManager {

    public static final String BLANK_IMAGE = "BLANK";
    public StyleFactory fontGenerator = new StyleFactory();

    private static UiManager _instance;

    public static UiManager instance() {
        if (_instance == null) {
            _instance = new UiManager();
        }
        return _instance;
    }

    @Getter
    @Setter
    protected Skin defaultSkin;

    @Getter
    @Setter
    protected Skin transparentSkin;

    protected TextureAtlas defaultAtlas;

    @Getter
    protected AssetManager assetManager;

    /**
     * Load skin from json file.
     * 
     * @param f
     *            FileHandle containing json skin
     */
    public void loadSkin(FileHandle f) {
        Skin skin = new Skin(f);
        defaultSkin = skin;
    }

    public void loadTransparentSkin(FileHandle f) {
        Skin skin = new Skin(f);
        transparentSkin = skin;
    }

    public void setAtlas(TextureAtlas setAtlas) {
        defaultAtlas = setAtlas;
        setFiltering();
    }

    public void setFiltering() {
        // for (Texture texture: defaultAtlas.getTextures()) {
        // texture.setFilter(Texture.TextureFilter.Linear,
        // Texture.TextureFilter.Linear);
        // }
    }

    public TextureAtlas atlas() {
        return defaultAtlas;
    }

    public void setAssetManager(AssetManager assets) {
        if (assetManager != null) {
            throw new IllegalStateException("Asset manager was already set.");
        }
        this.assetManager = assets;
    }

    public TextureAtlas.AtlasRegion getImage(String id) {
        if (!id.equals(BLANK_IMAGE)) {

            TextureAtlas.AtlasRegion region = atlas().findRegion(id);

            if (region == null) {
                // Log.warn("No image in atlas: " + id);
            }

            return region;
        } else {
            return null;
        }
    }

    public static void reset() {
        _instance = null;
    }

    public String getPathForAssetManager(Path path) {
        return path.toString().replace("\\", "/");
    }

}
<commit_msg>Add ToDo for old code.<commit_after>package net.kiberion.swampmachine.assets;

import java.nio.file.Path;

import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;

import lombok.Getter;
import lombok.Setter;
import net.kiberion.swampmachine.styling.StyleFactory;

/**
 * Ui manager. Currently just initializes skins; Note that this implementation
 * will be replaced with using external one. This class is meant to be used
 * statically, because it stores information that is used by separate UI
 * elements, which wouldn't participate in injection.
 * 
 * @author caryoscelus
 */

//ToDo Very old code that should definitely be reviewed and rewritten
public class UiManager {

    public static final String BLANK_IMAGE = "BLANK";
    public StyleFactory fontGenerator = new StyleFactory();

    private static UiManager _instance;

    public static UiManager instance() {
        if (_instance == null) {
            _instance = new UiManager();
        }
        return _instance;
    }

    @Getter
    @Setter
    protected Skin defaultSkin;

    @Getter
    @Setter
    protected Skin transparentSkin;

    protected TextureAtlas defaultAtlas;

    @Getter
    protected AssetManager assetManager;

    /**
     * Load skin from json file.
     * 
     * @param f
     *            FileHandle containing json skin
     */
    public void loadSkin(FileHandle f) {
        Skin skin = new Skin(f);
        defaultSkin = skin;
    }

    public void loadTransparentSkin(FileHandle f) {
        Skin skin = new Skin(f);
        transparentSkin = skin;
    }

    public void setAtlas(TextureAtlas setAtlas) {
        defaultAtlas = setAtlas;
        setFiltering();
    }

    public void setFiltering() {
        // for (Texture texture: defaultAtlas.getTextures()) {
        // texture.setFilter(Texture.TextureFilter.Linear,
        // Texture.TextureFilter.Linear);
        // }
    }

    public TextureAtlas atlas() {
        return defaultAtlas;
    }

    public void setAssetManager(AssetManager assets) {
        if (assetManager != null) {
            throw new IllegalStateException("Asset manager was already set.");
        }
        this.assetManager = assets;
    }

    public TextureAtlas.AtlasRegion getImage(String id) {
        if (!id.equals(BLANK_IMAGE)) {
            return atlas().findRegion(id);
        } else {
            return null;
        }
    }

    public static void reset() {
        _instance = null;
    }

    public String getPathForAssetManager(Path path) {
        return path.toString().replace("\\", "/");
    }

}

{'fraction_non_alphanumeric': 0.09064327485380116, 'fraction_numerical': 0.0007309941520467836, 'mean_word_length': 2.4399748585795096, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '379223', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1548, 'n_words': 424}