<commit_before>package org.basex.gui.view.real;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Transparency;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.basex.data.Data;
import org.basex.gui.GUI;
import org.basex.gui.GUIConstants;
import org.basex.gui.layout.BaseXLayout;
import org.basex.gui.view.View;
import org.basex.query.ChildIterator;
import org.basex.util.IntList;
import org.basex.util.Performance;
import org.basex.util.Token;

/**
 * This class offers a real tree view.
 * @author Workgroup DBIS, University of Konstanz 2005-08, ISC License
 * @author <NAME>, <NAME>
 */
public final class RealView extends View {
  /** Var to show the scrollbar. */
  //private BaseXBar scroll = null;
  /** Horizontal Coords of the pointer. */
  private int pointerx;
  /** Vertical Coords of the pointer. */
  private int pointery;
  /** Current font height. */
  private int fontHeight;
  /** Distance from the node to the border. */
  private final int margin = 3;
  /** Arc Measures for the box. */
  //private final int arcWH = 10;
  /** Vertical Distance between node levels. */
  private final int lvdistance = 30;
  /** Distance of the tree from the top border. */
  private final int topdistance = 20;
  /** Color for element node. */
  private final Color elementColor = Color.BLACK;
  /** Color for attribute node. */
  private final Color attributeColor = Color.GREEN;
  /** Color for attribute node. */
  private final Color commentColor = Color.MAGENTA;
  /** Color for process instruction node. */
  private final Color piColor = Color.ORANGE;
  /** Color for text node. */
  private final Color textColor = Color.CYAN;
  /** multiplier for pre/post values. */
  private final int prePostMulti = 17;
  /** the sum of all size values of a node line. */
  private int sumNodeSizeInLine = 0;
  /** the list of all parent nodes of a node line. */
  private IntList parentList = null;
  /** array with position of the parent node. */
  private HashMap<Integer, Double> parentPos = null;
  /** array of current rectangles. */
  private ArrayList<RealRect[]> rects = null;
  /** nodes in current line. */
  private int rectCount = 0;
  /** current mouse position x. */
  private int mousePosX = -1;
  /** current mouse position y. */
  private int mousePosY = -1;
  /** window width. */
  private int wwidth = -1;
  /** window height. */
  private int wheight = -1;
  /** current focused rect. */
  private RealRect focusedRealRect = null;
  /** current Image of visualization. */
  private BufferedImage realImage = null;

  /**
   * Default Constructor.
   */
  public RealView() {
    super(null);
  }

  @Override
  protected void refreshContext(final boolean more, final boolean quick) {
    repaint();
  }

  @Override
  protected void refreshFocus() {

    repaint();
  }

  @Override
  protected void refreshInit() {
    wwidth = -1;
    wheight = -1;
    realImage = null;
    repaint();
  }

  @Override
  protected void refreshLayout() {

    repaint();
  }

  @Override
  protected void refreshMark() {

    wwidth = -1;
    wheight = -1;
    realImage = null;
    repaint();
  }

  @Override
  protected void refreshUpdate() {
    repaint();
  }

