1 7 8 package org.jdesktop.swing.decorator; 9 10 import java.awt.Color ; 11 import java.awt.Component ; 12 13 18 public class HierarchicalColumnHighlighter extends Highlighter { 19 public HierarchicalColumnHighlighter() { 20 } 21 22 public HierarchicalColumnHighlighter(Color background, Color foreground) { 23 super(background, foreground); 24 } 25 26 protected Color computeBackground(Component component, ComponentAdapter adapter) { 27 if (adapter.isHierarchical()) { 28 Color background = getBackground(); 29 Color seed = background == null ? component.getBackground() : background; 30 seed = computeBackgroundSeed(seed); 31 return adapter.isSelected() ? computeSelectedBackground(seed) : seed; 32 } 33 return null; } 35 36 public Color getForeground(Component component, ComponentAdapter adapter) { 37 if (adapter.isHierarchical()) { 38 if (getForeground() != null) { 39 return super.computeForeground(component, adapter); 40 } 41 } 42 return null; } 44 45 protected Color computeBackgroundSeed(Color seed) { 46 return new Color (Math.max((int)(seed.getRed() * 0.95), 0), 47 Math.max((int)(seed.getGreen()* 0.95), 0), 48 Math.max((int)(seed.getBlue() * 0.95), 0)); 49 } 50 } 51 | Popular Tags |