com.alee.managers.style.skin.web
Class WebScrollBarPainter<E extends javax.swing.JScrollBar>

java.lang.Object
  extended by com.alee.extended.painter.AbstractPainter<E>
      extended by com.alee.managers.style.skin.web.WebScrollBarPainter<E>
All Implemented Interfaces:
Painter<E>, SpecificPainter, ScrollBarPainter<E>
Direct Known Subclasses:
NPScrollBarPainter

public class WebScrollBarPainter<E extends javax.swing.JScrollBar>
extends AbstractPainter<E>
implements ScrollBarPainter<E>

Web-style painter for JScrollBar component. It is used as WebScrollBarUI default painter.

Author:
Mikle Garin

Field Summary
protected  boolean animated
          Runtime variables.
protected  boolean dragged
           
protected  java.awt.event.MouseAdapter mouseAdapter
          Listeners.
protected  boolean paintButtons
          Style settings.
protected  boolean paintTrack
           
protected  boolean pressed
           
protected  boolean rollover
           
protected  WebTimer rolloverAnimator
           
protected  float rolloverState
           
protected  java.awt.Color thumbBackgroundColor
           
protected  java.awt.Color thumbBorderColor
           
protected  java.awt.Rectangle thumbBounds
           
protected  java.awt.Color thumbDisabledBackgroundColor
           
protected  java.awt.Color thumbDisabledBorderColor
           
protected  java.awt.Insets thumbMargin
           
protected  java.awt.Insets thumbMarginHL
           
protected  java.awt.Insets thumbMarginHR
           
protected  java.awt.Insets thumbMarginR
           
protected  java.awt.Color thumbPressedBackgroundColor
           
protected  java.awt.Color thumbPressedBorderColor
           
protected  java.awt.Color thumbRolloverBackgroundColor
           
protected  java.awt.Color thumbRolloverBorderColor
           
protected  int thumbRound
           
protected  java.awt.Color trackBackgroundColor
           
protected  java.awt.Color trackBorderColor
           
protected  java.awt.Rectangle trackBounds
           
 
Fields inherited from class com.alee.extended.painter.AbstractPainter
listeners, margin, opaque, preferredSize
 
Constructor Summary
WebScrollBarPainter()
           
 
Method Summary
protected  java.awt.Color getCurrentThumbBackgroundColor(E scrollbar)
          Returns current thumb background color.
protected  java.awt.Color getCurrentThumbBorderColor(E scrollbar)
          Returns current thumb border color.
protected  java.awt.Insets getCurrentThumbMargin(E scrollbar)
          Returns current thumb margin rotated into proper position.
 java.awt.Insets getMargin(E scrollbar)
          Returns margin required for visual data provided by this painter.
 java.awt.Color getThumbBackgroundColor()
          Returns scroll bar thumb background color.
 java.awt.Color getThumbBorderColor()
          Returns scroll bar thumb border color.
 java.awt.Color getThumbDisabledBackgroundColor()
          Returns disabled scroll bar thumb background color.
 java.awt.Color getThumbDisabledBorderColor()
          Returns disabled scroll bar thumb border color.
 java.awt.Insets getThumbMargin()
          Returns scroll bar thumb margin.
 java.awt.Color getThumbPressedBackgroundColor()
          Returns scroll bar pressed thumb background color.
 java.awt.Color getThumbPressedBorderColor()
          Returns scroll bar pressed thumb border color.
 java.awt.Color getThumbRolloverBackgroundColor()
          Returns scroll bar rollover thumb background color.
 java.awt.Color getThumbRolloverBorderColor()
          Returns scroll bar rollover thumb border color.
 int getThumbRound()
          Returns scroll bar thumb corners rounding.
 java.awt.Color getTrackBackgroundColor()
          Returns scroll bar track background color.
 java.awt.Color getTrackBorderColor()
          Returns scroll bar track border color.
 void install(E scrollbar)
          Called when painter is intalled into some component.
 java.lang.Boolean isOpaque(E scrollbar)
          Returns whether visual data provided by this painter is opaque or not.
 boolean isPaintButtons()
          Returns whether scroll bar arrow buttons are visible or not.
 boolean isPaintTrack()
          Returns whether scroll bar track should be painted or not.
 boolean isPressed()
          Returns whether scroll bar thumb is pressed or not.
 boolean isRollover()
          Returns whether scroll bar thumb is in rollover state or not.
 void paint(java.awt.Graphics2D g2d, java.awt.Rectangle bounds, E scrollbar)
          Paints visual data onto the component graphics.