  @Override
  public void paintComponent(final Graphics g) {

    final Data data = GUI.context.data();
    /** Set the paint Component */
    super.paintComponent(g);
    BaseXLayout.antiAlias(g);
    g.setColor(Color.BLACK);
    g.setFont(GUIConstants.font);
    data.doc();

    /** Timer */
    final Performance perf = new Performance();
    perf.initTimer();

    /** Initialize sizes */
    fontHeight = g.getFontMetrics().getHeight();

    /** Initialize the pointer */
    pointerx = getWidth() / 2;
    pointery = topdistance;

    if(windowSizeChanged()) {

      switch(3) {
        case 1:
          drawTree(g, 0, 0, 0, getWidth());
          break;
        case 2:
          drawPrePost(g, 1, 1);
          break;
        case 3:
          temperature(0, g);

      }
    } else {
      g.drawImage(realImage, 0, 0, getWidth(), getHeight(), this);
    }

    if(focusedRealRect != null) {
      RealRect r = focusedRealRect;
      g.drawRect(r.x1, r.y1, r.x2 - r.x1, r.y2 - r.y1);

      final int pre = r.p;
      String s = "";

      if(data.kind(pre) == Data.ELEM) {
        s = Token.string(data.tag(pre));
      } else {
        s = Token.string(data.text(pre));
      }

      for(int y = 0; y < data.attSize(pre, data.kind(pre)) - 1; y++) {
        s += " " + Token.string(data.attName(pre + y + 1)) + "=" + "\""
            + Token.string(data.attValue(pre + y + 1)) + "\" ";
      }

      int w = BaseXLayout.width(g, s);

      g.setColor(Color.WHITE);
      g.fillRect(r.x1, r.y1 - fontHeight, w, fontHeight);
      g.setColor(Color.BLACK);
      g.drawString(s, r.x1, (int) (r.y1 - fontHeight / 4f));
<commit_msg>little update<commit_after>package org.basex.gui.view.real;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Transparency;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.basex.data.Data;
import org.basex.gui.GUI;
import org.basex.gui.GUIConstants;
import org.basex.gui.layout.BaseXLayout;
import org.basex.gui.view.View;
import org.basex.query.ChildIterator;
import org.basex.util.IntList;
import org.basex.util.Performance;
import org.basex.util.Token;

/*
 * This class offers a real tree view.
 * @author Workgroup DBIS, University of Konstanz 2005-08, ISC License
 * @author <NAME>, <NAME>
 */
public final class RealView extends View {
  /** Var to show the scrollbar. */
  //private BaseXBar scroll = null;
  /** Horizontal Coords of the pointer. */
  private int pointerx;
  /** Vertical Coords of the pointer. */
  private int pointery;
  /** Current font height. */
  private int fontHeight;
  /** Distance from the node to the border. */
  private final int margin = 3;
  /** Arc Measures for the box. */
  //private final int arcWH = 10;
  /** Vertical Distance between node levels. */
  private final int lvdistance = 30;
  /** Distance of the tree from the top border. */
  private final int topdistance = 20;
  /** Color for element node. */
  private final Color elementColor = Color.BLACK;
  /** Color for attribute node. */
  private final Color attributeColor = Color.GREEN;
  /** Color for attribute node. */
  private final Color commentColor = Color.MAGENTA;
  /** Color for process instruction node. */
  private final Color piColor = Color.ORANGE;
  /** Color for text node. */
  private final Color textColor = Color.CYAN;
  /** multiplier for pre/post values. */
  private final int prePostMulti = 17;
  /** the sum of all size values of a node line. */
  private int sumNodeSizeInLine = 0;
  /** the list of all parent nodes of a node line. */
  private IntList parentList = null;
  /** array with position of the parent node. */
  private HashMap<Integer, Double> parentPos = null;
  /** array of current rectangles. */
  private ArrayList<RealRect[]> rects = null;
  /** nodes in current line. */
  private int rectCount = 0;
  /** current mouse position x. */
  private int mousePosX = -1;
  /** current mouse position y. */
  private int mousePosY = -1;
  /** window width. */
  private int wwidth = -1;
  /** window height. */
  private int wheight = -1;
  /** current focused rect. */
  private RealRect focusedRealRect = null;
  /** current Image of visualization. */
  private BufferedImage realImage = null;

  /**
   * Default Constructor.
   */
  public RealView() {
    super(null);
  }

  @Override
  protected void refreshContext(final boolean more, final boolean quick) {
    repaint();
  }

  @Override
  protected void refreshFocus() {

    repaint();
  }

  @Override
  protected void refreshInit() {
    wwidth = -1;
    wheight = -1;
    realImage = null;
    repaint();
  }

  @Override
  protected void refreshLayout() {

    repaint();
  }

  @Override
  protected void refreshMark() {
    wwidth = -1;
    wheight = -1;
    realImage = null;
    repaint();
  }

  @Override
  protected void refreshUpdate() {
    repaint();
  }

  @Override
  public void paintComponent(final Graphics g) {

    final Data data = GUI.context.data();
    /** Set the paint Component */
    super.paintComponent(g);
    BaseXLayout.antiAlias(g);
    g.setColor(Color.BLACK);
    g.setFont(GUIConstants.font);
    data.doc();

    /** Timer */
    final Performance perf = new Performance();
    perf.initTimer();

    /** Initialize sizes */
    fontHeight = g.getFontMetrics().getHeight();

    /** Initialize the pointer */
    pointerx = getWidth() / 2;
    pointery = topdistance;

    if(windowSizeChanged()) {

      switch(3) {
        case 1:
          drawTree(g, 0, 0, 0, getWidth());
          break;
        case 2:
          drawPrePost(g, 1, 1);
          break;
        case 3:
          temperature(GUI.context.marked().size == 0 ? 0
              : GUI.context.marked().nodes[0], g);

      }
    } else {
      g.drawImage(realImage, 0, 0, getWidth(), getHeight(), this);
    }

    if(focusedRealRect != null) {
      RealRect r = focusedRealRect;
      g.drawRect(r.x1, r.y1, r.x2 - r.x1, r.y2 - r.y1);

      final int pre = r.p;
      String s = "";

      if(data.kind(pre) == Data.ELEM) {
        s = Token.string(data.tag(pre));
      } else {
        s = Token.string(data.text(pre));
      }

      for(int y = 0; y < data.attSize(pre, data.kind(pre)) - 1; y++) {
        s += " " + Token.string(data.attName(pre + y + 1)) + "=" + "\""
            + Token.string(data.attValue(pre + y + 1)) + "\" ";
      }

      int w = BaseXLayout.width(g, s);

      g.setColor(Color.WHITE);
      g.fillRect(r.x1, r.y1 - fontHeight, w, fontHeight);
      g.setColor(Color.BLACK);
      g.drawString(s, r.x1, (int) (r.y1 - fontHeight / 4f));

{'fraction_non_alphanumeric': 0.13477869917074634, 'fraction_numerical': 0.01079028874013388, 'mean_word_length': 2.633393829401089, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '4614652', 'n_tokens_mistral': 3291, 'n_tokens_neox': 3145, 'n_words': 936}