<commit_before>package org.caleydo.view.matchmaker;

import gleem.linalg.Vec3f;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;

import javax.media.opengl.GL;

import org.caleydo.core.command.ECommandType;
import org.caleydo.core.command.view.opengl.CmdCreateView;
import org.caleydo.core.data.collection.ISet;
import org.caleydo.core.data.mapping.EIDCategory;
import org.caleydo.core.data.mapping.EIDType;
import org.caleydo.core.data.selection.ContentGroupList;
import org.caleydo.core.data.selection.ContentSelectionManager;
import org.caleydo.core.data.selection.ContentVAType;
import org.caleydo.core.data.selection.ContentVirtualArray;
import org.caleydo.core.data.selection.ESelectionCommandType;
import org.caleydo.core.data.selection.Group;
import org.caleydo.core.data.selection.SelectionCommand;
import org.caleydo.core.data.selection.SelectionType;
import org.caleydo.core.data.selection.SelectionTypeEvent;
import org.caleydo.core.data.selection.delta.ISelectionDelta;
import org.caleydo.core.data.selection.delta.SelectionDelta;
import org.caleydo.core.data.selection.delta.SelectionDeltaItem;
import org.caleydo.core.manager.IEventPublisher;
import org.caleydo.core.manager.IGeneralManager;
import org.caleydo.core.manager.ISetBasedDataDomain;
import org.caleydo.core.manager.event.view.SelectionCommandEvent;
import org.caleydo.core.manager.event.view.storagebased.SelectionUpdateEvent;
import org.caleydo.core.manager.general.GeneralManager;
import org.caleydo.core.manager.picking.EPickingMode;
import org.caleydo.core.manager.picking.EPickingType;
import org.caleydo.core.manager.picking.PickingManager;
import org.caleydo.core.view.opengl.camera.EProjectionMode;
import org.caleydo.core.view.opengl.canvas.AGLView;
import org.caleydo.core.view.opengl.canvas.EDetailLevel;
import org.caleydo.core.view.opengl.canvas.remote.IGLRemoteRenderingView;
import org.caleydo.core.view.opengl.mouse.GLMouseListener;
import org.caleydo.core.view.opengl.util.ColorUtil;
import org.caleydo.core.view.opengl.util.overlay.infoarea.GLInfoAreaManager;
import org.caleydo.core.view.opengl.util.texture.TextureManager;
import org.caleydo.view.heatmap.dendrogram.GLDendrogram;
import org.caleydo.view.heatmap.heatmap.GLHeatMap;
import org.caleydo.view.heatmap.heatmap.template.ComparerDetailTemplate;
import org.caleydo.view.matchmaker.layout.AHeatMapLayout;
import org.caleydo.view.matchmaker.layout.HeatMapLayoutDetailViewRight;
import org.caleydo.view.matchmaker.rendercommand.IHeatMapRenderCommand;
import org.caleydo.view.matchmaker.state.ACompareViewState;

/**
 * 
 * @author <NAME>
 * @author <NAME>
 * 
 */
public class HeatMapWrapper {

	private static final String SELECTION_TYPE_NAME = "Compare Type ";

	private static int selectionTypeNumber = 0;

	private HeatMapOverview overview;
	private ISet set;

	private IGeneralManager generalManager;
	private ContentVirtualArray contentVA;
	private AHeatMapLayout layout;
	private HashMap<Integer, GLHeatMap> hashHeatMaps;
	private HashMap<Group, Boolean> selectedGroups;
	private GLDendrogram<ContentGroupList> dendrogram;
	private boolean isNewSelection;
	private boolean isInitialized;
	private boolean isNewSet;
	private int id;
	private int activeHeatMapID;

	private AGLView glParentView;
	private ACompareViewState state;
	private GLInfoAreaManager infoAreaManager;
	private ISetBasedDataDomain dataDomain;
	private IGLRemoteRenderingView parentView;

	// private SelectionUpdateListener selectionUpdateListener;
	private IEventPublisher eventPublisher;
	private ContentSelectionManager contentSelectionManager;

	private boolean useSorting = true;
	private boolean useZoom = false;
	private boolean useFishEye = false;

	public HeatMapWrapper(int id, AHeatMapLayout layout, AGLView glParentView,
			GLInfoAreaManager infoAreaManager, ISetBasedDataDomain dataDomain,
			IGLRemoteRenderingView parentView, ACompareViewState state) {

		generalManager = GeneralManager.get();
		overview = new HeatMapOverview(layout);
		hashHeatMaps = new HashMap<Integer, GLHeatMap>();
		// hashHeatMapPositions = new HashMap<Integer, Vec3f>();
		selectedGroups = new HashMap<Group, Boolean>();

		this.layout = layout;
		this.id = id;
		this.glParentView = glParentView;
		this.infoAreaManager = infoAreaManager;
		this.dataDomain = dataDomain;
		this.parentView = parentView;
		this.state = state;

		isNewSelection = false;
		eventPublisher = GeneralManager.get().getEventPublisher();
		contentSelectionManager = dataDomain.getContentSelectionManager();
		// contentSelectionManager.addTypeToDeltaBlacklist(activeHeatMapSelectionType);
		activeHeatMapID = -1;
	}