protected  void paintBackground(java.awt.Graphics2D g2d, E scrollbar, java.awt.Rectangle bounds)
          Paints scroll bar background.
protected  void paintThumb(java.awt.Graphics2D g2d, E scrollbar, java.awt.Rectangle bounds)
          Paints scroll bar thumb.
protected  void paintTrack(java.awt.Graphics2D g2d, E scrollbar, java.awt.Rectangle bounds)
          Paints scroll bar track.
 void repaintThumb()
          Forces scroll bar thumb to be repainted.
 void setDragged(boolean dragged)
          Sets whether scroll bar thumb is being dragged or not.
 void setPaintButtons(boolean paint)
          Sets whether scroll bar arrow buttons are visible or not.
 void setPaintTrack(boolean paint)
          Sets whether scroll bar track should be painted or not.
 void setPressed(boolean pressed)
          Sets whether scroll bar thumb is pressed or not.
 void setRollover(boolean rollover)
          Sets whether scroll bar thumb is in rollover state or not.
 void setThumbBackgroundColor(java.awt.Color color)
          Sets scroll bar thumb background color.
 void setThumbBorderColor(java.awt.Color color)
          Sets scroll bar thumb border color.
 void setThumbBounds(java.awt.Rectangle bounds)
          Sets scroll bar thumb bounds.
 void setThumbDisabledBackgroundColor(java.awt.Color color)
          Sets disabled scroll bar thumb background color.
 void setThumbDisabledBorderColor(java.awt.Color color)
          Sets disabled scroll bar thumb border color.
 void setThumbMargin(java.awt.Insets margin)
          Sets scroll bar thumb margin.
 void setThumbPressedBackgroundColor(java.awt.Color color)
          Sets scroll bar pressed thumb background color.
 void setThumbPressedBorderColor(java.awt.Color color)
          Returns scroll bar pressed thumb border color.
 void setThumbRolloverBackgroundColor(java.awt.Color color)
          Sets scroll bar rollover thumb background color.
 void setThumbRolloverBorderColor(java.awt.Color color)
          Sets scroll bar rollover thumb border color.
 void setThumbRound(int round)
          Sets scroll bar thumb corners rounding.
 void setTrackBackgroundColor(java.awt.Color color)
          Sets scroll bar track background color.
 void setTrackBorderColor(java.awt.Color color)
          Sets scroll bar track border color.
 void setTrackBounds(java.awt.Rectangle bounds)
          Sets scroll bar track bounds.
 void uninstall(E scrollbar)
          Called when painter is intalled into some component.
protected  void updateThumbMargins()
          Updates cached thumb margins.
 
Methods inherited from class com.alee.extended.painter.AbstractPainter
addPainterListener, getPreferredSize, p, removePainterListener, repaint, repaint, repaint, revalidate, setMargin, setMargin, setMargin, setOpaque, setPreferredSize, updateAll, updateOpacity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.alee.extended.painter.Painter
addPainterListener, getPreferredSize, removePainterListener
 

Field Detail

paintButtons

protected boolean paintButtons
Style settings.


paintTrack

protected boolean paintTrack

thumbRound

protected int thumbRound

thumbMargin

protected java.awt.Insets thumbMargin

trackBorderColor

protected java.awt.Color trackBorderColor

trackBackgroundColor

protected java.awt.Color trackBackgroundColor

thumbBorderColor

protected java.awt.Color thumbBorderColor

thumbBackgroundColor

protected java.awt.Color thumbBackgroundColor

thumbDisabledBorderColor

protected java.awt.Color thumbDisabledBorderColor

thumbDisabledBackgroundColor

protected java.awt.Color thumbDisabledBackgroundColor

thumbRolloverBorderColor

protected java.awt.Color thumbRolloverBorderColor

thumbRolloverBackgroundColor

