001 // GraphLab Project: http://graphlab.sharif.edu 002 // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology 003 // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ 004 package graphlab.ui.components.gpropertyeditor.renderers; 005 006 import graphlab.ui.components.gpropertyeditor.GBasicCellRenderer; 007 008 import javax.swing.*; 009 import java.awt.*; 010 011 /** 012 * author: Azin Azadi 013 * EMail: 014 */ 015 public class GColorRenderer implements GBasicCellRenderer { 016 public Component getRendererComponent(final Object value) { 017 Color c = (Color) value; 018 JLabel l = new JLabel(String.valueOf(c.getRGB())); 019 l.setOpaque(true); 020 l.setBackground(c); 021 l.setHorizontalAlignment(JLabel.CENTER); 022 return l; 023 // JPanel x = new JPanel() { 024 // /** 025 // * 026 // */ 027 // private static final long serialVersionUID = 5615648107336029419L; 028 // 029 // public void paint(Graphics g) { 030 // super.paint(g); 031 // Color c = (Color) value; 032 // g.drawString(String.valueOf(c.getRGB()), 0, 12); 033 //// value.getClass(); 034 // } 035 // }; 036 // x.setBackground((Color) value); 037 // x.setPreferredSize(new Dimension(50, 150)); 038 // return x; 039 } 040 }