	private GLHeatMap createHeatMap(GL gl, GLMouseListener glMouseListener) {

		CmdCreateView cmdView = (CmdCreateView) generalManager.getCommandManager()
				.createCommandByType(ECommandType.CREATE_GL_VIEW);
		cmdView.setViewID(GLHeatMap.VIEW_ID);

		cmdView.setAttributes(EProjectionMode.ORTHOGRAPHIC, 0, 50, 0, 50, -20, 20, -1);

		cmdView.doCommand();

		GLHeatMap heatMap = (GLHeatMap) cmdView.getCreatedObject();
		heatMap.setRemoteRenderingGLView(parentView);
		heatMap.setSet(set);
		heatMap.setDataDomain(dataDomain);
		heatMap.setContentVAType(ContentVAType.CONTENT_EMBEDDED_HM);

		if (layout instanceof HeatMapLayoutDetailViewRight)
			heatMap.setRenderTemplate(new ComparerDetailTemplate(false));
		else
			heatMap.setRenderTemplate(new ComparerDetailTemplate(true));

		heatMap.initData();
		heatMap.setDetailLevel(EDetailLevel.MEDIUM);
		heatMap.initRemote(gl, glParentView, glMouseListener, infoAreaManager);
		heatMap.setSendClearSelectionsEvent(true);
		heatMap.useFishEye(false);

		return heatMap;
	}