protected java.awt.Color thumbRolloverBackgroundColor

thumbPressedBorderColor

protected java.awt.Color thumbPressedBorderColor

thumbPressedBackgroundColor

protected java.awt.Color thumbPressedBackgroundColor

animated

protected boolean animated
Runtime variables.


rolloverAnimator

protected WebTimer rolloverAnimator

rolloverState

protected float rolloverState

rollover

protected boolean rollover

pressed

protected boolean pressed

dragged

protected boolean dragged

trackBounds

protected java.awt.Rectangle trackBounds

thumbBounds

protected java.awt.Rectangle thumbBounds

thumbMarginR

protected java.awt.Insets thumbMarginR

thumbMarginHL

protected java.awt.Insets thumbMarginHL

thumbMarginHR

protected java.awt.Insets thumbMarginHR

mouseAdapter

protected java.awt.event.MouseAdapter mouseAdapter
Listeners.

Constructor Detail

WebScrollBarPainter

public WebScrollBarPainter()
Method Detail

install

public void install(E scrollbar)
Called when painter is intalled into some component. You might want to use this method to add custom component listeners or modify component settings.

Specified by:
install in interface Painter<E extends javax.swing.JScrollBar>
Overrides:
install in class AbstractPainter<E extends javax.swing.JScrollBar>
Parameters:
scrollbar - component to process

uninstall

public void uninstall(E scrollbar)
Called when painter is intalled into some component. You might want to use this method to add custom component listeners or modify component settings.

Specified by:
uninstall in interface Painter<E extends javax.swing.JScrollBar>
Overrides:
uninstall in class AbstractPainter<E extends javax.swing.JScrollBar>
Parameters:
scrollbar - component to process

isPaintButtons

public boolean isPaintButtons()
Returns whether scroll bar arrow buttons are visible or not. Buttons are painted separately, this mark simply informs whether they are actually visible or not.

Returns:
true if scroll bar arrow buttons are visible, false otherwise

setPaintButtons

public void setPaintButtons(boolean paint)
Sets whether scroll bar arrow buttons are visible or not. Buttons are painted separately, this mark simply informs whether they are actually visible or not.

Specified by:
setPaintButtons in interface ScrollBarPainter<E extends javax.swing.JScrollBar>
Parameters:
paint - whether scroll bar arrow buttons are visible or not

isPaintTrack

public boolean isPaintTrack()
Returns whether scroll bar track should be painted or not.

Returns:
true if scroll bar track should be painted, false otherwise

setPaintTrack

public void setPaintTrack(boolean paint)
Sets whether scroll bar track should be painted or not.

Specified by:
setPaintTrack in interface ScrollBarPainter<E extends javax.swing.JScrollBar>
Parameters:
paint - whether scroll bar track should be painted or not

getThumbRound

public int getThumbRound()
Returns scroll bar thumb corners rounding.

Returns:
scroll bar thumb corners rounding

setThumbRound

public void setThumbRound(int round)
Sets scroll bar thumb corners rounding.

Parameters:
round - new scroll bar thumb corners rounding

getThumbMargin

public java.awt.Insets getThumbMargin()
Returns scroll bar thumb margin. This value doesn't affect scroll bar size, just the visual representation of the thumb. Also these margins are the same only for vertical scroll bar, and are rotated clockwise for horizontal scroll bar.

Returns:
scroll bar thumb margin

setThumbMargin

public void setThumbMargin(java.awt.Insets margin)
Sets scroll bar thumb margin. This value doesn't affect scroll bar size, just the visual representation of the thumb. Also these margins are the same only for vertical scroll bar, and are rotated clockwise for horizontal scroll bar.

Parameters:
margin - new scroll bar thumb margin

updateThumbMargins

protected void updateThumbMargins()
Updates cached thumb margins.


getTrackBorderColor

public java.awt.Color getTrackBorderColor()
Returns scroll bar track border color.

Returns:
scroll bar track border color

setTrackBorderColor

public void setTrackBorderColor(java.awt.Color color)
Sets scroll bar track border color.

Parameters:
color - new scroll bar track border color

getTrackBackgroundColor

