<commit_before>package obvious.prefuse.view;

import java.util.Map;

import javax.swing.JComponent;

import obvious.data.Network;
import obvious.data.Table;
import obvious.data.util.Predicate;
import obvious.prefuse.viz.PrefuseObviousVisualization;
import obvious.prefuse.viz.PrefuseVisualizationFactory;
import obvious.view.JView;
import obvious.viz.Visualization;

/**
 * An implementation of JView interface for prefuse.
 * @author Hemery
 *
 */
@SuppressWarnings("serial")
public class PrefuseObviousView extends JView {

  /**
   * Backing prefuse "view".
   */
  private prefuse.Display display;

  /**
   * Visualization backing this view.
   */
  private Visualization backingVis;

  /**
   * Constructor.
   * @param vis an Obvious Visualization
   * @param predicate an obvious predicate
   * @param tech visualization technique name
   * @param param parameters for the visualization
   */
  public PrefuseObviousView(Visualization vis, Predicate predicate,
      String tech, Map<String, Object> param) {
    if (vis.getUnderlyingImpl(prefuse.Visualization.class) != null) {
      this.backingVis = vis;
    } else {
      PrefuseVisualizationFactory factory = new PrefuseVisualizationFactory();
      if (vis.getData() instanceof Table) {
        this.backingVis = factory.createVisualization(
          (Table) vis.getData(), predicate, tech, param);
      } else if (vis.getData() instanceof Network) {
        this.backingVis = factory.createVisualization(
            (Network) vis.getData(), predicate, "default", param);
      }
    }
    display = new prefuse.Display(
        (prefuse.Visualization) backingVis.getUnderlyingImpl(
            prefuse.Visualization.class));
  }

  /**
   * Gets the Visualization backing this view.
   * @return the Visualization backing this view
   */
  public Visualization getVisualization() {
    return backingVis;
  }

  @Override
  public JComponent getViewJComponent() {
    return display;
  }

}<commit_msg>[obvious-prefuse] Updated version of PrefuseObviousView class.<commit_after>package obvious.prefuse.view;

import java.util.Map;

import javax.swing.JComponent;

import obvious.ObviousRuntimeException;
import obvious.data.Network;
import obvious.data.Table;
import obvious.data.util.Predicate;
import obvious.prefuse.viz.PrefuseObviousVisualization;
import obvious.prefuse.viz.PrefuseVisualizationFactory;
import obvious.view.JView;
import obvious.view.event.ViewListener;
import obvious.viz.Visualization;

/**
 * An implementation of JView interface for prefuse.
 * @author Hemery
 *
 */
@SuppressWarnings("serial")
public class PrefuseObviousView extends JView {

  /**
   * Backing prefuse "view".
   */
  private prefuse.Display display;

  /**
   * Visualization backing this view.
   */
  private Visualization backingVis;

  /**
   * Constructor.
   * @param vis an Obvious Visualization
   * @param predicate an obvious predicate
   * @param tech visualization technique name
   * @param param parameters for the visualization
   */
  public PrefuseObviousView(Visualization vis, Predicate predicate,
      String tech, Map<String, Object> param) {
    if (vis.getUnderlyingImpl(prefuse.Visualization.class) != null) {
      this.backingVis = vis;
    } else {
      PrefuseVisualizationFactory factory = new PrefuseVisualizationFactory();
      if (vis.getData() instanceof Table) {
        this.backingVis = factory.createVisualization(
          (Table) vis.getData(), predicate, tech, param);
      } else if (vis.getData() instanceof Network) {
        this.backingVis = factory.createVisualization(
            (Network) vis.getData(), predicate, "default", param);
      }
    }
    display = new prefuse.Display(
        (prefuse.Visualization) backingVis.getUnderlyingImpl(
            prefuse.Visualization.class));
  }

  /**
   * Gets the Visualization backing this view.
   * @return the Visualization backing this view
   */
  public Visualization getVisualization() {
    return backingVis;
  }

  @Override
  public JComponent getViewJComponent() {
    return display;
  }

  @Override
  public void addListener(ViewListener lstnr) {
    if (lstnr.getUnderlyingImpl(prefuse.controls.Control.class) != null) {
      this.getViewListeners().add(lstnr);
      this.display.addControlListener(
          (prefuse.controls.Control) lstnr.getUnderlyingImpl(
              prefuse.controls.Control.class));
    } else {
      throw new ObviousRuntimeException("The following renderer : "
          + lstnr.toString() + " is not supported");
    }
  }

  @Override
  public boolean removeListener(ViewListener listener) {
    return this.getViewListeners().remove(listener);
  }

}
{'fraction_non_alphanumeric': 0.09937888198757763, 'fraction_numerical': 0.0, 'mean_word_length': 3.5120772946859904, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6745850', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1318, 'n_words': 323}