Class CellRenderer

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.tree.TreeCellRenderer

    public class CellRenderer
    extends javax.swing.JPanel
    implements javax.swing.tree.TreeCellRenderer
    TreeCellRenderer with stylesets.
    Version:
    1.0
    Author:
    Sebastian
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  CellRenderer.SameHeightBoxLayout
      A box layout assuring that all components have the same height.
      • Nested classes/interfaces inherited from class javax.swing.JPanel

        javax.swing.JPanel.AccessibleJPanel
      • 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

      Fields 
      Modifier and Type Field Description
      static int ADDITIONAL_STYLE
      ADDITIONAL PART
      static java.util.Map<java.lang.String,​java.awt.Color> colorMap
      DOCUMENT-ME
      static int DEFAULT_STYLE
      DEFAULT TYPE
      static java.awt.Color emphasizeColor
      DOCUMENT-ME
      static int emphasizeStyleChange
      DOCUMENT-ME
      static int MAIN_STYLE
      MAIN PART STYLE
      static int SIMPLE_STYLE
      SIMPLE STYLE
      static java.lang.String SKILL_CHANGE_STYLE_PREFIX  
      static java.lang.String[] STYLE_NAMES
      Names (for preferences etc.) of styles
      static int TALENT_DEC_STYLE
      SKILL DECREASE TYPE
      static int TALENT_INC_STYLE
      SKILL INCREASED TYPE
      static int TALENT_UNKNOWN_STYLE
      SKILL UNKNOWN
      protected static GraphicsStyleset[] typeSets  
      • Fields inherited from class javax.swing.JComponent

        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

        accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void addStyleset​(GraphicsStyleset set)
      Adds the given styleset to the styleset table.
      protected void applyUIDefaults()
      Applies the default values to type set 4 (DEFAULT).
      protected static java.lang.String createDefinitionString​(GraphicsStyleset set)  
      protected static java.lang.String encodeColor​(java.awt.Color c)  
      protected static java.lang.String encodeFont​(java.awt.Font f)  
      protected void fillLabel​(javax.swing.JLabel l, GraphicsElement ge)
      Fills the given label with the information out of the given element.
      protected void formatLabel​(javax.swing.JLabel l, GraphicsStyleset set, boolean isSelected, boolean hasFocus)
      Formats a label using the given styleset.
      protected java.awt.Font getBoldFont​(java.awt.Font f)
      Returns the bold font of the given font.
      protected javax.swing.Icon getIcon​(java.lang.Object icon)
      Returns an icon constructed out of the given information.
      protected GraphicsStyleset getStyleset​(int type)
      Returns a full styleset created out of the given styleset.
      protected GraphicsStyleset getStyleset​(GraphicsElement ge)
      Returns a styleset that supplies all variables.
      protected GraphicsStyleset getStyleset​(GraphicsStyleset set, int type)
      Returns a styleset that supplies all variables.
      static java.util.Map<java.lang.String,​GraphicsStyleset> getStylesets()
      Returns the styleset map.
      java.lang.String getToolTipText​(java.awt.event.MouseEvent e)
      Overrides JComponent.getToolTipText to return the tooltip of the underlying label or null, if no label found.
      java.awt.Component getTreeCellRendererComponent​(javax.swing.JTree tree, java.lang.Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
      DOCUMENT-ME
      static GraphicsStyleset getTypeset​(int i)
      Returns the styleset of a certain type.
      static boolean isShowTooltips()
      Returns the value of showTooltips.
      protected void layoutComponent2​(boolean isSelected, boolean hasFocus)  
      protected void loadAdditionalValueProperties()
      Loads the display values out of the settings.
      protected static void loadEmphasizeData()  
      protected static void loadStyleset​(java.lang.String name)
      Loads a styleset out of the property PropertiesHelper.CELLRENDERER_STYLESETS+name
      static void loadStylesets()
      Loads all custom stylesets.
      protected void loadTypesets()  
      static void removeStyleset​(java.lang.String styleset)
      Deletes a styleset out of the stylesets map.
      protected static void saveStyleset​(java.lang.String name)
      Saves a single styleset.
      static void saveStylesets()
      Stores all stylesets(custom and type) into the settings.
      static void setAdditionalValueProperties​(java.util.Map<java.lang.String,​java.awt.Color> colorM, boolean sTip)
      Sets the display values and saves them in the settings
      static void setColorMap​(java.util.Map<java.lang.String,​java.awt.Color> colorM)
      Sets the current color mapping and stores it in the settings.
      static void setEmphasizeData​(int sChange, java.awt.Color sColor)
      DOCUMENT-ME
      static void setShowTooltips​(boolean showTooltips)
      Sets the value of showTooltips.
      • Methods inherited from class javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, 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, transferFocusDownCycle, validate, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • SKILL_CHANGE_STYLE_PREFIX

        public static final java.lang.String SKILL_CHANGE_STYLE_PREFIX
        See Also:
        Constant Field Values
      • STYLE_NAMES

        public static final java.lang.String[] STYLE_NAMES
        Names (for preferences etc.) of styles
      • ADDITIONAL_STYLE

        public static final int ADDITIONAL_STYLE
        ADDITIONAL PART
        See Also:
        Constant Field Values
      • TALENT_INC_STYLE

        public static final int TALENT_INC_STYLE
        SKILL INCREASED TYPE
        See Also:
        Constant Field Values
      • TALENT_DEC_STYLE

        public static final int TALENT_DEC_STYLE
        SKILL DECREASE TYPE
        See Also:
        Constant Field Values
      • TALENT_UNKNOWN_STYLE

        public static final int TALENT_UNKNOWN_STYLE
        SKILL UNKNOWN
        See Also:
        Constant Field Values
      • colorMap

        public static java.util.Map<java.lang.String,​java.awt.Color> colorMap
        DOCUMENT-ME
      • emphasizeStyleChange

        public static int emphasizeStyleChange
        DOCUMENT-ME
      • emphasizeColor

        public static java.awt.Color emphasizeColor
        DOCUMENT-ME
    • Constructor Detail

      • CellRenderer

        public CellRenderer​(MagellanContext context)
        Creates new CellRenderer
    • Method Detail

      • loadTypesets

        protected void loadTypesets()
      • loadAdditionalValueProperties

        protected void loadAdditionalValueProperties()
        Loads the display values out of the settings.
      • loadEmphasizeData

        protected static void loadEmphasizeData()
      • setEmphasizeData

        public static void setEmphasizeData​(int sChange,
                                            java.awt.Color sColor)
        DOCUMENT-ME
      • setAdditionalValueProperties

        public static void setAdditionalValueProperties​(java.util.Map<java.lang.String,​java.awt.Color> colorM,
                                                        boolean sTip)
        Sets the display values and saves them in the settings
      • setShowTooltips

        public static void setShowTooltips​(boolean showTooltips)
        Sets the value of showTooltips.
        Parameters:
        showTooltips - The value for showTooltips.
      • isShowTooltips

        public static boolean isShowTooltips()
        Returns the value of showTooltips.
        Returns:
        Returns showTooltips.
      • setColorMap

        public static void setColorMap​(java.util.Map<java.lang.String,​java.awt.Color> colorM)
        Sets the current color mapping and stores it in the settings.
      • applyUIDefaults

        protected void applyUIDefaults()
        Applies the default values to type set 4 (DEFAULT).
      • getTreeCellRendererComponent

        public java.awt.Component getTreeCellRendererComponent​(javax.swing.JTree tree,
                                                               java.lang.Object value,
                                                               boolean selected,
                                                               boolean expanded,
                                                               boolean leaf,
                                                               int row,
                                                               boolean hasFocus)
        DOCUMENT-ME
        Specified by:
        getTreeCellRendererComponent in interface javax.swing.tree.TreeCellRenderer
      • layoutComponent2

        protected void layoutComponent2​(boolean isSelected,
                                        boolean hasFocus)
      • fillLabel

        protected void fillLabel​(javax.swing.JLabel l,
                                 GraphicsElement ge)
        Fills the given label with the information out of the given element.
      • getIcon

        protected javax.swing.Icon getIcon​(java.lang.Object icon)
        Returns an icon constructed out of the given information.

        Following parseing is done:

        1. If given object is an icon, return it.
        2. If given object is an image, construct an ImageIcon and return.
        3. If given object is a String, search an image with that name and construct an ImageIcon.
        All icons are cached(except (1)). Non-found images of (3) are replaced with missingIcon. All unparseable objects return missingIcon.

      • getBoldFont

        protected java.awt.Font getBoldFont​(java.awt.Font f)
        Returns the bold font of the given font. These fonts are stored in boldFonts. If the given font is bold it's returned directly. If there's no bold font yet, a new one is created and placed into boldFonts.

        In this implementation all other style features(only italic yet) are save.

      • formatLabel

        protected void formatLabel​(javax.swing.JLabel l,
                                   GraphicsStyleset set,
                                   boolean isSelected,
                                   boolean hasFocus)
        Formats a label using the given styleset. The styleset must be complete! Try using getStyleset() to assure a complete set.

        The label will also be resetted meaning tooltip, icon text are cleared.

      • getStyleset

        protected GraphicsStyleset getStyleset​(GraphicsElement ge)
        Returns a styleset that supplies all variables. This is done with a union of the given styleset of the element (if given) and the two fallbacks(type set and default set).
      • getStyleset

        protected GraphicsStyleset getStyleset​(GraphicsStyleset set,
                                               int type)
        Returns a styleset that supplies all variables. This is done with a union of the given styleset and the two fallbacks(type set[given via parameter] and default set).
      • getStyleset

        protected GraphicsStyleset getStyleset​(int type)
        Returns a full styleset created out of the given styleset.
      • addStyleset

        public static void addStyleset​(GraphicsStyleset set)
        Adds the given styleset to the styleset table. The name of the set is used as a key.
      • loadStyleset

        protected static void loadStyleset​(java.lang.String name)
        Loads a styleset out of the property PropertiesHelper.CELLRENDERER_STYLESETS+name
      • getStylesets

        public static java.util.Map<java.lang.String,​GraphicsStyleset> getStylesets()
        Returns the styleset map.
      • getTypeset

        public static GraphicsStyleset getTypeset​(int i)
        Returns the styleset of a certain type.
      • loadStylesets

        public static void loadStylesets()
        Loads all custom stylesets. Checks the property PropertiesHelper.CELLRENDERER_CUSTOM_STYLESETS for names of stylesets and searches the given sets.
      • saveStyleset

        protected static void saveStyleset​(java.lang.String name)
        Saves a single styleset.
      • saveStylesets

        public static void saveStylesets()
        Stores all stylesets(custom and type) into the settings.
      • removeStyleset

        public static void removeStyleset​(java.lang.String styleset)
        Deletes a styleset out of the stylesets map.
      • encodeColor

        protected static java.lang.String encodeColor​(java.awt.Color c)
      • encodeFont

        protected static java.lang.String encodeFont​(java.awt.Font f)
      • createDefinitionString

        protected static java.lang.String createDefinitionString​(GraphicsStyleset set)
      • getToolTipText

        public java.lang.String getToolTipText​(java.awt.event.MouseEvent e)
        Overrides JComponent.getToolTipText to return the tooltip of the underlying label or null, if no label found.
        Overrides:
        getToolTipText in class javax.swing.JComponent