public java.awt.Color getTrackBackgroundColor()
Returns scroll bar track background color.

Returns:
scroll bar track background color

setTrackBackgroundColor

public void setTrackBackgroundColor(java.awt.Color color)
Sets scroll bar track background color.

Parameters:
color - new scroll bar track background color

getThumbBorderColor

public java.awt.Color getThumbBorderColor()
Returns scroll bar thumb border color.

Returns:
scroll bar thumb border color

setThumbBorderColor

public void setThumbBorderColor(java.awt.Color color)
Sets scroll bar thumb border color.

Parameters:
color - new scroll bar thumb border color

getThumbBackgroundColor

public java.awt.Color getThumbBackgroundColor()
Returns scroll bar thumb background color.

Returns:
scroll bar thumb background color

setThumbBackgroundColor

public void setThumbBackgroundColor(java.awt.Color color)
Sets scroll bar thumb background color.

Parameters:
color - new scroll bar thumb background color

getThumbDisabledBorderColor

public java.awt.Color getThumbDisabledBorderColor()
Returns disabled scroll bar thumb border color.

Returns:
disabled scroll bar thumb border color

setThumbDisabledBorderColor

public void setThumbDisabledBorderColor(java.awt.Color color)
Sets disabled scroll bar thumb border color.

Parameters:
color - new disabled scroll bar thumb border color

getThumbDisabledBackgroundColor

public java.awt.Color getThumbDisabledBackgroundColor()
Returns disabled scroll bar thumb background color.

Returns:
disabled scroll bar thumb background color

setThumbDisabledBackgroundColor

public void setThumbDisabledBackgroundColor(java.awt.Color color)
Sets disabled scroll bar thumb background color.

Parameters:
color - new disabled scroll bar thumb background color

getThumbRolloverBorderColor

public java.awt.Color getThumbRolloverBorderColor()
Returns scroll bar rollover thumb border color.

Returns:
scroll bar rollover thumb border color

setThumbRolloverBorderColor

public void setThumbRolloverBorderColor(java.awt.Color color)
Sets scroll bar rollover thumb border color.

Parameters:
color - new scroll bar rollover thumb border color

getThumbRolloverBackgroundColor

public java.awt.Color getThumbRolloverBackgroundColor()
Returns scroll bar rollover thumb background color.

Returns:
scroll bar rollover thumb background color

setThumbRolloverBackgroundColor

public void setThumbRolloverBackgroundColor(java.awt.Color color)
Sets scroll bar rollover thumb background color.

Parameters:
color - new scroll bar rollover thumb background color

getThumbPressedBorderColor

public java.awt.Color getThumbPressedBorderColor()
Returns scroll bar pressed thumb border color.

Returns:
scroll bar pressed thumb border color

setThumbPressedBorderColor

public void setThumbPressedBorderColor(java.awt.Color color)
Returns scroll bar pressed thumb border color.

Parameters:
color - new scroll bar pressed thumb border color

getThumbPressedBackgroundColor

public java.awt.Color getThumbPressedBackgroundColor()
Returns scroll bar pressed thumb background color.

Returns:
scroll bar pressed thumb background color

setThumbPressedBackgroundColor

public void setThumbPressedBackgroundColor(java.awt.Color color)
Sets scroll bar pressed thumb background color.

Parameters:
color - new scroll bar pressed thumb background color

isRollover

public boolean isRollover()
Returns whether scroll bar thumb is in rollover state or not.

Returns:
true if scroll bar thumb is in rollover state, false otherwise

setRollover

public void setRollover(boolean rollover)
Sets whether scroll bar thumb is in rollover state or not.

Parameters:
rollover - whether scroll bar thumb is in rollover state or not

isPressed

public boolean isPressed()
Returns whether scroll bar thumb is pressed or not.

Returns:
true if scroll bar thumb is pressed, false otherwise

setPressed

public void setPressed(boolean pressed)
Sets whether scroll bar thumb is pressed or not.

Parameters:
pressed - whether scroll bar thumb is pressed or not

setDragged

public void setDragged(boolean dragged)
Sets whether scroll bar thumb is being dragged or not. This value is updated by WebScrollBarUI when drag event starts or ends.

