Class: CellRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/life_game_viewer/view/life_game_viewer_frame.rb

Overview

This class is responsible for rendering the display of a table cell, which in our case is to display an image of Alfred E. Neuman if the underlying data value is true, else display nothing.

Defined Under Namespace

Classes: LifeLabel

Instance Method Summary collapse

Constructor Details

#initializeCellRenderer

Returns a new instance of CellRenderer.



191
192
193
194
195
196
# File 'lib/life_game_viewer/view/life_game_viewer_frame.rb', line 191

def initialize
  @label = LifeLabel.new
  image_spec = File.expand_path(File.join(
      File.dirname(__FILE__), '..', '..', '..', 'resources', 'images', 'alfred-e-neuman.jpg'))
  @true_icon = ImageIcon.new(image_spec, 'Alfred E. Neuman')
end

Instance Method Details

#getTableCellRendererComponent(table, value, is_selected, has_focus, row, column) ⇒ Object

from TableCellRenderer interface



199
200
201
202
203
204
# File 'lib/life_game_viewer/view/life_game_viewer_frame.rb', line 199

def getTableCellRendererComponent(table, value, is_selected, has_focus, row, column)
  alive = value
  @label.icon = alive ? @true_icon : nil
  @label.tool_tip_text = "row #{row}, column #{column}, value is #{alive}"
  @label
end