<commit_before>/*******************************************************************************
 * Caleydo - Visualization for Molecular Biology - http://caleydo.org
 * Copyright (c) The Caleydo Team. All rights reserved.
 * Licensed under the new BSD license, available at http://caleydo.org/license
 *******************************************************************************/
package org.caleydo.view.domino.internal;

import java.util.Collection;
import java.util.Set;

import org.caleydo.core.data.collection.EDimension;
import org.caleydo.core.util.base.ILabeled;
import org.caleydo.core.util.base.Labels;
import org.caleydo.view.domino.api.model.EDirection;
import org.caleydo.view.domino.api.model.typed.TypedGroupList;
import org.caleydo.view.info.dataset.spi.IDataSetItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ExpandBar;
import org.eclipse.swt.widgets.ExpandItem;

import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Multimap;

/**
 * @author <NAME>
 *
 */
public class NodeDataItem implements IDataSetItem {
	private static volatile NodeDataItem instance;
	private ExpandItem item;
	private StyledText text;

	/**
	 *
	 */
	public NodeDataItem() {
		instance = this;
	}

	@Override
	public ExpandItem create(ExpandBar expandBar) {
		this.item = new ExpandItem(expandBar, SWT.WRAP);
		item.setText("Domino Node Infos");
		item.setExpanded(false);
		Composite c = new Composite(expandBar, SWT.NONE);
		c.setLayout(new GridLayout(1, false));

		text = new StyledText(c, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP);
		text.setBackgroundMode(SWT.INHERIT_FORCE);
		text.setText("No Selection");
		GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
		gd.heightHint = 60;
		text.setLayoutData(gd);
		text.setEditable(false);
		text.setWordWrap(true);

		// transformationLabel.set
		// transformationLabel.();

		item.setControl(c);
		item.setHeight(c.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
		return item;
	}

	/**
	 * @param mouseOvers
	 * @param selections
	 */
	private void updateImpl(String text) {
		this.text.setText(text);
	}

	public static void update(final Set<NodeGroup> mouseOvers, final Set<NodeGroup> selections) {
		final NodeDataItem i = instance;
		if (i == null)
			return;
		Set<NodeGroup> toShow = selections;
		if (!mouseOvers.isEmpty()) {
			toShow = mouseOvers;
		}

		String text;
		if (toShow.isEmpty()) {
			text = "No Selection";
		} else {
			Multimap<Node, NodeGroup> nodes = HashMultimap.create();
			for (NodeGroup group : toShow) {
				Node n = group.getNode();
				nodes.put(n, group);
			}<commit_msg>bugfixing<commit_after>/*******************************************************************************
 * Caleydo - Visualization for Molecular Biology - http://caleydo.org
 * Copyright (c) The Caleydo Team. All rights reserved.
 * Licensed under the new BSD license, available at http://caleydo.org/license
 *******************************************************************************/
package org.caleydo.view.domino.internal;

import java.util.Collection;
import java.util.Set;

import org.caleydo.core.data.collection.EDimension;
import org.caleydo.core.util.base.ILabeled;
import org.caleydo.core.util.base.Labels;
import org.caleydo.view.domino.api.model.EDirection;
import org.caleydo.view.domino.api.model.typed.TypedGroupList;
import org.caleydo.view.info.dataset.spi.IDataSetItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ExpandBar;
import org.eclipse.swt.widgets.ExpandItem;

import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Multimap;

/**
 * @author <NAME>
 *
 */
public class NodeDataItem implements IDataSetItem {
	private static volatile NodeDataItem instance;
	private ExpandItem item;
	private StyledText text;

	/**
	 *
	 */
	public NodeDataItem() {
		instance = this;
	}

	@Override
	public ExpandItem create(ExpandBar expandBar) {
		this.item = new ExpandItem(expandBar, SWT.WRAP);
		item.setText("Domino Node Infos");
		item.setExpanded(false);
		Composite c = new Composite(expandBar, SWT.NONE);
		c.setLayout(new GridLayout(1, false));

		text = new StyledText(c, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP);
		text.setBackgroundMode(SWT.INHERIT_FORCE);
		text.setText("No Selection");
		GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
		gd.heightHint = 60;
		text.setLayoutData(gd);
		text.setEditable(false);
		text.setWordWrap(true);

		// transformationLabel.set
		// transformationLabel.();

		item.setControl(c);
		item.setHeight(c.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
		return item;
	}

	/**
	 * @param mouseOvers
	 * @param selections
	 */
	private void updateImpl(String text) {
		if (this.text.isDisposed()) {
			instance = null;
			return;
		}
		this.text.setText(text);
	}

	public static void update(final Set<NodeGroup> mouseOvers, final Set<NodeGroup> selections) {
		final NodeDataItem i = instance;
		if (i == null)
			return;
		Set<NodeGroup> toShow = selections;
		if (!mouseOvers.isEmpty()) {
			toShow = mouseOvers;
		}

		String text;
		if (toShow.isEmpty()) {
			text = "No Selection";
		} else {
			Multimap<Node, NodeGroup> nodes = HashMultimap.create();
			for (NodeGroup group : toShow) {
				Node n = group.getNode();
				nodes.put(n, group);
			}
{'fraction_non_alphanumeric': 0.17497857754927162, 'fraction_numerical': 0.0010282776349614395, 'mean_word_length': 4.616939364773821, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '2275992', 'n_tokens_mistral': 2115, 'n_tokens_neox': 1921, 'n_words': 387}