<commit_before>/*
 * Dockable window with rendered state output
 *
 * @author <NAME>, TU Munich
 * @author <NAME>, TU Munich
 */

package isabelle.jedit


import java.awt.{BorderLayout, Dimension}
import javax.swing.{JButton, JPanel, JScrollPane}

import isabelle.IsabelleSystem.getenv

import org.xhtmlrenderer.simple.XHTMLPanel
import org.xhtmlrenderer.context.AWTFontResolver

import org.gjt.sp.jedit.View
import org.gjt.sp.jedit.gui.DockableWindowManager


class StateViewDockable(view : View, position : String) extends JPanel {
  val panel = new XHTMLPanel(new UserAgent())

  if (position == DockableWindowManager.FLOATING)
    setPreferredSize(new Dimension(500, 250))

  setLayout(new BorderLayout)

  
  //Copy-paste-support
  private val cp = new SelectionActions
  cp.install(panel)

  add(new JScrollPane(panel), BorderLayout.CENTER)

  private val fontResolver =
    panel.getSharedContext.getFontResolver.asInstanceOf[AWTFontResolver]
  if (Plugin.plugin.viewFont != null)
    fontResolver.setFontMapping("Isabelle", Plugin.plugin.viewFont)

  Plugin.plugin.viewFontChanged.add(font => {<commit_msg>basic setup of anti-aliasing, according to jEdit property; tuned;<commit_after>/*
 * Dockable window with rendered state output
 *
 * @author <NAME>, TU Munich
 * @author <NAME>, TU Munich
 */

package isabelle.jedit


import java.awt.{BorderLayout, Dimension}
import javax.swing.{JButton, JPanel, JScrollPane}

import isabelle.IsabelleSystem.getenv

import org.xhtmlrenderer.simple.{XHTMLPanel, FSScrollPane}
import org.xhtmlrenderer.context.AWTFontResolver
import org.xhtmlrenderer.layout.SharedContext;
import org.xhtmlrenderer.extend.TextRenderer;
import org.xhtmlrenderer.swing.Java2DTextRenderer;

import org.gjt.sp.jedit.jEdit
import org.gjt.sp.jedit.View
import org.gjt.sp.jedit.gui.DockableWindowManager
import org.gjt.sp.jedit.textarea.AntiAlias


class StateViewDockable(view : View, position : String) extends JPanel {

  // outer panel
  if (position == DockableWindowManager.FLOATING)
    setPreferredSize(new Dimension(500, 250))
  setLayout(new BorderLayout)


  // XHTML panel
  val panel = new XHTMLPanel(new UserAgent)


  // anti-aliasing
  // TODO: proper EditBus event handling
  {
    val aa = jEdit.getProperty("view.antiAlias")
    if (aa != null && aa != AntiAlias.NONE) {
      panel.getSharedContext.setTextRenderer(
        {
          val renderer = new Java2DTextRenderer
          renderer.setSmoothingThreshold(0)
          renderer.setSmoothingLevel(TextRenderer.HIGH)
          renderer
        })
    }
  }

  // copy & paste
  (new SelectionActions).install(panel)


  // scrolling
  add(new FSScrollPane(panel), BorderLayout.CENTER)


  private val fontResolver =
    panel.getSharedContext.getFontResolver.asInstanceOf[AWTFontResolver]
  if (Plugin.plugin.viewFont != null)
    fontResolver.setFontMapping("Isabelle", Plugin.plugin.viewFont)

  Plugin.plugin.viewFontChanged.add(font => {
{'fraction_non_alphanumeric': 0.10064603876232574, 'fraction_numerical': 0.0051003060183611015, 'mean_word_length': 4.320072332730561, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '408744', 'n_tokens_mistral': 982, 'n_tokens_neox': 922, 'n_words': 191}