	private void createDendrogram(GL gl, GLMouseListener glMouseListener) {

		CmdCreateView cmdView = (CmdCreateView) generalManager.getCommandManager()
				.createCommandByType(ECommandType.CREATE_GL_VIEW);
		cmdView.setViewID(GLDendrogram.VIEW_ID + ".horizontal");

		cmdView.setAttributes(EProjectionMode.ORTHOGRAPHIC, 0, 50, 0, 50, -20, 20, -1);

		cmdView.doCommand();

		dendrogram = (GLDendrogram<ContentGroupList>) cmdView.getCreatedObject();
		dendrogram.setDataDomain(dataDomain);
		dendrogram.setRemoteRenderingGLView(parentView);
		dendrogram.setSet(set);<commit_msg>fixed some things in matchmaker<commit_after>package org.caleydo.view.matchmaker;

import gleem.linalg.Vec3f;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;

import javax.media.opengl.GL;

import org.caleydo.core.command.ECommandType;
import org.caleydo.core.command.view.opengl.CmdCreateView;
import org.caleydo.core.data.collection.ISet;
import org.caleydo.core.data.mapping.EIDCategory;
import org.caleydo.core.data.mapping.EIDType;
import org.caleydo.core.data.selection.ContentGroupList;
import org.caleydo.core.data.selection.ContentSelectionManager;
import org.caleydo.core.data.selection.ContentVAType;
import org.caleydo.core.data.selection.ContentVirtualArray;
import org.caleydo.core.data.selection.ESelectionCommandType;
import org.caleydo.core.data.selection.Group;
import org.caleydo.core.data.selection.SelectionCommand;
import org.caleydo.core.data.selection.SelectionType;
import org.caleydo.core.data.selection.SelectionTypeEvent;
import org.caleydo.core.data.selection.delta.ISelectionDelta;
import org.caleydo.core.data.selection.delta.SelectionDelta;
import org.caleydo.core.data.selection.delta.SelectionDeltaItem;
import org.caleydo.core.manager.IEventPublisher;
import org.caleydo.core.manager.IGeneralManager;
import org.caleydo.core.manager.ISetBasedDataDomain;
import org.caleydo.core.manager.event.view.SelectionCommandEvent;
import org.caleydo.core.manager.event.view.storagebased.SelectionUpdateEvent;
import org.caleydo.core.manager.general.GeneralManager;
import org.caleydo.core.manager.picking.EPickingMode;
import org.caleydo.core.manager.picking.EPickingType;
import org.caleydo.core.manager.picking.PickingManager;
import org.caleydo.core.view.opengl.camera.EProjectionMode;
import org.caleydo.core.view.opengl.canvas.AGLView;
import org.caleydo.core.view.opengl.canvas.EDetailLevel;
import org.caleydo.core.view.opengl.canvas.remote.IGLRemoteRenderingView;
import org.caleydo.core.view.opengl.mouse.GLMouseListener;
import org.caleydo.core.view.opengl.util.ColorUtil;
import org.caleydo.core.view.opengl.util.overlay.infoarea.GLInfoAreaManager;
import org.caleydo.core.view.opengl.util.texture.TextureManager;
import org.caleydo.view.heatmap.dendrogram.GLDendrogram;
import org.caleydo.view.heatmap.heatmap.GLHeatMap;
import org.caleydo.view.heatmap.heatmap.template.ComparerDetailTemplate;
import org.caleydo.view.matchmaker.layout.AHeatMapLayout;
import org.caleydo.view.matchmaker.layout.HeatMapLayoutDetailViewRight;
import org.caleydo.view.matchmaker.rendercommand.IHeatMapRenderCommand;
import org.caleydo.view.matchmaker.state.ACompareViewState;

/**
 * 
 * @author <NAME>
 * @author <NAME>
 * 
 */
public class HeatMapWrapper {

	private static final String SELECTION_TYPE_NAME = "Compare Type ";

	private static int selectionTypeNumber = 0;

	private HeatMapOverview overview;
	private ISet set;

	private IGeneralManager generalManager;
	private ContentVirtualArray contentVA;
	private AHeatMapLayout layout;
	private HashMap<Integer, GLHeatMap> hashHeatMaps;
	private HashMap<Group, Boolean> selectedGroups;
	private GLDendrogram<ContentGroupList> dendrogram;
	private boolean isNewSelection;
	private boolean isInitialized;
	private boolean isNewSet;
	private int id;
	private int activeHeatMapID;

	private AGLView glParentView;
	private ACompareViewState state;
	private GLInfoAreaManager infoAreaManager;
	private ISetBasedDataDomain dataDomain;
	private IGLRemoteRenderingView parentView;

	// private SelectionUpdateListener selectionUpdateListener;
	private IEventPublisher eventPublisher;
	private ContentSelectionManager contentSelectionManager;

	private boolean useSorting = true;
	private boolean useZoom = false;
	private boolean useFishEye = false;

	public HeatMapWrapper(int id, AHeatMapLayout layout, AGLView glParentView,
			GLInfoAreaManager infoAreaManager, ISetBasedDataDomain dataDomain,
			IGLRemoteRenderingView parentView, ACompareViewState state) {

		generalManager = GeneralManager.get();
		overview = new HeatMapOverview(layout);
		hashHeatMaps = new HashMap<Integer, GLHeatMap>();
		// hashHeatMapPositions = new HashMap<Integer, Vec3f>();
		selectedGroups = new HashMap<Group, Boolean>();

		this.layout = layout;
		this.id = id;
		this.glParentView = glParentView;
		this.infoAreaManager = infoAreaManager;
		this.dataDomain = dataDomain;
		this.parentView = parentView;
		this.state = state;

		isNewSelection = false;
		eventPublisher = GeneralManager.get().getEventPublisher();
		contentSelectionManager = dataDomain.getContentSelectionManager();
		// contentSelectionManager.addTypeToDeltaBlacklist(activeHeatMapSelectionType);
		activeHeatMapID = -1;
	}

	private GLHeatMap createHeatMap(GL gl, GLMouseListener glMouseListener) {

		CmdCreateView cmdView = (CmdCreateView) generalManager.getCommandManager()
				.createCommandByType(ECommandType.CREATE_GL_VIEW);
		cmdView.setViewID(GLHeatMap.VIEW_ID);

		cmdView.setAttributes(EProjectionMode.ORTHOGRAPHIC, 0, 50, 0, 50, -20, 20, -1);

		cmdView.doCommand();

		GLHeatMap heatMap = (GLHeatMap) cmdView.getCreatedObject();
		heatMap.setRemoteRenderingGLView(parentView);
		heatMap.setDataDomain(dataDomain);
		heatMap.setSet(set);
	
		heatMap.setContentVAType(ContentVAType.CONTENT_EMBEDDED_HM);

		if (layout instanceof HeatMapLayoutDetailViewRight)
			heatMap.setRenderTemplate(new ComparerDetailTemplate(false));
		else
			heatMap.setRenderTemplate(new ComparerDetailTemplate(true));

		heatMap.initData();
		heatMap.setDetailLevel(EDetailLevel.MEDIUM);
		heatMap.initRemote(gl, glParentView, glMouseListener, infoAreaManager);
		heatMap.setSendClearSelectionsEvent(true);
		heatMap.useFishEye(false);

		return heatMap;
	}

	private void createDendrogram(GL gl, GLMouseListener glMouseListener) {

		CmdCreateView cmdView = (CmdCreateView) generalManager.getCommandManager()
				.createCommandByType(ECommandType.CREATE_GL_VIEW);
		cmdView.setViewID(GLDendrogram.VIEW_ID + ".horizontal");

		cmdView.setAttributes(EProjectionMode.ORTHOGRAPHIC, 0, 50, 0, 50, -20, 20, -1);

		cmdView.doCommand();

		dendrogram = (GLDendrogram<ContentGroupList>) cmdView.getCreatedObject();
		dendrogram.setDataDomain(dataDomain);
		dendrogram.setRemoteRenderingGLView(parentView);
		dendrogram.setSet(set);
{'fraction_non_alphanumeric': 0.09525331628575995, 'fraction_numerical': 0.004155346012466038, 'mean_word_length': 6.5255562236921225, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '4673171', 'n_tokens_mistral': 4348, 'n_tokens_neox': 3970, 'n_words': 645}