1 /* 2 * aTunes 3 * Copyright (C) Alex Aranda, Sylvain Gaudard and contributors 4 * 5 * See http://www.atunes.org/wiki/index.php?title=Contributing for information about contributors 6 * 7 * http://www.atunes.org 8 * http://sourceforge.net/projects/atunes 9 * 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU General Public License 12 * as published by the Free Software Foundation; either version 2 13 * of the License, or (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 */ 20 21 package net.sourceforge.atunes.gui; 22 23 import javax.swing.JComponent; 24 import javax.swing.JLabel; 25 import javax.swing.JTable; 26 27 import net.sourceforge.atunes.kernel.modules.columns.PlayListColumnSet; 28 import net.sourceforge.atunes.model.IPlayListHandler; 29 import net.sourceforge.atunes.model.ITableCellRendererCode; 30 31 /** 32 * Renderer for play list table, includes highlight of incomplete tags 33 * 34 * @author alex 35 * 36 */ 37 public class PlayListTableCellRendererCode extends 38 AbstractTableCellRendererCode<JComponent, Object> { 39 40 private ITableCellRendererCode<JComponent, Object> renderer; 41 42 private IPlayListHandler playListHandler; 43 44 private PlayListColumnSet playListColumnSet; 45 46 /** 47 * @param playListColumnSet 48 */ setPlayListColumnSet(final PlayListColumnSet playListColumnSet)49 public void setPlayListColumnSet(final PlayListColumnSet playListColumnSet) { 50 this.playListColumnSet = playListColumnSet; 51 } 52 53 /** 54 * @param playListHandler 55 */ setPlayListHandler(final IPlayListHandler playListHandler)56 public void setPlayListHandler(final IPlayListHandler playListHandler) { 57 this.playListHandler = playListHandler; 58 } 59 60 /** 61 * @param renderer 62 */ setRenderer( final ITableCellRendererCode<JComponent, Object> renderer)63 public void setRenderer( 64 final ITableCellRendererCode<JComponent, Object> renderer) { 65 this.renderer = renderer; 66 } 67 68 @Override getComponent(final JComponent superComponent, final JTable t, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column)69 public JComponent getComponent(final JComponent superComponent, 70 final JTable t, final Object value, final boolean isSelected, 71 final boolean hasFocus, final int row, final int column) { 72 // Get result from super renderer 73 JComponent c = this.renderer.getComponent(superComponent, t, value, 74 isSelected, hasFocus, row, column); 75 76 // Apply component orientation 77 ((JLabel) c).setHorizontalAlignment(this.playListColumnSet.getColumn( 78 this.playListColumnSet.getColumnId(column)).getAlignment()); 79 80 // Apply font to current row 81 if (this.playListHandler.isCurrentVisibleRowPlaying(row)) { 82 if (getLookAndFeel().getPlayListSelectedItemFont() != null) { 83 c.setFont(getLookAndFeel().getPlayListSelectedItemFont()); 84 } else if (getLookAndFeel().getPlayListFont() != null) { 85 c.setFont(getLookAndFeel().getPlayListFont()); 86 } 87 } 88 return c; 89 } 90 }