com.mucommander.ui.main.table
Class CellLabel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLabel
                  extended by com.mucommander.ui.main.table.CellLabel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.SwingConstants

public class CellLabel
extends javax.swing.JLabel

A custom JLabel component used by FileTableCellRenderer to render table cells.

CellLabel is basically a faster dumbed-down JLabel which overrides some JLabel to be no-ops (see below) and some other (setText, setIcon) to call JLabel's super methods only if value has changed since last call, as very often values don't change from one cell to another. Some methods were borrowed from Sun's DefaultTableCellRender implementation and are marked as much.

Quote from Sun's Javadoc : The table class defines a single cell renderer and uses it as a as a rubber-stamp for rendering all cells in the table; it renders the first cell, changes the contents of that cell renderer, shifts the origin to the new location, re-draws it, and so on.

The standard JLabel component was not designed to be used this way and we want to avoid triggering a revalidate each time the cell is drawn. This would greatly decrease performance because the revalidate message would be passed up the hierarchy of the container to determine whether any other components would be affected. So this class overrides the validate, revalidate, repaint, and firePropertyChange methods to be no-ops.

Author:
Maxence Bernard, Sun Microsystems
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JLabel
javax.swing.JLabel.AccessibleJLabel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int CELL_BORDER_HEIGHT
          Amount of border space on the top and bottom of the cell
static int CELL_BORDER_WIDTH
          Amount of border space on the left and right of the cell
 
Fields inherited from class javax.swing.JLabel
labelFor
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CellLabel()
          Creates a new blank CellLabel.
 
Method Summary
 void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
          Overridden for performance reasons.
protected  void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Overridden for performance reasons.
 boolean isOpaque()
          Overridden for performance reasons.
 void paint(java.awt.Graphics g)
          Paints the label.
 void repaint(long tm, int x, int y, int width, int height)
          Overridden for performance reasons.
 void repaint(java.awt.Rectangle r)
          Overridden for performance reasons.
 void revalidate()
          Overridden for performance reasons.
 void setBackground(java.awt.Color c)
          Overrides JComponent.setBackground to call the super method only if the value has changed since last call.
 void setBackground(java.awt.Color c1, java.awt.Color c2)
          Sets the background to a gradient between the two specified colors.
 void setForeground(java.awt.Color c)
          Overrides JComponent.setForeground to call the super method only if the value has changed since last call.
 void setIcon(javax.swing.ImageIcon icon)
          Overrides JLabel.setIcon to call the super method only if the value has changed since last call.
 void setOutline(java.awt.Color c)
          Sets the label outline color.
 void setText(java.lang.String text)
          Overrides JLabel.setText to call the super method only if the value has changed since last call.
 void setToolTipText(java.lang.String tooltip)
          Overrides JLabel.setToolTipText to call the super method only if the value has changed since last call.
 void validate()
          Overridden for performance reasons.
 
Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CELL_BORDER_WIDTH

public static final int CELL_BORDER_WIDTH
Amount of border space on the left and right of the cell

See Also:
Constant Field Values

CELL_BORDER_HEIGHT

public static final int CELL_BORDER_HEIGHT
Amount of border space on the top and bottom of the cell

See Also:
Constant Field Values
Constructor Detail

CellLabel

public CellLabel()
Creates a new blank CellLabel.

Method Detail

setForeground

public void setForeground(java.awt.Color c)
Overrides JComponent.setForeground to call the super method only if the value has changed since last call.

Overrides:
setForeground in class javax.swing.JComponent
Parameters:
c - the new foreground's color for this label

setBackground

public void setBackground(java.awt.Color c)
Overrides JComponent.setBackground to call the super method only if the value has changed since last call.

Overrides:
setBackground in class javax.swing.JComponent
Parameters:
c - the new background's color for this label

setBackground

public void setBackground(java.awt.Color c1,
                          java.awt.Color c2)
Sets the background to a gradient between the two specified colors.

Parameters:
c1 - first component of the gradient.
c2 - second component of the gradient.

setOutline

public void setOutline(java.awt.Color c)
Sets the label outline color.

Parameters:
c - the new background's color for this label

setText

public void setText(java.lang.String text)
Overrides JLabel.setText to call the super method only if the value has changed since last call.

Overrides:
setText in class javax.swing.JLabel
Parameters:
text - the new text this label will display

setIcon

public void setIcon(javax.swing.ImageIcon icon)
Overrides JLabel.setIcon to call the super method only if the value has changed since last call.

Parameters:
icon - the new icon this label will display

setToolTipText

public void setToolTipText(java.lang.String tooltip)
Overrides JLabel.setToolTipText to call the super method only if the value has changed since last call.

Overrides:
setToolTipText in class javax.swing.JComponent
Parameters:
tooltip - the new tooltip this label will display

paint

public void paint(java.awt.Graphics g)
Paints the label.

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - where to paint the label.

isOpaque

public boolean isOpaque()
Overridden for performance reasons.

Overrides:
isOpaque in class javax.swing.JComponent

validate

public void validate()
Overridden for performance reasons.

Overrides:
validate in class java.awt.Container

revalidate

public void revalidate()
Overridden for performance reasons.

Overrides:
revalidate in class javax.swing.JComponent

repaint

public void repaint(long tm,
                    int x,
                    int y,
                    int width,
                    int height)
Overridden for performance reasons.

Overrides:
repaint in class javax.swing.JComponent

repaint

public void repaint(java.awt.Rectangle r)
Overridden for performance reasons.

Overrides:
repaint in class javax.swing.JComponent

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)
Overridden for performance reasons.

Overrides:
firePropertyChange in class java.awt.Component

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               boolean oldValue,
                               boolean newValue)
Overridden for performance reasons.

Overrides:
firePropertyChange in class javax.swing.JComponent


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard