<commit_before>package de.lessvoid.nifty.effects;

import java.util.LinkedList;
import java.util.logging.Logger;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.effects.Falloff.HoverFalloffConstraint;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.render.NiftyRenderEngine;
import de.lessvoid.nifty.spi.time.TimeProvider;
import de.lessvoid.nifty.tools.time.TimeInterpolator;

/**
 * An effect can be active or not and is always attached to one element. It has a TimeInterpolator that manages the life
 * time of the effect. The actual effect implementation is done be EffectImpl implementations.
 *
 * @author void
 */
public class Effect {
  private Logger log = Logger.getLogger(Effect.class.getName());
  private EffectEventId effectEventId;
  private boolean active;
  private Element element;
  private TimeInterpolator timeInterpolator;
  private EffectImpl effectImpl;
  private EffectProperties parameter;
  private boolean post;
  private boolean overlay;
  private String alternateEnable;
  private String alternateDisable;
  private String alternate;
  private String customKey;
  private boolean inherit;
  private Nifty nifty;
  private boolean hoverEffect;
  private boolean infiniteEffect;
  private Falloff falloff;
  private EffectEvents effectEvents;
  private boolean neverStopRendering;
  private boolean customFlag;

  public Effect(
      final Nifty niftyParam,
      final boolean inheritParam,
      final boolean postParam,
      final boolean overlayParam,
      final String alternateEnableParam,
      final String alternateDisableParam,
      final String customKeyParam,
      final boolean neverStopRenderingParam,
      final EffectEventId effectEventIdParam) {
    nifty = niftyParam;
    inherit = inheritParam;
    post = postParam;
    overlay = overlayParam;
    active = false;
    alternateEnable = alternateEnableParam;
    alternateDisable = alternateDisableParam;
    alternate = null;
    customKey = customKeyParam;
    effectEventId = effectEventIdParam;
    hoverEffect = false;
    infiniteEffect = false;
    neverStopRendering = neverStopRenderingParam;
    effectEvents = new EffectEvents();
    customFlag = false;
  }

  public void enableHover(final Falloff falloffParameter) {
    hoverEffect = true;
    falloff = falloffParameter;
  }

  public void enableInfinite() {
    infiniteEffect = true;
  }

  public void init(
      final Element elementParam,
      final EffectImpl effectImplParam,
      final EffectProperties parameterParam,
      final TimeProvider timeParam,
      final LinkedList<Object> controllers) {
    element = elementParam;
    effectImpl = effectImplParam;
    parameter = parameterParam;
    parameter.put("effectEventId", effectEventId);
    timeInterpolator = new TimeInterpolator(parameter, timeParam, infiniteEffect);
    effectEvents.init(nifty, controllers, parameter);
    customFlag = false;
  }

  public boolean start(final String alternate, final String customKey) {
    this.alternate = alternate;
    if (!canStartEffect(alternate, customKey)) {
      return false;
    }

    log.info("starting effect [" + getStateString() + "] with customKey [" + customKey + "]");
    internalStart();
    return true;
  }

  private void internalStart() {
    active = true;
    timeInterpolator.start();
    effectEvents.onStartEffect(parameter);
    effectImpl.activate(nifty, element, parameter);<commit_msg>#3489461: Hint effect requires interact tag<commit_after>package de.lessvoid.nifty.effects;

import java.util.LinkedList;
import java.util.logging.Logger;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.effects.Falloff.HoverFalloffConstraint;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.render.NiftyRenderEngine;
import de.lessvoid.nifty.spi.time.TimeProvider;
import de.lessvoid.nifty.tools.time.TimeInterpolator;

/**
 * An effect can be active or not and is always attached to one element. It has a TimeInterpolator that manages the life
 * time of the effect. The actual effect implementation is done be EffectImpl implementations.
 *
 * @author void
 */
public class Effect {
  private Logger log = Logger.getLogger(Effect.class.getName());
  private EffectEventId effectEventId;
  private boolean active;
  private Element element;
  private TimeInterpolator timeInterpolator;
  private EffectImpl effectImpl;
  private EffectProperties parameter;
  private boolean post;
  private boolean overlay;
  private String alternateEnable;
  private String alternateDisable;
  private String alternate;
  private String customKey;
  private boolean inherit;
  private Nifty nifty;
  private boolean hoverEffect;
  private boolean infiniteEffect;
  private Falloff falloff;
  private EffectEvents effectEvents;
  private boolean neverStopRendering;
  private boolean customFlag;

  public Effect(
      final Nifty niftyParam,
      final boolean inheritParam,
      final boolean postParam,
      final boolean overlayParam,
      final String alternateEnableParam,
      final String alternateDisableParam,
      final String customKeyParam,
      final boolean neverStopRenderingParam,
      final EffectEventId effectEventIdParam) {
    nifty = niftyParam;
    inherit = inheritParam;
    post = postParam;
    overlay = overlayParam;
    active = false;
    alternateEnable = alternateEnableParam;
    alternateDisable = alternateDisableParam;
    alternate = null;
    customKey = customKeyParam;
    effectEventId = effectEventIdParam;
    hoverEffect = false;
    infiniteEffect = false;
    neverStopRendering = neverStopRenderingParam;
    effectEvents = new EffectEvents();
    customFlag = false;
  }

  public void enableHover(final Falloff falloffParameter) {
    hoverEffect = true;
    falloff = falloffParameter;
  }

  public void enableInfinite() {
    infiniteEffect = true;
  }

  public void init(
      final Element elementParam,
      final EffectImpl effectImplParam,
      final EffectProperties parameterParam,
      final TimeProvider timeParam,
      final LinkedList<Object> controllers) {
    element = elementParam;
    effectImpl = effectImplParam;
    parameter = parameterParam;
    parameter.put("effectEventId", effectEventId);
    timeInterpolator = new TimeInterpolator(parameter, timeParam, infiniteEffect);
    effectEvents.init(nifty, controllers, parameter);
    customFlag = false;

    if (hoverEffect) {
      element.setVisibleToMouseEvents(true);
    }
  }

  public boolean start(final String alternate, final String customKey) {
    this.alternate = alternate;
    if (!canStartEffect(alternate, customKey)) {
      return false;
    }

    log.info("starting effect [" + getStateString() + "] with customKey [" + customKey + "]");
    internalStart();
    return true;
  }

  private void internalStart() {
    active = true;
    timeInterpolator.start();
    effectEvents.onStartEffect(parameter);
    effectImpl.activate(nifty, element, parameter);
{'fraction_non_alphanumeric': 0.07152089616544594, 'fraction_numerical': 0.0010053138015223323, 'mean_word_length': 4.042722664735699, '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': '5216173', 'n_tokens_mistral': 1897, 'n_tokens_neox': 1873, 'n_words': 539}