<commit_before>package com.davebsoft.sctw.ui

import _root_.scala.xml.{NodeSeq, Node}
import java.awt.event.{ActionListener, ActionEvent}
import java.awt.Font
import javax.swing.table.{DefaultTableCellRenderer, AbstractTableModel}
import javax.swing.{JTable}
import scala.swing._
import twitter.{FriendsFollowersDataProvider}

/**
 * Displays a list of friends or followers
 */
class FriendsFollowersPane(users: List[Node], xref: List[String]) extends ScrollPane {
  val table = new Table {
    model = new UsersModel(users, xref)
    peer.setAutoCreateRowSorter(true)
    val cm = peer.getColumnModel
    cm.getColumn(0).setCellRenderer(new AnnotatedUserRenderer)
    cm.getColumn(3).setPreferredWidth(500)
  }
  viewportView = table
}

private class UsersModel(users: List[Node], xref: List[String]) extends AbstractTableModel {
  private val colNames     = List[String]("Screen Name", "Name", "Location", "Description")
  private val elementNames = List[String]("screen_name", "name", "location", "description")
  
  def getColumnCount = 4
  def getRowCount = users.length
  def getValueAt(rowIndex: Int, columnIndex: Int) = {
    val user = users(rowIndex)
    val colVal = (user \ elementNames(columnIndex)).text
    columnIndex match {
      case 0 => new AnnotatedUser(colVal, xref.contains((user \ "id").text))
      case _ => colVal
    }
  }
  override def getColumnName(column: Int) = colNames(column)
}

private case class AnnotatedUser(val name: String, val annotated: Boolean)

private class AnnotatedUserRenderer extends DefaultTableCellRenderer {
  val normalFont = getFont
  val boldFont = new Font(normalFont.getFontName, Font.BOLD, normalFont.getSize)<commit_msg>Undo last change, which broke the annotated user cell rendering<commit_after>package com.davebsoft.sctw.ui

import _root_.scala.xml.{NodeSeq, Node}
import java.awt.event.{ActionListener, ActionEvent}
import java.awt.Font
import javax.swing.table.{DefaultTableCellRenderer, AbstractTableModel}
import javax.swing.{JTable}
import scala.swing._
import twitter.{FriendsFollowersDataProvider}

/**
 * Displays a list of friends or followers
 */
class FriendsFollowersPane(users: List[Node], xref: List[String]) extends ScrollPane {
  val table = new JTable(new UsersModel(users, xref)) {
    setAutoCreateRowSorter(true)
    getColumnModel.getColumn(0).setCellRenderer(new AnnotatedUserRenderer)
    getColumnModel.getColumn(3).setPreferredWidth(500)
  }
  peer.setViewportView(table)
}

private class UsersModel(users: List[Node], xref: List[String]) extends AbstractTableModel {
  private val colNames = List[String]("Screen Name", "Name", "Location", "Description")
  private val elementNames = List[String]("screen_name", "name", "location", "description")
  
  def getColumnCount = 4
  def getRowCount = users.length
  def getValueAt(rowIndex: Int, columnIndex: Int) = {
    val user = users(rowIndex)
    val colVal = (user \ elementNames(columnIndex)).text
    columnIndex match {
      case 0 => new AnnotatedUser(colVal, xref.contains((user \ "id").text))
      case _ => colVal
    }
  }
  override def getColumnName(column: Int) = colNames(column)
}

private case class AnnotatedUser(val name: String, val annotated: Boolean)

private class AnnotatedUserRenderer extends DefaultTableCellRenderer {
  val normalFont = getFont
  val boldFont = new Font(normalFont.getFontName, Font.BOLD, normalFont.getSize)
{'fraction_non_alphanumeric': 0.10639552018862364, 'fraction_numerical': 0.00412614205717654, 'mean_word_length': 5.126353790613718, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '378999', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1027, 'n_words': 260}