Specified by:
setDragged in interface ScrollBarPainter<E extends javax.swing.JScrollBar>
Parameters:
dragged - whether scroll bar thumb is being dragged or not

setTrackBounds

public void setTrackBounds(java.awt.Rectangle bounds)
Sets scroll bar track bounds. This value is updated by WebScrollBarUI on each paint call to ensure that proper bounds presented.

Specified by:
setTrackBounds in interface ScrollBarPainter<E extends javax.swing.JScrollBar>
Parameters:
bounds - new scroll bar track bounds

setThumbBounds

public void setThumbBounds(java.awt.Rectangle bounds)
Sets scroll bar thumb bounds. This value is updated by WebScrollBarUI on each paint call to ensure that proper bounds presented.

Specified by:
setThumbBounds in interface ScrollBarPainter<E extends javax.swing.JScrollBar>
Parameters:
bounds - new scroll bar thumb bounds

isOpaque

public java.lang.Boolean isOpaque(E scrollbar)
Returns whether visual data provided by this painter is opaque or not. Returned value might affect component opacity depending on painter support inside that component UI. Simply return null if you don't want to change default component opacity.

Specified by:
isOpaque in interface Painter<E extends javax.swing.JScrollBar>
Overrides:
isOpaque in class AbstractPainter<E extends javax.swing.JScrollBar>
Parameters:
scrollbar - component to process
Returns:
true if visual data provided by this painter is opaque, false otherwise

getMargin

public java.awt.Insets getMargin(E scrollbar)
Returns margin required for visual data provided by this painter. This margin is usually added to component's margin when the final component border is calculated. You may pass null instead of zero margin - it will simply be ignored in that case.

Specified by:
getMargin in interface Painter<E extends javax.swing.JScrollBar>
Overrides:
getMargin in class AbstractPainter<E extends javax.swing.JScrollBar>
Parameters:
scrollbar - component to process
Returns:
margin required for visual data provided by this painter or null for zero margin

paint

public void paint(java.awt.Graphics2D g2d,
                  java.awt.Rectangle bounds,
                  E scrollbar)
Paints visual data onto the component graphics. Provided graphics and component are taken directly from component UI paint method. Provided bounds are usually fake (zero location, component size) but in some cases it might be specified by componentUI.

Specified by:
paint in interface Painter<E extends javax.swing.JScrollBar>
Parameters:
g2d - component graphics
bounds - bounds for painter visual data
scrollbar - component to process

paintBackground

protected void paintBackground(java.awt.Graphics2D g2d,
                               E scrollbar,
                               java.awt.Rectangle bounds)
Paints scroll bar background. Background area includes the space under arrow buttons.

Parameters:
g2d - graphics context
scrollbar - scroll bar
bounds - scroll bar bounds

paintTrack

protected void paintTrack(java.awt.Graphics2D g2d,
                          E scrollbar,
                          java.awt.Rectangle bounds)
Paints scroll bar track. Track area only excludes the space under arrow buttons.

Parameters:
g2d - graphics context
scrollbar - scroll bar
bounds - track bounds

paintThumb

protected void paintThumb(java.awt.Graphics2D g2d,
                          E scrollbar,
                          java.awt.Rectangle bounds)
Paints scroll bar thumb. Thumb area is limited to thumb bounds and might be changed frequently.

Parameters:
g2d - graphics context
scrollbar - scroll bar component
bounds - thumb bounds

getCurrentThumbMargin

protected java.awt.Insets getCurrentThumbMargin(E scrollbar)
Returns current thumb margin rotated into proper position.

Parameters:
scrollbar - scroll bar component
Returns:
current thumb margin rotated into proper position

getCurrentThumbBorderColor

protected java.awt.Color getCurrentThumbBorderColor(E scrollbar)
Returns current thumb border color.

Parameters:
scrollbar - scroll bar component
Returns:
current thumb border color

getCurrentThumbBackgroundColor

protected java.awt.Color getCurrentThumbBackgroundColor(E scrollbar)
Returns current thumb background color.

Parameters:
scrollbar - scroll bar component
Returns:
current thumb background color

repaintThumb

public void repaintThumb()
Forces scroll bar thumb to be repainted.