Package com.intellij.ui
Class SimpleColoredComponent
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
com.intellij.ui.SimpleColoredComponent
- All Implemented Interfaces:
ColoredTextContainer,ImageObserver,MenuContainer,Serializable,Accessible
This is high performance Swing component which represents an icon
with a colored text. The text consists of fragments. Each
text fragment has its own color (foreground) and font style.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classstatic classstatic interfaceNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprotected intGap between icon and text.static final Colorstatic final ColorFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal SimpleColoredComponentfinal voidappend(String fragment, SimpleTextAttributes attributes) Appends string fragments to existing ones.voidappend(String fragment, SimpleTextAttributes attributes, boolean isMainText) Appends string fragments to existing ones.final voidappend(String fragment, SimpleTextAttributes attributes, int padding, int align) Appends text fragment and sets it's end offset and alignment.voidappend(String fragment, SimpleTextAttributes attributes, Object tag) voidappendFixedTextFragmentWidth(int width) Deprecated.remove in IDEA 16voidappendTextPadding(int padding) voidappendTextPadding(int padding, int align) protected voidvoidvoidclear()Clear all special attributes ofSimpleColoredComponent.final DimensioncomputePreferredSize(boolean mainTextOnly) protected voidprotected voiddoPaintIcon(Graphics2D g, Icon icon, int offset) protected intdoPaintText(Graphics2D g, int offset, boolean focusAroundIcon) intfindFragmentAt(int x) Returns the index of text fragment at the specified X offset.protected JLabelformatToLabel(JLabel label) intgetBaseline(int width, int height) getCharSequence(boolean mainOnly) getFragmentTag(int index) getFragmentTagAt(int x) final IcongetIcon()intgetIpad()static intgetTextBaseLine(FontMetrics metrics, int height) booleanbooleanbooleaniterator()protected voidpaintBackground(Graphics2D g, int x, int width, int height) protected voidprotected voidprotected voidsetBorderInsets(Insets insets) protected final voidsetFocusBorderAroundIcon(boolean focusBorderAroundIcon) Sets whether focus border extends to icon or not.final voidSets a new component iconvoidsetIconOnTheRight(boolean iconOnTheRight) voidsetIconOpaque(boolean iconOpaque) voidsetIconTextGap(int iconTextGap) Sets a new gap between icon and textvoidSets specified internal paddingsvoidsetMyBorder(Border border) protected final voidsetPaintFocusBorder(boolean paintFocusBorder) Sets whether focus border is painted or notvoidsetTextAlign(int align) voidsetTransparentIconBackground(boolean transparentIconBackground) protected booleanprotected booleanprotected booleantoString()voidupdateUI()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, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, updateMethods 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, validateTreeMethods 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, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.intellij.ui.ColoredTextContainer
setToolTipText
-
Field Details
-
SHADOW_COLOR
-
STYLE_SEARCH_MATCH_BACKGROUND
-
FRAGMENT_ICON
public static final int FRAGMENT_ICON- See Also:
-
myIconTextGap
protected int myIconTextGapGap between icon and text. It is used only if icon is defined.
-
-
Constructor Details
-
SimpleColoredComponent
public SimpleColoredComponent()
-
-
Method Details
-
updateUI
public void updateUI()- Overrides:
updateUIin classJComponent
-
iterator
-
isIconOnTheRight
public boolean isIconOnTheRight() -
setIconOnTheRight
public void setIconOnTheRight(boolean iconOnTheRight) -
append
-
append
Appends string fragments to existing ones. Appended string will have specifiedattributes.- Specified by:
appendin interfaceColoredTextContainer- Parameters:
fragment- text fragmentattributes- text attributes
-
append
public final void append(@NotNull String fragment, @NotNull SimpleTextAttributes attributes, int padding, int align) Appends text fragment and sets it's end offset and alignment. See SimpleColoredComponent#appendTextPadding for details- Parameters:
fragment- text fragmentattributes- text attributespadding- end offset of the textalign- alignment between current offset and padding
-
append
public void append(@NotNull String fragment, @NotNull SimpleTextAttributes attributes, boolean isMainText) Appends string fragments to existing ones. Appended string will have specifiedattributes.- Parameters:
fragment- text fragmentattributes- text attributesisMainText- main text of not
-
append
- Specified by:
appendin interfaceColoredTextContainer
-
appendFixedTextFragmentWidth
Deprecated.remove in IDEA 16fragment width isn't a right name, it is actually a padding -
appendTextPadding
public void appendTextPadding(int padding) -
appendTextPadding
public void appendTextPadding(int padding, int align) - Parameters:
padding- end offset that will be set after drawing current text fragmentalign- alignment of the current text fragment, if it is SwingConstants.RIGHT or SwingConstants.TRAILING then the text fragment will be aligned to the right at the padding, otherwise it will be aligned to the left
-
setTextAlign
public void setTextAlign(int align) -
clear
public void clear()Clear all special attributes ofSimpleColoredComponent. They are icon, text fragments and their attributes, "paint focus border". -
getIcon
- Returns:
- component's icon. This method returns
nullif there is no icon.
-
setIcon
Sets a new component icon- Specified by:
setIconin interfaceColoredTextContainer- Parameters:
icon- icon
-
getIpad
- Returns:
- "leave" (internal) internal paddings of the component
-
setIpad
Sets specified internal paddings- Parameters:
ipad- insets
-
getIconTextGap
public int getIconTextGap()- Returns:
- gap between icon and text
-
setIconTextGap
public void setIconTextGap(int iconTextGap) Sets a new gap between icon and text- Parameters:
iconTextGap- the gap between text and icon- Throws:
IllegalArgumentException- if theiconTextGaphas a negative value
-
getMyBorder
-
setMyBorder
-
setPaintFocusBorder
protected final void setPaintFocusBorder(boolean paintFocusBorder) Sets whether focus border is painted or not- Parameters:
paintFocusBorder-trueorfalse
-
setFocusBorderAroundIcon
protected final void setFocusBorderAroundIcon(boolean focusBorderAroundIcon) Sets whether focus border extends to icon or not. If so then component also extends the selection.- Parameters:
focusBorderAroundIcon-trueorfalse
-
isIconOpaque
public boolean isIconOpaque() -
setIconOpaque
public void setIconOpaque(boolean iconOpaque) -
getPreferredSize
- Overrides:
getPreferredSizein classJComponent
-
getMinimumSize
- Overrides:
getMinimumSizein classJComponent
-
getFragmentTag
-
computePreferredSize
-
findFragmentAt
public int findFragmentAt(int x) Returns the index of text fragment at the specified X offset.- Parameters:
x- the offset- Returns:
- the index of the fragment,
FRAGMENT_ICONif the icon is at the offset, or -1 if nothing is there.
-
getFragmentTagAt
-
formatToLabel
-
paintComponent
- Overrides:
paintComponentin classJComponent
-
doPaint
-
paintBackground
-
doPaintIcon
-
doPaintText
-
shouldDrawMacShadow
protected boolean shouldDrawMacShadow() -
shouldDrawDimmed
protected boolean shouldDrawDimmed() -
shouldDrawBackground
protected boolean shouldDrawBackground() -
paintIcon
-
applyAdditionalHints
-
getBaseline
public int getBaseline(int width, int height) - Overrides:
getBaselinein classJComponent
-
isTransparentIconBackground
public boolean isTransparentIconBackground() -
setTransparentIconBackground
public void setTransparentIconBackground(boolean transparentIconBackground) -
getTextBaseLine
-
setBorderInsets
-
getCharSequence
-
toString
-
change
-
getAccessibleContext
- Specified by:
getAccessibleContextin interfaceAccessible- Overrides:
getAccessibleContextin classComponent
-