idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
37,200 | protected void propertyChange ( PropertyChangeEvent evt ) { super . propertyChange ( evt ) ; String name = evt . getPropertyName ( ) ; if ( name . equals ( "foreground" ) ) { updateForeground ( ( Color ) evt . getNewValue ( ) ) ; } else if ( name . equals ( "font" ) ) { updateFont ( ( Font ) evt . getNewValue ( ) ) ; } else if ( name . equals ( "document" ) ) { JComponent comp = getComponent ( ) ; updateForeground ( comp . getForeground ( ) ) ; updateFont ( comp . getFont ( ) ) ; } } | This method gets called when a bound property is changed on the associated JTextComponent . This is a hook which UI implementations may change to reflect how the UI displays bound properties of JTextComponent subclasses . If the font foreground or document has changed the the appropriate property is set in the default style of the document . |
37,201 | private void updateForeground ( Color color ) { StyledDocument doc = ( StyledDocument ) getComponent ( ) . getDocument ( ) ; Style style = doc . getStyle ( StyleContext . DEFAULT_STYLE ) ; if ( style == null ) { return ; } if ( color == null ) { style . removeAttribute ( StyleConstants . Foreground ) ; } else { StyleConstants . setForeground ( style , color ) ; } } | Update the color in the default style of the document . |
37,202 | private void updateFont ( Font font ) { StyledDocument doc = ( StyledDocument ) getComponent ( ) . getDocument ( ) ; Style style = doc . getStyle ( StyleContext . DEFAULT_STYLE ) ; if ( style == null ) { return ; } if ( font == null ) { style . removeAttribute ( StyleConstants . FontFamily ) ; style . removeAttribute ( StyleConstants . FontSize ) ; style . removeAttribute ( StyleConstants . Bold ) ; style . removeAttribute ( StyleConstants . Italic ) ; } else { StyleConstants . setFontFamily ( style , font . getName ( ) ) ; StyleConstants . setFontSize ( style , font . getSize ( ) ) ; StyleConstants . setBold ( style , font . isBold ( ) ) ; StyleConstants . setItalic ( style , font . isItalic ( ) ) ; } } | Update the font in the default style of the document . |
37,203 | private static Object invokeGetter ( Object obj , String methodName , Object defaultValue ) { try { Method method = obj . getClass ( ) . getMethod ( methodName , new Class [ 0 ] ) ; Object result = method . invoke ( obj , new Object [ 0 ] ) ; return result ; } catch ( NoSuchMethodException e ) { return defaultValue ; } catch ( IllegalAccessException e ) { return defaultValue ; } catch ( InvocationTargetException e ) { return defaultValue ; } } | Invokes the specified getter method if it exists . |
37,204 | public Paint getFrameBorderPaint ( Shape s ) { switch ( state ) { case BACKGROUND_ENABLED : return frameBorderInactive ; case BACKGROUND_ENABLED_WINDOWFOCUSED : return frameBorderActive ; } return null ; } | Get the paint for the border . |
37,205 | public Paint getFrameInteriorPaint ( Shape s , int titleHeight , int topToolBarHeight , int bottomToolBarHeight ) { return createFrameGradient ( s , titleHeight , topToolBarHeight , bottomToolBarHeight , getFrameInteriorColors ( ) ) ; } | Get the paint for the frame interior . |
37,206 | public Paint getFrameInnerHighlightPaint ( Shape s ) { switch ( state ) { case BACKGROUND_ENABLED : return frameInnerHighlightInactive ; case BACKGROUND_ENABLED_WINDOWFOCUSED : return frameInnerHighlightActive ; } return null ; } | Get the paint to paint the inner highlight with . |
37,207 | public Paint getFocusPaint ( Shape s , FocusType focusType , boolean useToolBarFocus ) { if ( focusType == FocusType . OUTER_FOCUS ) { return useToolBarFocus ? outerToolBarFocus : outerFocus ; } else { return useToolBarFocus ? innerToolBarFocus : innerFocus ; } } | Get the paint to use for a focus ring . |
37,208 | protected final Color decodeColor ( String key , float hOffset , float sOffset , float bOffset , int aOffset ) { if ( UIManager . getLookAndFeel ( ) instanceof SeaGlassLookAndFeel ) { SeaGlassLookAndFeel laf = ( SeaGlassLookAndFeel ) UIManager . getLookAndFeel ( ) ; return laf . getDerivedColor ( key , hOffset , sOffset , bOffset , aOffset , true ) ; } else { return Color . getHSBColor ( hOffset , sOffset , bOffset ) ; } } | Decodes and returns a color which is derived from a base color in UI defaults . |
37,209 | public static int deriveARGB ( Color color1 , Color color2 , float midPoint ) { int r = color1 . getRed ( ) + ( int ) ( ( color2 . getRed ( ) - color1 . getRed ( ) ) * midPoint + 0.5f ) ; int g = color1 . getGreen ( ) + ( int ) ( ( color2 . getGreen ( ) - color1 . getGreen ( ) ) * midPoint + 0.5f ) ; int b = color1 . getBlue ( ) + ( int ) ( ( color2 . getBlue ( ) - color1 . getBlue ( ) ) * midPoint + 0.5f ) ; int a = color1 . getAlpha ( ) + ( int ) ( ( color2 . getAlpha ( ) - color1 . getAlpha ( ) ) * midPoint + 0.5f ) ; return ( ( a & 0xFF ) << 24 ) | ( ( r & 0xFF ) << 16 ) | ( ( g & 0xFF ) << 8 ) | ( b & 0xFF ) ; } | Derives the ARGB value for a color based on an offset between two other colors . |
37,210 | protected final LinearGradientPaint createGradient ( float x1 , float y1 , float x2 , float y2 , float [ ] midpoints , Color [ ] colors ) { if ( x1 == x2 && y1 == y2 ) { y2 += .00001f ; } return new LinearGradientPaint ( x1 , y1 , x2 , y2 , midpoints , colors ) ; } | Given parameters for creating a LinearGradientPaint this method will create and return a linear gradient paint . One primary purpose for this method is to avoid creating a LinearGradientPaint where the start and end points are equal . In such a case the end y point is slightly increased to avoid the overlap . |
37,211 | protected final RadialGradientPaint createRadialGradient ( float x , float y , float r , float [ ] midpoints , Color [ ] colors ) { if ( r == 0f ) { r = .00001f ; } return new RadialGradientPaint ( x , y , r , midpoints , colors ) ; } | Given parameters for creating a RadialGradientPaint this method will create and return a radial gradient paint . One primary purpose for this method is to avoid creating a RadialGradientPaint where the radius is non - positive . In such a case the radius is just slightly increased to avoid 0 . |
37,212 | protected Paint createVerticalGradient ( Shape s , TwoColors colors ) { Rectangle2D bounds = s . getBounds2D ( ) ; float xCenter = ( float ) bounds . getCenterX ( ) ; float yMin = ( float ) bounds . getMinY ( ) ; float yMax = ( float ) bounds . getMaxY ( ) ; return createGradient ( xCenter , yMin , xCenter , yMax , new float [ ] { 0f , 1f } , new Color [ ] { colors . top , colors . bottom } ) ; } | Creates a simple vertical gradient using the shape for bounds and the colors for top and bottom colors . |
37,213 | protected Paint createHorizontalGradient ( Shape s , TwoColors colors ) { Rectangle2D bounds = s . getBounds2D ( ) ; float xMin = ( float ) bounds . getMinX ( ) ; float xMax = ( float ) bounds . getMaxX ( ) ; float yCenter = ( float ) bounds . getCenterY ( ) ; return createGradient ( xMin , yCenter , xMax , yCenter , new float [ ] { 0f , 1f } , new Color [ ] { colors . top , colors . bottom } ) ; } | Creates a simple horizontal gradient using the shape for bounds and the colors for top and bottom colors . |
37,214 | protected Paint createHorizontalGradient ( Shape s , FourColors colors ) { Rectangle2D bounds = s . getBounds2D ( ) ; float x = ( float ) bounds . getX ( ) ; float y = ( float ) bounds . getY ( ) ; float w = ( float ) bounds . getWidth ( ) ; float h = ( float ) bounds . getHeight ( ) ; return createGradient ( x , ( 0.5f * h ) + y , x + w , ( 0.5f * h ) + y , new float [ ] { 0f , 0.45f , 0.62f , 1f } , new Color [ ] { colors . top , colors . upperMid , colors . lowerMid , colors . bottom } ) ; } | Creates a simple horizontal gradient using the shape for bounds and the colors for top two middle and bottom colors . |
37,215 | protected Color desaturate ( Color color ) { float [ ] tmp = Color . RGBtoHSB ( color . getRed ( ) , color . getGreen ( ) , color . getBlue ( ) , null ) ; tmp [ 1 ] /= 3.0f ; tmp [ 2 ] = clamp ( 1.0f - ( 1.0f - tmp [ 2 ] ) / 3f ) ; return new Color ( ( Color . HSBtoRGB ( tmp [ 0 ] , tmp [ 1 ] , tmp [ 2 ] ) & 0xFFFFFF ) ) ; } | Returns a new color with the saturation cut to one third the original and the brightness moved one third closer to white . |
37,216 | private void paintWithCaching ( Graphics2D g , JComponent c , int w , int h , Object [ ] extendedCacheKeys ) { VolatileImage img = getImage ( g . getDeviceConfiguration ( ) , c , w , h , extendedCacheKeys ) ; if ( img != null ) { g . drawImage ( img , 0 , 0 , null ) ; } else { paintDirectly ( g , c , w , h , extendedCacheKeys ) ; } } | Paint the component using a cached image if possible . |
37,217 | private void paintDirectly ( Graphics2D g , JComponent c , int w , int h , Object [ ] extendedCacheKeys ) { g = ( Graphics2D ) g . create ( ) ; configureGraphics ( g ) ; doPaint ( g , c , w , h , extendedCacheKeys ) ; g . dispose ( ) ; } | Convenience method which creates a temporary graphics object by creating a clone of the passed in one configuring it drawing with it disposing it . These steps have to be taken to ensure that any hints set on the graphics are removed subsequent to painting . |
37,218 | private VolatileImage getImage ( GraphicsConfiguration config , JComponent c , int w , int h , Object [ ] extendedCacheKeys ) { ImageCache imageCache = ImageCache . getInstance ( ) ; VolatileImage buffer = ( VolatileImage ) imageCache . getImage ( config , w , h , this , extendedCacheKeys ) ; int renderCounter = 0 ; do { int bufferStatus = VolatileImage . IMAGE_INCOMPATIBLE ; if ( buffer != null ) { bufferStatus = buffer . validate ( config ) ; } if ( bufferStatus == VolatileImage . IMAGE_INCOMPATIBLE || bufferStatus == VolatileImage . IMAGE_RESTORED ) { if ( buffer == null || buffer . getWidth ( ) != w || buffer . getHeight ( ) != h || bufferStatus == VolatileImage . IMAGE_INCOMPATIBLE ) { if ( buffer != null ) { buffer . flush ( ) ; buffer = null ; } buffer = config . createCompatibleVolatileImage ( w , h , Transparency . TRANSLUCENT ) ; imageCache . setImage ( buffer , config , w , h , this , extendedCacheKeys ) ; } Graphics2D bg = buffer . createGraphics ( ) ; bg . setComposite ( AlphaComposite . Clear ) ; bg . fillRect ( 0 , 0 , w , h ) ; bg . setComposite ( AlphaComposite . SrcOver ) ; configureGraphics ( bg ) ; paintDirectly ( bg , c , w , h , extendedCacheKeys ) ; bg . dispose ( ) ; } } while ( buffer . contentsLost ( ) && renderCounter ++ < 3 ) ; if ( renderCounter == 3 ) return null ; return buffer ; } | Gets the rendered image for this painter at the requested size either from cache or create a new one |
37,219 | private void updateStyle ( JTabbedPane c ) { SeaGlassContext context = getContext ( c , ENABLED ) ; SynthStyle oldStyle = style ; style = SeaGlassLookAndFeel . updateStyle ( context , this ) ; tabPlacement = tabPane . getTabPlacement ( ) ; orientation = ControlOrientation . getOrientation ( tabPlacement == LEFT || tabPlacement == RIGHT ? VERTICAL : HORIZONTAL ) ; closeButtonArmedIndex = - 1 ; Object o = c . getClientProperty ( "JTabbedPane.closeButton" ) ; if ( o != null && "left" . equals ( o ) ) { tabCloseButtonPlacement = LEFT ; } else if ( o != null && "right" . equals ( o ) ) { tabCloseButtonPlacement = RIGHT ; } else { tabCloseButtonPlacement = CENTER ; } closeButtonSize = style . getInt ( context , "closeButtonSize" , 6 ) ; closeButtonInsets = ( Insets ) style . get ( context , "closeButtonInsets" ) ; if ( closeButtonInsets == null ) { closeButtonInsets = new Insets ( 2 , 2 , 2 , 2 ) ; } o = c . getClientProperty ( "JTabbedPane.closeListener" ) ; if ( o != null && o instanceof SeaGlassTabCloseListener ) { if ( tabCloseListener == null ) { tabCloseListener = ( SeaGlassTabCloseListener ) o ; } } if ( style != oldStyle ) { tabRunOverlay = 0 ; textIconGap = style . getInt ( context , "TabbedPane.textIconGap" , 0 ) ; selectedTabPadInsets = ( Insets ) style . get ( context , "TabbedPane.selectedTabPadInsets" ) ; if ( selectedTabPadInsets == null ) { selectedTabPadInsets = new Insets ( 0 , 0 , 0 , 0 ) ; } if ( oldStyle != null ) { uninstallKeyboardActions ( ) ; installKeyboardActions ( ) ; } } context . dispose ( ) ; if ( tabContext != null ) { tabContext . dispose ( ) ; } tabContext = getContext ( c , Region . TABBED_PANE_TAB , ENABLED ) ; this . tabStyle = SeaGlassLookAndFeel . updateStyle ( tabContext , this ) ; tabInsets = tabStyle . getInsets ( tabContext , null ) ; if ( tabCloseContext != null ) { tabCloseContext . dispose ( ) ; } tabCloseContext = getContext ( c , SeaGlassRegion . TABBED_PANE_TAB_CLOSE_BUTTON , ENABLED ) ; this . tabCloseStyle = SeaGlassLookAndFeel . updateStyle ( tabCloseContext , this ) ; if ( tabAreaContext != null ) { tabAreaContext . dispose ( ) ; } tabAreaContext = getContext ( c , Region . TABBED_PANE_TAB_AREA , ENABLED ) ; this . tabAreaStyle = SeaGlassLookAndFeel . updateStyle ( tabAreaContext , this ) ; tabAreaInsets = tabAreaStyle . getInsets ( tabAreaContext , null ) ; if ( tabContentContext != null ) { tabContentContext . dispose ( ) ; } tabContentContext = getContext ( c , Region . TABBED_PANE_CONTENT , ENABLED ) ; this . tabContentStyle = SeaGlassLookAndFeel . updateStyle ( tabContentContext , this ) ; contentBorderInsets = tabContentStyle . getInsets ( tabContentContext , null ) ; } | Update the Synth styles when something changes . |
37,220 | protected void scrollBackward ( ) { int selectedIndex = tabPane . getSelectedIndex ( ) ; if ( -- selectedIndex < 0 ) { tabPane . setSelectedIndex ( tabPane . getTabCount ( ) == 0 ? - 1 : 0 ) ; } else { tabPane . setSelectedIndex ( selectedIndex ) ; } tabPane . repaint ( ) ; } | Scroll the tab buttons backwards . |
37,221 | protected void scrollForward ( ) { int selectedIndex = tabPane . getSelectedIndex ( ) ; if ( ++ selectedIndex >= tabPane . getTabCount ( ) ) { tabPane . setSelectedIndex ( tabPane . getTabCount ( ) - 1 ) ; } else { tabPane . setSelectedIndex ( selectedIndex ) ; } tabPane . repaint ( ) ; } | Scroll the tab buttons forwards . |
37,222 | public SeaGlassContext getContext ( JComponent c , int state ) { return SeaGlassContext . getContext ( SeaGlassContext . class , c , SeaGlassLookAndFeel . getRegion ( c ) , style , state ) ; } | Create a SynthContext for the component and state . Use the default region . |
37,223 | public SeaGlassContext getContext ( JComponent c , Region subregion ) { return getContext ( c , subregion , getComponentState ( c ) ) ; } | Create a SynthContext for the component and subregion . Use the current state . |
37,224 | private SeaGlassContext getContext ( JComponent c , Region subregion , int state ) { SynthStyle style = null ; Class klass = SeaGlassContext . class ; if ( subregion == Region . TABBED_PANE_TAB ) { style = tabStyle ; } else if ( subregion == Region . TABBED_PANE_TAB_AREA ) { style = tabAreaStyle ; } else if ( subregion == Region . TABBED_PANE_CONTENT ) { style = tabContentStyle ; } else if ( subregion == SeaGlassRegion . TABBED_PANE_TAB_CLOSE_BUTTON ) { style = tabCloseStyle ; } return SeaGlassContext . getContext ( klass , c , subregion , style , state ) ; } | Create a SynthContext for the component subregion and state . |
37,225 | public int getCloseButtonState ( JComponent c , int tabIndex , boolean tabIsMousedOver ) { if ( ! c . isEnabled ( ) ) { return DISABLED ; } else if ( tabIndex == closeButtonArmedIndex ) { return PRESSED ; } else if ( tabIndex == closeButtonHoverIndex ) { return FOCUSED ; } else if ( tabIsMousedOver ) { return MOUSE_OVER ; } return ENABLED ; } | Get the state for the specified tab s close button . |
37,226 | protected void paint ( SeaGlassContext context , Graphics g ) { int selectedIndex = tabPane . getSelectedIndex ( ) ; ensureCurrentLayout ( ) ; paintContentBorder ( tabContentContext , g , tabPlacement , selectedIndex ) ; paintTabArea ( g , tabPlacement , selectedIndex ) ; } | Paint the tabbed pane . |
37,227 | protected void paintTabArea ( SeaGlassContext ss , Graphics g , int tabPlacement , int selectedIndex , Rectangle tabAreaBounds ) { Rectangle clipRect = g . getClipBounds ( ) ; ss . setComponentState ( SynthConstants . ENABLED ) ; SeaGlassLookAndFeel . updateSubregion ( ss , g , tabAreaBounds ) ; ss . getPainter ( ) . paintTabbedPaneTabAreaBackground ( ss , g , tabAreaBounds . x , tabAreaBounds . y , tabAreaBounds . width , tabAreaBounds . height , tabPlacement ) ; ss . getPainter ( ) . paintTabbedPaneTabAreaBorder ( ss , g , tabAreaBounds . x , tabAreaBounds . y , tabAreaBounds . width , tabAreaBounds . height , tabPlacement ) ; iconRect . setBounds ( 0 , 0 , 0 , 0 ) ; textRect . setBounds ( 0 , 0 , 0 , 0 ) ; if ( runCount == 0 ) { return ; } if ( scrollBackwardButton . isVisible ( ) ) { paintScrollButtonBackground ( ss , g , scrollBackwardButton ) ; } if ( scrollForwardButton . isVisible ( ) ) { paintScrollButtonBackground ( ss , g , scrollForwardButton ) ; } for ( int i = leadingTabIndex ; i <= trailingTabIndex ; i ++ ) { if ( rects [ i ] . intersects ( clipRect ) && selectedIndex != i ) { paintTab ( tabContext , g , rects , i , iconRect , textRect ) ; } } if ( selectedIndex >= 0 ) { if ( rects [ selectedIndex ] . intersects ( clipRect ) ) { paintTab ( tabContext , g , rects , selectedIndex , iconRect , textRect ) ; } } } | Paint the tab area including the tabs . |
37,228 | protected void paintTab ( SeaGlassContext ss , Graphics g , Rectangle [ ] rects , int tabIndex , Rectangle iconRect , Rectangle textRect ) { Rectangle tabRect = rects [ tabIndex ] ; int selectedIndex = tabPane . getSelectedIndex ( ) ; boolean isSelected = selectedIndex == tabIndex ; JComponent b = ss . getComponent ( ) ; boolean flipSegments = ( orientation == ControlOrientation . HORIZONTAL && ! tabPane . getComponentOrientation ( ) . isLeftToRight ( ) ) ; String segmentPosition = "only" ; if ( tabPane . getTabCount ( ) > 1 ) { if ( tabIndex == 0 && tabIndex == leadingTabIndex ) { segmentPosition = flipSegments ? "last" : "first" ; } else if ( tabIndex == tabPane . getTabCount ( ) - 1 && tabIndex == trailingTabIndex ) { segmentPosition = flipSegments ? "first" : "last" ; } else { segmentPosition = "middle" ; } } b . putClientProperty ( "JTabbedPane.Tab.segmentPosition" , segmentPosition ) ; updateTabContext ( tabIndex , isSelected , isSelected && selectedTabIsPressed , getRolloverTab ( ) == tabIndex , getFocusIndex ( ) == tabIndex ) ; SeaGlassLookAndFeel . updateSubregion ( ss , g , tabRect ) ; int x = tabRect . x ; int y = tabRect . y ; int height = tabRect . height ; int width = tabRect . width ; tabContext . getPainter ( ) . paintTabbedPaneTabBackground ( tabContext , g , x , y , width , height , tabIndex , tabPlacement ) ; tabContext . getPainter ( ) . paintTabbedPaneTabBorder ( tabContext , g , x , y , width , height , tabIndex , tabPlacement ) ; if ( tabCloseButtonPlacement != CENTER ) { tabRect = paintCloseButton ( g , tabContext , tabIndex ) ; } if ( tabPane . getTabComponentAt ( tabIndex ) == null ) { String title = tabPane . getTitleAt ( tabIndex ) ; Font font = ss . getStyle ( ) . getFont ( ss ) ; FontMetrics metrics = SwingUtilities2 . getFontMetrics ( tabPane , g , font ) ; Icon icon = getIconForTab ( tabIndex ) ; layoutLabel ( ss , tabPlacement , metrics , tabIndex , title , icon , tabRect , iconRect , textRect , isSelected ) ; paintText ( ss , g , tabPlacement , font , metrics , tabIndex , title , textRect , isSelected ) ; paintIcon ( g , tabPlacement , tabIndex , icon , iconRect , isSelected ) ; } } | Paint a tab . |
37,229 | protected Rectangle paintCloseButton ( Graphics g , SynthContext tabContext , int tabIndex ) { Rectangle tabRect = new Rectangle ( rects [ tabIndex ] ) ; Rectangle bounds = getCloseButtonBounds ( tabIndex ) ; int offset = bounds . width + textIconGap ; boolean onLeft = isCloseButtonOnLeft ( ) ; if ( onLeft ) { tabRect . x += offset ; tabRect . width -= offset ; } else { tabRect . width -= offset ; } SeaGlassContext subcontext = getContext ( tabPane , SeaGlassRegion . TABBED_PANE_TAB_CLOSE_BUTTON , getCloseButtonState ( tabPane , tabIndex , ( tabContext . getComponentState ( ) & MOUSE_OVER ) != 0 ) ) ; SeaGlassLookAndFeel . updateSubregion ( subcontext , g , bounds ) ; SeaGlassSynthPainterImpl painter = ( SeaGlassSynthPainterImpl ) subcontext . getPainter ( ) ; painter . paintSearchButtonForeground ( subcontext , g , bounds . x , bounds . y , bounds . width , bounds . height ) ; subcontext . dispose ( ) ; return tabRect ; } | Paint the close button for a tab . |
37,230 | protected void paintScrollButtonBackground ( SeaGlassContext ss , Graphics g , JButton scrollButton ) { Rectangle tabRect = scrollButton . getBounds ( ) ; int x = tabRect . x ; int y = tabRect . y ; int height = tabRect . height ; int width = tabRect . width ; boolean flipSegments = ( orientation == ControlOrientation . HORIZONTAL && ! tabPane . getComponentOrientation ( ) . isLeftToRight ( ) ) ; SeaGlassLookAndFeel . updateSubregion ( ss , g , tabRect ) ; tabPane . putClientProperty ( "JTabbedPane.Tab.segmentPosition" , ( ( scrollButton == scrollBackwardButton ) ^ flipSegments ) ? "first" : "last" ) ; int oldState = tabContext . getComponentState ( ) ; ButtonModel model = scrollButton . getModel ( ) ; int isPressed = model . isPressed ( ) && model . isArmed ( ) ? PRESSED : 0 ; int buttonState = SeaGlassLookAndFeel . getComponentState ( scrollButton ) | isPressed ; tabContext . setComponentState ( buttonState ) ; tabContext . getPainter ( ) . paintTabbedPaneTabBackground ( tabContext , g , x , y , width , height , - 1 , tabPlacement ) ; tabContext . getPainter ( ) . paintTabbedPaneTabBorder ( tabContext , g , x , y , width , height , - 1 , tabPlacement ) ; tabContext . setComponentState ( oldState ) ; } | Paint the background for a tab scroll button . |
37,231 | protected void layoutLabel ( SeaGlassContext ss , int tabPlacement , FontMetrics metrics , int tabIndex , String title , Icon icon , Rectangle tabRect , Rectangle iconRect , Rectangle textRect , boolean isSelected ) { View v = getTextViewForTab ( tabIndex ) ; if ( v != null ) { tabPane . putClientProperty ( "html" , v ) ; } textRect . x = textRect . y = iconRect . x = iconRect . y = 0 ; ss . getStyle ( ) . getGraphicsUtils ( ss ) . layoutText ( ss , metrics , title , icon , SwingUtilities . CENTER , SwingUtilities . CENTER , SwingUtilities . LEADING , SwingUtilities . TRAILING , tabRect , iconRect , textRect , textIconGap ) ; tabPane . putClientProperty ( "html" , null ) ; int xNudge = getTabLabelShiftX ( tabPlacement , tabIndex , isSelected ) ; int yNudge = getTabLabelShiftY ( tabPlacement , tabIndex , isSelected ) ; iconRect . x += xNudge ; iconRect . y += yNudge ; textRect . x += xNudge ; textRect . y += yNudge ; } | Layout label text for a tab . |
37,232 | protected void paintText ( SeaGlassContext ss , Graphics g , int tabPlacement , Font font , FontMetrics metrics , int tabIndex , String title , Rectangle textRect , boolean isSelected ) { g . setFont ( font ) ; View v = getTextViewForTab ( tabIndex ) ; if ( v != null ) { v . paint ( g , textRect ) ; } else { int mnemIndex = tabPane . getDisplayedMnemonicIndexAt ( tabIndex ) ; FontMetrics fm = SwingUtilities2 . getFontMetrics ( tabPane , g ) ; title = SwingUtilities2 . clipStringIfNecessary ( tabPane , fm , title , textRect . width ) ; g . setColor ( ss . getStyle ( ) . getColor ( ss , ColorType . TEXT_FOREGROUND ) ) ; ss . getStyle ( ) . getGraphicsUtils ( ss ) . paintText ( ss , g , title , textRect , mnemIndex ) ; } } | Paint the label text for a tab . |
37,233 | protected void paintContentBorder ( SeaGlassContext ss , Graphics g , int tabPlacement , int selectedIndex ) { int width = tabPane . getWidth ( ) ; int height = tabPane . getHeight ( ) ; Insets insets = tabPane . getInsets ( ) ; int x = insets . left ; int y = insets . top ; int w = width - insets . right - insets . left ; int h = height - insets . top - insets . bottom ; switch ( tabPlacement ) { case LEFT : x += calculateTabAreaWidth ( tabPlacement , runCount , maxTabWidth ) ; w -= ( x - insets . left ) ; break ; case RIGHT : w -= calculateTabAreaWidth ( tabPlacement , runCount , maxTabWidth ) ; break ; case BOTTOM : h -= calculateTabAreaHeight ( tabPlacement , runCount , maxTabHeight ) ; break ; case TOP : default : y += calculateTabAreaHeight ( tabPlacement , runCount , maxTabHeight ) ; h -= ( y - insets . top ) ; } SeaGlassLookAndFeel . updateSubregion ( ss , g , new Rectangle ( x , y , w , h ) ) ; ss . getPainter ( ) . paintTabbedPaneContentBackground ( ss , g , x , y , w , h ) ; ss . getPainter ( ) . paintTabbedPaneContentBorder ( ss , g , x , y , w , h ) ; } | Paint the content pane s border . |
37,234 | private void ensureCurrentLayout ( ) { if ( ! tabPane . isValid ( ) ) { tabPane . validate ( ) ; } if ( ! tabPane . isValid ( ) ) { TabbedPaneLayout layout = ( TabbedPaneLayout ) tabPane . getLayout ( ) ; layout . calculateLayoutInfo ( ) ; } } | Make sure we have laid out the pane with the current layout . |
37,235 | private void updateTabContext ( int index , boolean selected , boolean isMouseDown , boolean isMouseOver , boolean hasFocus ) { int state = 0 ; if ( ! tabPane . isEnabled ( ) || ! tabPane . isEnabledAt ( index ) ) { state |= SynthConstants . DISABLED ; if ( selected ) { state |= SynthConstants . SELECTED ; } } else if ( selected ) { state |= ( SynthConstants . ENABLED | SynthConstants . SELECTED ) ; if ( isMouseOver && UIManager . getBoolean ( "TabbedPane.isTabRollover" ) ) { state |= SynthConstants . MOUSE_OVER ; } } else if ( isMouseOver ) { state |= ( SynthConstants . ENABLED | SynthConstants . MOUSE_OVER ) ; } else { state = SeaGlassLookAndFeel . getComponentState ( tabPane ) ; state &= ~ SynthConstants . FOCUSED ; } if ( hasFocus && tabPane . hasFocus ( ) ) { state |= SynthConstants . FOCUSED ; } if ( isMouseDown ) { state |= SynthConstants . PRESSED ; } tabContext . setComponentState ( state ) ; } | Update the SynthContext for the tab area for a specified tab . |
37,236 | protected boolean isOverCloseButton ( int x , int y ) { if ( tabCloseButtonPlacement != CENTER ) { int tabCount = tabPane . getTabCount ( ) ; for ( int i = 0 ; i < tabCount ; i ++ ) { if ( getCloseButtonBounds ( i ) . contains ( x , y ) ) { closeButtonHoverIndex = i ; return true ; } } } closeButtonHoverIndex = - 1 ; return false ; } | Determine whether the mouse is over a tab close button and if so set the hover index . |
37,237 | protected Rectangle getCloseButtonBounds ( int tabIndex ) { Rectangle bounds = new Rectangle ( rects [ tabIndex ] ) ; bounds . width = closeButtonSize ; bounds . height = closeButtonSize ; bounds . y += ( rects [ tabIndex ] . height - closeButtonSize - closeButtonInsets . top - closeButtonInsets . bottom ) / 2 + closeButtonInsets . top ; boolean onLeft = isCloseButtonOnLeft ( ) ; if ( onLeft ) { int offset = orientation == ControlOrientation . VERTICAL || tabIndex == 0 ? 6 : 3 ; bounds . x += offset ; } else { int offset = orientation == ControlOrientation . VERTICAL || tabIndex == tabPane . getTabCount ( ) - 1 ? 6 : 4 ; bounds . x += rects [ tabIndex ] . width - bounds . width - offset ; } return bounds ; } | Get the bounds for a tab close button . |
37,238 | protected void doClose ( int tabIndex ) { if ( tabCloseListener == null || tabCloseListener . tabAboutToBeClosed ( tabIndex ) ) { String title = tabPane . getTitleAt ( tabIndex ) ; Component component = tabPane . getComponentAt ( tabIndex ) ; tabPane . removeTabAt ( tabIndex ) ; if ( tabCloseListener != null ) { tabCloseListener . tabClosed ( title , component ) ; } } } | Called when a close tab button is pressed . |
37,239 | private void paintCheckIconDisabledAndSelected ( Graphics2D g , int width , int height ) { Shape s = shapeGenerator . createCheckMark ( 0 , 0 , width , height ) ; g . setPaint ( iconDisabledSelected ) ; g . fill ( s ) ; } | Paint the check mark in disabled state . |
37,240 | public void initialize ( ) { super . initialize ( ) ; setStyleFactory ( new SynthStyleFactory ( ) { public SynthStyle getStyle ( JComponent c , Region r ) { SynthStyle style = getSeaGlassStyle ( c , r ) ; if ( ! ( style instanceof SeaGlassStyle ) ) { style = new SeaGlassStyleWrapper ( style ) ; } return style ; } } ) ; } | Called by UIManager when this look and feel is installed . |
37,241 | public UIDefaults getDefaults ( ) { if ( uiDefaults == null ) { uiDefaults = new UIWrapper ( super . getDefaults ( ) ) ; if ( PlatformUtils . isWindows ( ) ) { WindowsKeybindings . installKeybindings ( uiDefaults ) ; } else if ( PlatformUtils . isMac ( ) ) { MacKeybindings . installKeybindings ( uiDefaults ) ; } else { GTKKeybindings . installKeybindings ( uiDefaults ) ; } defineDefaultFont ( uiDefaults ) ; useOurUIs ( ) ; defineBaseColors ( uiDefaults ) ; defineDefaultBorders ( uiDefaults ) ; defineArrowButtons ( uiDefaults ) ; defineButtons ( uiDefaults ) ; defineComboBoxes ( uiDefaults ) ; defineDesktopPanes ( uiDefaults ) ; defineInternalFrames ( uiDefaults ) ; defineInternalFrameMenuButtons ( uiDefaults ) ; defineInternalFrameCloseButtons ( uiDefaults ) ; defineInternalFrameIconifyButtons ( uiDefaults ) ; defineInternalFrameMaximizeButton ( uiDefaults ) ; defineLists ( uiDefaults ) ; defineMenus ( uiDefaults ) ; definePanels ( uiDefaults ) ; definePopups ( uiDefaults ) ; defineProgressBars ( uiDefaults ) ; defineRootPanes ( uiDefaults ) ; defineSeparators ( uiDefaults ) ; defineSpinners ( uiDefaults ) ; defineScrollBars ( uiDefaults ) ; defineScrollPane ( uiDefaults ) ; defineSliders ( uiDefaults ) ; defineSplitPanes ( uiDefaults ) ; defineTabbedPanes ( uiDefaults ) ; defineTables ( uiDefaults ) ; defineTextControls ( uiDefaults ) ; defineToolBars ( uiDefaults ) ; defineTrees ( uiDefaults ) ; defineToolTips ( uiDefaults ) ; defineOptionPane ( uiDefaults ) ; defineFileChooser ( uiDefaults ) ; if ( ! PlatformUtils . isMac ( ) ) { uiDefaults . put ( "MenuBar[Enabled].backgroundPainter" , null ) ; uiDefaults . put ( "MenuBar[Enabled].borderPainter" , null ) ; JFrame . setDefaultLookAndFeelDecorated ( true ) ; JDialog . setDefaultLookAndFeelDecorated ( true ) ; } else { System . setProperty ( "apple.laf.useScreenMenuBar" , "true" ) ; defineAquaSettings ( uiDefaults ) ; } } return uiDefaults ; } | Returns the defaults for SeaGlassLookAndFeel . |
37,242 | private void defineToolTips ( UIDefaults d ) { String p = "ToolTip" ; d . put ( "seaGlassToolTipBorder" , new Color ( 0x5b7ea4 ) ) ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 4 , 4 , 4 , 4 ) ) ; d . put ( p + ".opaque" , Boolean . FALSE ) ; d . put ( p + ".background" , new ColorUIResource ( 0xd5 , 0xe8 , 0xf7 ) ) ; d . put ( p + ".backgroundPainter" , new ToolTipPainter ( ToolTipPainter . Which . BORDER_ENABLED ) ) ; } | Define some settings for tool tips . |
37,243 | private void useOurUIs ( ) { for ( String uiName : UI_LIST ) { uiName = uiName + "UI" ; uiDefaults . put ( uiName , UI_PACKAGE_PREFIX + uiName ) ; } } | Use our UI delegate for the specified UI control type . |
37,244 | protected Font initializeDefaultFont ( ) { if ( defaultFont == null ) { if ( PlatformUtils . isMac ( ) ) { defaultFont = new Font ( "Lucida Grande" , Font . PLAIN , 13 ) ; } if ( defaultFont == null ) { defaultFont = new Font ( "Dialog" , Font . PLAIN , 13 ) ; } if ( defaultFont == null ) { defaultFont = new Font ( "SansSerif" , Font . PLAIN , 13 ) ; } } return defaultFont ; } | Initialize the default font . |
37,245 | private void defineAquaSettings ( UIDefaults d ) { try { Class < ? > lnfClass = Class . forName ( UIManager . getSystemLookAndFeelClassName ( ) , true , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; LookAndFeel aqua = ( LookAndFeel ) lnfClass . newInstance ( ) ; UIDefaults aquaDefaults = aqua . getDefaults ( ) ; d . put ( "MenuBarUI" , aquaDefaults . get ( "MenuBarUI" ) ) ; d . put ( "MenuUI" , aquaDefaults . get ( "MenuUI" ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } | Use Aqua settings for some properties if we re on a Mac . |
37,246 | private void defineArrowButtons ( UIDefaults d ) { String c = PAINTER_PREFIX + "ArrowButtonPainter" ; String p = "ArrowButton" ; d . put ( p + ".States" , "Enabled,MouseOver,Disabled,Pressed" ) ; d . put ( p + "[Disabled].foreground" , new ColorUIResource ( 0x9ba8cf ) ) ; d . put ( p + "[Enabled].foreground" , new ColorUIResource ( 0x5b7ea4 ) ) ; d . put ( p + "[Pressed].foreground" , new ColorUIResource ( 0x134D8C ) ) ; d . put ( p + "[Disabled].foregroundPainter" , new LazyPainter ( c , ArrowButtonPainter . Which . FOREGROUND_DISABLED ) ) ; d . put ( p + "[Enabled].foregroundPainter" , new LazyPainter ( c , ArrowButtonPainter . Which . FOREGROUND_ENABLED ) ) ; d . put ( p + "[MouseOver].foregroundPainter" , new LazyPainter ( c , ArrowButtonPainter . Which . FOREGROUND_ENABLED ) ) ; d . put ( p + "[Pressed].foregroundPainter" , new LazyPainter ( c , ArrowButtonPainter . Which . FOREGROUND_PRESSED ) ) ; } | Initialize the arrow button settings . |
37,247 | private void defineDesktopPanes ( UIDefaults d ) { d . put ( "seaGlassDesktopPane" , new ColorUIResource ( 0x556ba6 ) ) ; String c = PAINTER_PREFIX + "DesktopPanePainter" ; String p = "DesktopPane" ; d . put ( p + "[Enabled].backgroundPainter" , new LazyPainter ( c , DesktopPanePainter . Which . BACKGROUND_ENABLED ) ) ; p = "DesktopIcon" ; c = PAINTER_PREFIX + "DesktopIconPainter" ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 0 , 6 , 5 , 4 ) ) ; d . put ( p + "[Enabled].backgroundPainter" , new LazyPainter ( c , DesktopIconPainter . Which . BACKGROUND_ENABLED ) ) ; } | Initialize the desktop pane UI settings . |
37,248 | private void defineInternalFrameCloseButtons ( UIDefaults d ) { String p = "InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.closeButton\"" ; String c = PAINTER_PREFIX + "TitlePaneCloseButtonPainter" ; d . put ( p + ".States" , "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,WindowNotFocused" ) ; d . put ( p + ".WindowNotFocused" , new TitlePaneCloseButtonWindowNotFocusedState ( ) ) ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 0 , 0 , 0 , 0 ) ) ; d . put ( p + "[Disabled].backgroundPainter" , new LazyPainter ( c , TitlePaneCloseButtonPainter . Which . BACKGROUND_DISABLED ) ) ; d . put ( p + "[Enabled].backgroundPainter" , new LazyPainter ( c , TitlePaneCloseButtonPainter . Which . BACKGROUND_ENABLED ) ) ; d . put ( p + "[MouseOver].backgroundPainter" , new LazyPainter ( c , TitlePaneCloseButtonPainter . Which . BACKGROUND_MOUSEOVER ) ) ; d . put ( p + "[Pressed].backgroundPainter" , new LazyPainter ( c , TitlePaneCloseButtonPainter . Which . BACKGROUND_PRESSED ) ) ; d . put ( p + "[Enabled+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneCloseButtonPainter . Which . BACKGROUND_ENABLED_WINDOWNOTFOCUSED ) ) ; d . put ( p + "[MouseOver+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneCloseButtonPainter . Which . BACKGROUND_MOUSEOVER ) ) ; d . put ( p + "[Pressed+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneCloseButtonPainter . Which . BACKGROUND_PRESSED_WINDOWNOTFOCUSED ) ) ; d . put ( p + ".icon" , new SeaGlassIcon ( p , "iconPainter" , 43 , 18 ) ) ; } | Initialize the internal frame close button settings . |
37,249 | private void defineInternalFrameIconifyButtons ( UIDefaults d ) { String p = "InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.iconifyButton\"" ; String c = PAINTER_PREFIX + "TitlePaneIconifyButtonPainter" ; d . put ( p + ".States" , "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,WindowNotFocused,WindowMinimized" ) ; d . put ( p + ".WindowNotFocused" , new TitlePaneIconifyButtonWindowNotFocusedState ( ) ) ; d . put ( p + ".WindowMinimized" , new TitlePaneIconifyButtonWindowMinimizedState ( ) ) ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 0 , 0 , 0 , 0 ) ) ; d . put ( p + "[Enabled].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_ENABLED ) ) ; d . put ( p + "[Disabled].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_DISABLED ) ) ; d . put ( p + "[MouseOver].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_MOUSEOVER ) ) ; d . put ( p + "[Pressed].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_PRESSED ) ) ; d . put ( p + "[Enabled+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_ENABLED_WINDOWNOTFOCUSED ) ) ; d . put ( p + "[MouseOver+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_MOUSEOVER_WINDOWNOTFOCUSED ) ) ; d . put ( p + "[Pressed+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_PRESSED_WINDOWNOTFOCUSED ) ) ; d . put ( p + "[Disabled+WindowMinimized].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_MINIMIZED_DISABLED ) ) ; d . put ( p + "[Enabled+WindowMinimized].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_MINIMIZED_ENABLED ) ) ; d . put ( p + "[MouseOver+WindowMinimized].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_MINIMIZED_MOUSEOVER ) ) ; d . put ( p + "[Pressed+WindowMinimized].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_MINIMIZED_PRESSED ) ) ; d . put ( p + "[Enabled+WindowMinimized+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_MINIMIZED_ENABLED_WINDOWNOTFOCUSED ) ) ; d . put ( p + "[MouseOver+WindowMinimized+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_MINIMIZED_MOUSEOVER_WINDOWNOTFOCUSED ) ) ; d . put ( p + "[Pressed+WindowMinimized+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneIconifyButtonPainter . Which . BACKGROUND_MINIMIZED_PRESSED_WINDOWNOTFOCUSED ) ) ; d . put ( p + ".icon" , new SeaGlassIcon ( p , "iconPainter" , 26 , 18 ) ) ; } | Initialize the internal frame iconify button settings . |
37,250 | private void defineInternalFrameMaximizeButton ( UIDefaults d ) { String p = "InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.maximizeButton\"" ; String c = PAINTER_PREFIX + "TitlePaneMaximizeButtonPainter" ; d . put ( p + ".WindowNotFocused" , new TitlePaneMaximizeButtonWindowNotFocusedState ( ) ) ; d . put ( p + ".WindowMaximized" , new TitlePaneMaximizeButtonWindowMaximizedState ( ) ) ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 0 , 0 , 0 , 0 ) ) ; d . put ( p + "[Disabled].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_DISABLED ) ) ; d . put ( p + "[Enabled].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_ENABLED ) ) ; d . put ( p + "[MouseOver].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_MOUSEOVER ) ) ; d . put ( p + "[Pressed].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_PRESSED ) ) ; d . put ( p + "[Enabled+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_ENABLED_WINDOWNOTFOCUSED ) ) ; d . put ( p + "[MouseOver+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_MOUSEOVER_WINDOWNOTFOCUSED ) ) ; d . put ( p + "[Pressed+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_PRESSED_WINDOWNOTFOCUSED ) ) ; d . put ( p + "[Disabled+WindowMaximized].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_MAXIMIZED_DISABLED ) ) ; d . put ( p + "[Enabled+WindowMaximized].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_MAXIMIZED_ENABLED ) ) ; d . put ( p + "[MouseOver+WindowMaximized].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_MAXIMIZED_MOUSEOVER ) ) ; d . put ( p + "[Pressed+WindowMaximized].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_MAXIMIZED_PRESSED ) ) ; d . put ( p + "[Enabled+WindowMaximized+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_MAXIMIZED_ENABLED_WINDOWNOTFOCUSED ) ) ; d . put ( p + "[MouseOver+WindowMaximized+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_MAXIMIZED_MOUSEOVER_WINDOWNOTFOCUSED ) ) ; d . put ( p + "[Pressed+WindowMaximized+WindowNotFocused].backgroundPainter" , new LazyPainter ( c , TitlePaneMaximizeButtonPainter . Which . BACKGROUND_MAXIMIZED_PRESSED_WINDOWNOTFOCUSED ) ) ; d . put ( p + ".icon" , new SeaGlassIcon ( p , "iconPainter" , 25 , 18 ) ) ; } | Initialize the internal frame maximize button settings . |
37,251 | private void defineInternalFrameMenuButtons ( UIDefaults d ) { String p = "InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.menuButton\"" ; String c = PAINTER_PREFIX + "TitlePaneMenuButtonPainter" ; d . put ( p + ".WindowNotFocused" , new TitlePaneMenuButtonWindowNotFocusedState ( ) ) ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 0 , 0 , 0 , 0 ) ) ; d . put ( p + "[Enabled].iconPainter" , new LazyPainter ( c , TitlePaneMenuButtonPainter . Which . ICON_ENABLED ) ) ; d . put ( p + "[Disabled].iconPainter" , new LazyPainter ( c , TitlePaneMenuButtonPainter . Which . ICON_DISABLED ) ) ; d . put ( p + "[MouseOver].iconPainter" , new LazyPainter ( c , TitlePaneMenuButtonPainter . Which . ICON_MOUSEOVER ) ) ; d . put ( p + "[Pressed].iconPainter" , new LazyPainter ( c , TitlePaneMenuButtonPainter . Which . ICON_PRESSED ) ) ; d . put ( p + "[Enabled+WindowNotFocused].iconPainter" , new LazyPainter ( c , TitlePaneMenuButtonPainter . Which . ICON_ENABLED_WINDOWNOTFOCUSED ) ) ; d . put ( p + "[MouseOver+WindowNotFocused].iconPainter" , new LazyPainter ( c , TitlePaneMenuButtonPainter . Which . ICON_MOUSEOVER_WINDOWNOTFOCUSED ) ) ; d . put ( p + "[Pressed+WindowNotFocused].iconPainter" , new LazyPainter ( c , TitlePaneMenuButtonPainter . Which . ICON_PRESSED_WINDOWNOTFOCUSED ) ) ; d . put ( p + ".icon" , new SeaGlassIcon ( p , "iconPainter" , 19 , 18 ) ) ; } | Initialize the internal frame menu button settings . |
37,252 | private void defineLists ( UIDefaults d ) { String p = "List" ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 0 , 0 , 0 , 0 ) ) ; d . put ( p + ".opaque" , Boolean . TRUE ) ; d . put ( p + ".background" , d . get ( "seaGlassLightBackground" ) ) ; d . put ( p + ".dropLineColor" , d . get ( "seaGlassFocus" ) ) ; d . put ( p + ".rendererUseListColors" , Boolean . TRUE ) ; d . put ( p + ".rendererUseUIBorder" , Boolean . TRUE ) ; d . put ( p + ".cellNoFocusBorder" , new BorderUIResource ( BorderFactory . createEmptyBorder ( 2 , 5 , 2 , 5 ) ) ) ; d . put ( p + ".focusCellHighlightBorder" , new BorderUIResource ( new PainterBorder ( "Tree:TreeCell[Enabled+Focused].backgroundPainter" , new Insets ( 2 , 5 , 2 , 5 ) ) ) ) ; d . put ( p + "[Selected].textForeground" , Color . WHITE ) ; d . put ( p + "[Selected].textBackground" , d . get ( "seaGlassSelection" ) ) ; d . put ( p + "[Disabled+Selected].textBackground" , Color . WHITE ) ; d . put ( p + "[Disabled].textForeground" , d . get ( "seaGlassDisabledText" ) ) ; p = "List:\"List.cellRenderer\"" ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 0 , 0 , 0 , 0 ) ) ; d . put ( p + ".opaque" , Boolean . TRUE ) ; d . put ( p + "[Disabled].textForeground" , d . get ( "seaGlassDisabledText" ) ) ; d . put ( p + "[Disabled].background" , d . get ( "seaGlassSelectionBackground" ) ) ; } | Initialize the list settings . |
37,253 | private void definePanels ( UIDefaults d ) { String p = "Panel" ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 0 , 0 , 0 , 0 ) ) ; d . put ( p + ".background" , new ColorUIResource ( ( Color ) d . get ( "control" ) ) ) ; d . put ( p + ".opaque" , Boolean . TRUE ) ; } | Initialize the panel settings . |
37,254 | private void definePopups ( UIDefaults d ) { d . put ( "seaGlassPopupBorder" , new ColorUIResource ( 0xbbbbbb ) ) ; d . put ( "popupMenuInteriorEnabled" , Color . WHITE ) ; d . put ( "popupMenuBorderEnabled" , new Color ( 0x5b7ea4 ) ) ; String c = PAINTER_PREFIX + "PopupMenuPainter" ; String p = "PopupMenu" ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 6 , 1 , 6 , 1 ) ) ; d . put ( p + ".opaque" , Boolean . TRUE ) ; d . put ( p + ".consumeEventOnClose" , Boolean . TRUE ) ; d . put ( p + "[Disabled].backgroundPainter" , new LazyPainter ( c , PopupMenuPainter . Which . BACKGROUND_DISABLED ) ) ; d . put ( p + "[Enabled].backgroundPainter" , new LazyPainter ( c , PopupMenuPainter . Which . BACKGROUND_ENABLED ) ) ; c = PAINTER_PREFIX + "SeparatorPainter" ; p = "PopupMenuSeparator" ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 1 , 0 , 2 , 0 ) ) ; d . put ( p + "[Enabled].backgroundPainter" , new LazyPainter ( c , SeparatorPainter . Which . BACKGROUND_ENABLED ) ) ; } | Initialize the popup settings . |
37,255 | private void defineProgressBars ( UIDefaults d ) { d . put ( "ProgressBar.contentMargins" , new InsetsUIResource ( 0 , 0 , 0 , 0 ) ) ; d . put ( "ProgressBar.States" , "Enabled,Disabled,Indeterminate,Finished" ) ; d . put ( "ProgressBar.tileWhenIndeterminate" , Boolean . TRUE ) ; d . put ( "ProgressBar.paintOutsideClip" , Boolean . TRUE ) ; d . put ( "ProgressBar.rotateText" , Boolean . TRUE ) ; d . put ( "ProgressBar.vertictalSize" , new DimensionUIResource ( 19 , 150 ) ) ; d . put ( "ProgressBar.horizontalSize" , new DimensionUIResource ( 150 , 19 ) ) ; addColor ( d , "ProgressBar[Disabled].textForeground" , "seaGlassDisabledText" , 0.0f , 0.0f , 0.0f , 0 ) ; d . put ( "ProgressBar[Disabled+Indeterminate].progressPadding" , new Integer ( 3 ) ) ; d . put ( "progressBarTrackInterior" , Color . WHITE ) ; d . put ( "progressBarTrackBase" , new Color ( 0x4076bf ) ) ; d . put ( "ProgressBar.Indeterminate" , new ProgressBarIndeterminateState ( ) ) ; d . put ( "ProgressBar.Finished" , new ProgressBarFinishedState ( ) ) ; String p = "ProgressBar" ; String c = PAINTER_PREFIX + "ProgressBarPainter" ; d . put ( p + ".cycleTime" , 500 ) ; d . put ( p + ".progressPadding" , new Integer ( 3 ) ) ; d . put ( p + ".trackThickness" , new Integer ( 19 ) ) ; d . put ( p + ".tileWidth" , new Integer ( 24 ) ) ; d . put ( p + ".backgroundFillColor" , Color . WHITE ) ; d . put ( p + ".font" , new DerivedFont ( "defaultFont" , 0.769f , null , null ) ) ; d . put ( p + "[Enabled].backgroundPainter" , new LazyPainter ( c , ProgressBarPainter . Which . BACKGROUND_ENABLED ) ) ; d . put ( p + "[Disabled].backgroundPainter" , new LazyPainter ( c , ProgressBarPainter . Which . BACKGROUND_DISABLED ) ) ; d . put ( p + "[Enabled].foregroundPainter" , new LazyPainter ( c , ProgressBarPainter . Which . FOREGROUND_ENABLED ) ) ; d . put ( p + "[Enabled+Finished].foregroundPainter" , new LazyPainter ( c , ProgressBarPainter . Which . FOREGROUND_ENABLED_FINISHED ) ) ; d . put ( p + "[Enabled+Indeterminate].foregroundPainter" , new LazyPainter ( c , ProgressBarPainter . Which . FOREGROUND_ENABLED_INDETERMINATE ) ) ; d . put ( p + "[Disabled].foregroundPainter" , new LazyPainter ( c , ProgressBarPainter . Which . FOREGROUND_DISABLED ) ) ; d . put ( p + "[Disabled+Finished].foregroundPainter" , new LazyPainter ( c , ProgressBarPainter . Which . FOREGROUND_DISABLED_FINISHED ) ) ; d . put ( p + "[Disabled+Indeterminate].foregroundPainter" , new LazyPainter ( c , ProgressBarPainter . Which . FOREGROUND_DISABLED_INDETERMINATE ) ) ; } | Initialize the progress bar settings . |
37,256 | private void defineRootPanes ( UIDefaults d ) { String c = PAINTER_PREFIX + "FrameAndRootPainter" ; String p = "RootPane" ; d . put ( p + ".States" , "Enabled,WindowFocused,NoFrame" ) ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 0 , 0 , 0 , 0 ) ) ; d . put ( p + ".opaque" , Boolean . FALSE ) ; d . put ( p + ".NoFrame" , new RootPaneNoFrameState ( ) ) ; d . put ( p + ".WindowFocused" , new RootPaneWindowFocusedState ( ) ) ; d . put ( p + "[Enabled+NoFrame].backgroundPainter" , new LazyPainter ( c , FrameAndRootPainter . Which . BACKGROUND_ENABLED_NOFRAME ) ) ; d . put ( p + "[Enabled].backgroundPainter" , new LazyPainter ( c , FrameAndRootPainter . Which . BACKGROUND_ENABLED ) ) ; d . put ( p + "[Enabled+WindowFocused].backgroundPainter" , new LazyPainter ( c , FrameAndRootPainter . Which . BACKGROUND_ENABLED_WINDOWFOCUSED ) ) ; } | Initialize the root pane settings . |
37,257 | private void defineScrollPane ( UIDefaults d ) { String c = PAINTER_PREFIX + "ScrollPanePainter" ; String p = "ScrollPane" ; d . put ( p + ".opaque" , Boolean . FALSE ) ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 3 , 3 , 3 , 3 ) ) ; d . put ( p + ".backgroundPainter" , new LazyPainter ( c , ScrollPanePainter . Which . BACKGROUND_ENABLED ) ) ; d . put ( p + "[Enabled+Focused].borderPainter" , new LazyPainter ( c , ScrollPanePainter . Which . BORDER_ENABLED_FOCUSED ) ) ; d . put ( p + "[Enabled].borderPainter" , new LazyPainter ( c , ScrollPanePainter . Which . BORDER_ENABLED ) ) ; d . put ( p + ".cornerPainter" , new LazyPainter ( c , ScrollPanePainter . Which . CORNER_ENABLED ) ) ; p = "Viewport" ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 0 , 0 , 0 , 0 ) ) ; d . put ( p + ".opaque" , Boolean . TRUE ) ; } | Initialize the scroll pane UI |
37,258 | private void defineSeparators ( UIDefaults d ) { String c = PAINTER_PREFIX + "SeparatorPainter" ; d . put ( "Separator.contentMargins" , new InsetsUIResource ( 0 , 0 , 0 , 0 ) ) ; d . put ( "Separator[Enabled].backgroundPainter" , new LazyPainter ( c , SeparatorPainter . Which . BACKGROUND_ENABLED ) ) ; } | Initialize the separator settings . |
37,259 | private void defineSplitPanes ( UIDefaults d ) { d . put ( "splitPaneDividerBackgroundOuter" , new Color ( 0xd9d9d9 ) ) ; String p = "SplitPane" ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 1 , 1 , 1 , 1 ) ) ; d . put ( p + ".States" , "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Vertical" ) ; d . put ( p + ".Vertical" , new SplitPaneVerticalState ( ) ) ; d . put ( p + ".size" , new Integer ( 11 ) ) ; d . put ( p + ".dividerSize" , new Integer ( 11 ) ) ; d . put ( p + ".centerOneTouchButtons" , Boolean . TRUE ) ; d . put ( p + ".oneTouchButtonOffset" , new Integer ( 20 ) ) ; d . put ( p + ".oneTouchButtonVOffset" , new Integer ( 3 ) ) ; d . put ( p + ".oneTouchExpandable" , Boolean . FALSE ) ; d . put ( p + ".continuousLayout" , Boolean . TRUE ) ; String c = PAINTER_PREFIX + "SplitPaneDividerPainter" ; p = "SplitPane:SplitPaneDivider" ; d . put ( p + ".contentMargins" , new InsetsUIResource ( 0 , 0 , 0 , 0 ) ) ; d . put ( p + ".States" , "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Vertical" ) ; d . put ( p + ".Vertical" , new SplitPaneDividerVerticalState ( ) ) ; d . put ( p + "[Enabled].backgroundPainter" , new LazyPainter ( c , SplitPaneDividerPainter . Which . BACKGROUND_ENABLED ) ) ; d . put ( p + "[Focused].backgroundPainter" , new LazyPainter ( c , SplitPaneDividerPainter . Which . BACKGROUND_FOCUSED ) ) ; d . put ( p + "[Enabled].foregroundPainter" , new LazyPainter ( c , SplitPaneDividerPainter . Which . FOREGROUND_ENABLED ) ) ; d . put ( p + "[Focused].foregroundPainter" , new LazyPainter ( c , SplitPaneDividerPainter . Which . FOREGROUND_FOCUSED ) ) ; d . put ( p + "[Enabled+Vertical].foregroundPainter" , new LazyPainter ( c , SplitPaneDividerPainter . Which . FOREGROUND_ENABLED_VERTICAL ) ) ; d . put ( p + "[Focused+Vertical].foregroundPainter" , new LazyPainter ( c , SplitPaneDividerPainter . Which . FOREGROUND_FOCUSED_VERTICAL ) ) ; } | Initialize the split pane UI settings . |
37,260 | public static Insets getPaintingInsets ( SynthContext state , Insets insets ) { if ( state . getRegion ( ) . isSubregion ( ) ) { insets = state . getStyle ( ) . getInsets ( state , insets ) ; } else { insets = state . getComponent ( ) . getInsets ( insets ) ; } return insets ; } | A convenience method to return where the foreground should be painted for the Component identified by the passed in AbstractSynthContext . |
37,261 | public static Object resolveToolbarConstraint ( JToolBar toolbar ) { if ( toolbar != null ) { Container parent = toolbar . getParent ( ) ; if ( parent != null ) { LayoutManager m = parent . getLayout ( ) ; if ( m instanceof BorderLayout ) { BorderLayout b = ( BorderLayout ) m ; Object con = b . getConstraints ( toolbar ) ; if ( con == SOUTH || con == EAST || con == WEST ) { return con ; } return NORTH ; } } } return NORTH ; } | Package private method which returns either BorderLayout . NORTH BorderLayout . SOUTH BorderLayout . EAST or BorderLayout . WEST depending on the location of the toolbar in its parent . The toolbar might be in PAGE_START PAGE_END CENTER or some other position but will be resolved to either NORTH SOUTH EAST or WEST based on where the toolbar actually IS with CENTER being NORTH . |
37,262 | public void register ( Region region , String prefix ) { if ( region == null || prefix == null ) { throw new IllegalArgumentException ( "Neither Region nor Prefix may be null" ) ; } List < LazyStyle > styles = styleMap . get ( region ) ; if ( styles == null ) { styles = new LinkedList < LazyStyle > ( ) ; styles . add ( new LazyStyle ( prefix ) ) ; styleMap . put ( region , styles ) ; } else { for ( LazyStyle s : styles ) { if ( prefix . equals ( s . prefix ) ) { return ; } } styles . add ( new LazyStyle ( prefix ) ) ; } registeredRegions . put ( region . getName ( ) , region ) ; } | Registers the given region and prefix . The prefix if it contains quoted sections refers to certain named components . If there are not quoted sections then the prefix refers to a generic component type . |
37,263 | SynthStyle getSeaGlassStyle ( JComponent c , Region r ) { if ( c == null || r == null ) { throw new IllegalArgumentException ( "Neither comp nor r may be null" ) ; } List < LazyStyle > styles = styleMap . get ( r ) ; if ( styles == null || styles . size ( ) == 0 ) { return getDefaultStyle ( ) ; } LazyStyle foundStyle = null ; for ( LazyStyle s : styles ) { if ( s . matches ( c ) ) { if ( foundStyle == null || ( foundStyle . parts . length < s . parts . length ) || ( foundStyle . parts . length == s . parts . length && foundStyle . simple && ! s . simple ) ) { foundStyle = s ; } } } return foundStyle == null ? getDefaultStyle ( ) : foundStyle . getStyle ( c ) ; } | Locate the style associated with the given region and component . This is called from SeaGlassLookAndFeel in the SynthStyleFactory implementation . |
37,264 | public static int getComponentState ( Component c ) { if ( c . isEnabled ( ) ) { if ( c . isFocusOwner ( ) ) { return SeaglassUI . ENABLED | SeaglassUI . FOCUSED ; } return SeaglassUI . ENABLED ; } return SeaglassUI . DISABLED ; } | Returns the component state for the specified component . This should only be used for Components that don t have any special state beyond that of ENABLED DISABLED or FOCUSED . For example buttons shouldn t call into this method . |
37,265 | public static void updateSubregion ( SynthContext state , Graphics g , Rectangle bounds ) { paintRegion ( state , g , bounds ) ; } | A convenience method that handles painting of the background for subregions . All SynthUI s that have subregions should invoke this method than paint the foreground . |
37,266 | private static void paintRegion ( SynthContext state , Graphics g , Rectangle bounds ) { JComponent c = state . getComponent ( ) ; SynthStyle style = state . getStyle ( ) ; int x ; int y ; int width ; int height ; if ( bounds == null ) { x = 0 ; y = 0 ; width = c . getWidth ( ) ; height = c . getHeight ( ) ; } else { x = bounds . x ; y = bounds . y ; width = bounds . width ; height = bounds . height ; } boolean subregion = state . getRegion ( ) . isSubregion ( ) ; if ( ( subregion && style . isOpaque ( state ) ) || ( ! subregion && c . isOpaque ( ) ) ) { g . setColor ( style . getColor ( state , ColorType . BACKGROUND ) ) ; g . fillRect ( x , y , width , height ) ; } } | Paint a region . |
37,267 | public DerivedColor getDerivedColor ( String parentUin , float hOffset , float sOffset , float bOffset , int aOffset , boolean uiResource ) { return getDerivedColor ( null , parentUin , hOffset , sOffset , bOffset , aOffset , uiResource ) ; } | Get a derived color derived colors are shared instances and will be updated when its parent UIDefault color changes . |
37,268 | protected final Color getDerivedColor ( Color color1 , Color color2 , float midPoint , boolean uiResource ) { int argb = deriveARGB ( color1 , color2 , midPoint ) ; if ( uiResource ) { return new ColorUIResource ( argb ) ; } else { return new Color ( argb ) ; } } | Decodes and returns a color which is derived from an offset between two other colors . |
37,269 | private int getPadForLabel ( int i ) { Dictionary dictionary = slider . getLabelTable ( ) ; int pad = 0 ; Object o = dictionary . get ( i ) ; if ( o != null ) { Component c = ( Component ) o ; int centerX = xPositionForValue ( i ) ; int cHalfWidth = c . getPreferredSize ( ) . width / 2 ; if ( centerX - cHalfWidth < insetCache . left ) { pad = Math . max ( pad , insetCache . left - ( centerX - cHalfWidth ) ) ; } if ( centerX + cHalfWidth > slider . getWidth ( ) - insetCache . right ) { pad = Math . max ( pad , ( centerX + cHalfWidth ) - ( slider . getWidth ( ) - insetCache . right ) ) ; } } return pad ; } | Calculates the pad for the label at the specified index . |
37,270 | public int valueForYPosition ( int yPos ) { int value ; int minValue = slider . getMinimum ( ) ; int maxValue = slider . getMaximum ( ) ; int trackTop = trackRect . y + thumbRect . height / 2 + trackBorder ; int trackBottom = trackRect . y + trackRect . height - thumbRect . height / 2 - trackBorder ; int trackLength = trackBottom - trackTop ; if ( yPos <= trackTop ) { value = drawInverted ( ) ? minValue : maxValue ; } else if ( yPos >= trackBottom ) { value = drawInverted ( ) ? maxValue : minValue ; } else { int distanceFromTrackTop = yPos - trackTop ; double valueRange = ( double ) maxValue - ( double ) minValue ; double valuePerPixel = valueRange / ( double ) trackLength ; int valueFromTrackTop = ( int ) Math . round ( distanceFromTrackTop * valuePerPixel ) ; value = drawInverted ( ) ? minValue + valueFromTrackTop : maxValue - valueFromTrackTop ; } return value ; } | Returns a value give a y position . If yPos is past the track at the top or the bottom it will set the value to the min or max of the slider depending if the slider is inverted or not . |
37,271 | public int valueForXPosition ( int xPos ) { int value ; int minValue = slider . getMinimum ( ) ; int maxValue = slider . getMaximum ( ) ; int trackLeft = trackRect . x + thumbRect . width / 2 + trackBorder ; int trackRight = trackRect . x + trackRect . width - thumbRect . width / 2 - trackBorder ; int trackLength = trackRight - trackLeft ; if ( xPos <= trackLeft ) { value = drawInverted ( ) ? maxValue : minValue ; } else if ( xPos >= trackRight ) { value = drawInverted ( ) ? minValue : maxValue ; } else { int distanceFromTrackLeft = xPos - trackLeft ; double valueRange = ( double ) maxValue - ( double ) minValue ; double valuePerPixel = valueRange / ( double ) trackLength ; int valueFromTrackLeft = ( int ) Math . round ( distanceFromTrackLeft * valuePerPixel ) ; value = drawInverted ( ) ? maxValue - valueFromTrackLeft : minValue + valueFromTrackLeft ; } return value ; } | Returns a value give an x position . If xPos is past the track at the left or the right it will set the value to the min or max of the slider depending if the slider is inverted or not . |
37,272 | private boolean isPaintLineSeperators ( JComponent c ) { boolean paintLines = c instanceof JTextArea ; String globalOverride = System . getProperty ( "SeaGlass.JTextArea.drawLineSeparator" ) ; if ( globalOverride != null && globalOverride . length ( ) > 0 ) { paintLines = Boolean . valueOf ( globalOverride ) ; } Boolean overrideProperty = ( Boolean ) c . getClientProperty ( "SeaGlass.JTextArea.drawLineSeparator" ) ; if ( overrideProperty != null ) { paintLines = overrideProperty ; } return paintLines ; } | Test if we should also paint the line seperators . |
37,273 | private void paintBorder ( Graphics2D g , JComponent c , int x , int y , int width , int height ) { boolean useToolBarColors = isInToolBar ( c ) ; Shape s ; if ( focused ) { s = shapeGenerator . createRoundRectangle ( x - 2 , y - 2 , width + 3 , height + 3 , CornerSize . OUTER_FOCUS ) ; g . setPaint ( getFocusPaint ( s , FocusType . OUTER_FOCUS , useToolBarColors ) ) ; g . draw ( s ) ; s = shapeGenerator . createRoundRectangle ( x - 1 , y - 1 , width + 1 , height + 1 , CornerSize . INNER_FOCUS ) ; g . setPaint ( getFocusPaint ( s , FocusType . INNER_FOCUS , useToolBarColors ) ) ; g . draw ( s ) ; } if ( type != CommonControlState . DISABLED ) { s = shapeGenerator . createRoundRectangle ( x + 1 , x + 1 , width - 2 , height - 2 , CornerSize . BORDER ) ; internalShadow . fill ( g , s , false , true ) ; } s = shapeGenerator . createRoundRectangle ( x , y , width - 1 , height - 1 , CornerSize . BORDER ) ; g . setPaint ( getTextBorderPaint ( type , ! focused && useToolBarColors ) ) ; g . draw ( s ) ; } | Paint the border . |
37,274 | private int getButtonHeight ( JComponent c , int height ) { String scaleKey = SeaGlassStyle . getSizeVariant ( c ) ; int newHeight = 27 ; if ( SeaGlassStyle . NATURAL_KEY . equals ( scaleKey ) ) { return height ; } else if ( SeaGlassStyle . LARGE_KEY . equals ( scaleKey ) ) { newHeight *= SeaGlassStyle . LARGE_SCALE ; } else if ( SeaGlassStyle . SMALL_KEY . equals ( scaleKey ) ) { newHeight *= SeaGlassStyle . SMALL_SCALE ; } else if ( SeaGlassStyle . MINI_KEY . equals ( scaleKey ) ) { newHeight *= SeaGlassStyle . MINI_SCALE ; } else { if ( height < 22 ) { newHeight *= SeaGlassStyle . MINI_SCALE ; } else if ( height < 26 ) { newHeight *= SeaGlassStyle . SMALL_SCALE ; } else if ( height >= 30 ) { newHeight *= SeaGlassStyle . LARGE_SCALE ; } } return newHeight ; } | Compute the new button height for drawing forcing the button into a standard height . |
37,275 | protected Shape createOuterFocus ( final SegmentType segmentType , final int x , final int y , final int w , final int h ) { switch ( segmentType ) { case FIRST : return shapeGenerator . createRoundRectangle ( x - 2 , y - 2 , w + 3 , h + 3 , CornerSize . OUTER_FOCUS , CornerStyle . ROUNDED , CornerStyle . ROUNDED , CornerStyle . SQUARE , CornerStyle . SQUARE ) ; case MIDDLE : return shapeGenerator . createRectangle ( x - 2 , y - 2 , w + 3 , h + 3 ) ; case LAST : return shapeGenerator . createRoundRectangle ( x - 2 , y - 2 , w + 3 , h + 3 , CornerSize . OUTER_FOCUS , CornerStyle . SQUARE , CornerStyle . SQUARE , CornerStyle . ROUNDED , CornerStyle . ROUNDED ) ; default : return shapeGenerator . createRoundRectangle ( x - 2 , y - 2 , w + 3 , h + 3 , CornerSize . OUTER_FOCUS ) ; } } | Create the shape for the outer focus ring . Designed to be drawn rather than filled . |
37,276 | public static boolean isMac ( ) { if ( System . getProperty ( SEA_GLASS_OVERRIDE_OS_NAME ) != null ) { return System . getProperty ( SEA_GLASS_OVERRIDE_OS_NAME ) . startsWith ( "Mac OS" ) ; } return System . getProperty ( "os.name" ) . startsWith ( "Mac OS" ) ; } | True if this JVM is running on a Mac . |
37,277 | public void paintCurrentValue ( Graphics g , Rectangle bounds , boolean hasFocus ) { ListCellRenderer renderer = comboBox . getRenderer ( ) ; Component c ; c = renderer . getListCellRendererComponent ( listBox , comboBox . getSelectedItem ( ) , - 1 , false , false ) ; boolean shouldValidate = false ; if ( c instanceof JPanel ) { shouldValidate = true ; } if ( c instanceof UIResource ) { c . setName ( "ComboBox.renderer" ) ; } boolean force = forceOpaque && c instanceof JComponent ; if ( force ) { ( ( JComponent ) c ) . setOpaque ( false ) ; } int x = bounds . x , y = bounds . y , w = bounds . width , h = bounds . height ; if ( padding != null ) { x = bounds . x + padding . left ; y = bounds . y + padding . top ; w = bounds . width - ( padding . left + padding . right ) ; h = bounds . height - ( padding . top + padding . bottom ) ; } currentValuePane . paintComponent ( g , c , comboBox , x , y , w , h , shouldValidate ) ; if ( force ) { ( ( JComponent ) c ) . setOpaque ( true ) ; } } | Paints the currently selected item . |
37,278 | protected Dimension getDefaultSize ( ) { SynthComboBoxRenderer r = new SynthComboBoxRenderer ( ) ; Dimension d = getSizeForComponent ( r . getListCellRendererComponent ( listBox , " " , - 1 , false , false ) ) ; return new Dimension ( d . width , d . height ) ; } | Return the default size of an empty display area of the combo box using the current renderer and font . |
37,279 | public void fill ( Graphics2D g , Shape s , boolean isRounded , boolean paintRightShadow ) { if ( isRounded ) { fillInternalShadowRounded ( g , s ) ; } else { fillInternalShadow ( g , s , paintRightShadow ) ; } } | Fill the shape with the internal shadow . |
37,280 | private void fillInternalShadow ( Graphics2D g , Shape s , boolean paintRightShadow ) { Rectangle bounds = s . getBounds ( ) ; int x = bounds . x ; int y = bounds . y ; int w = bounds . width ; int h = bounds . height ; s = shapeGenerator . createRectangle ( x , y , w , 2 ) ; g . setPaint ( getTopShadowGradient ( s ) ) ; g . fill ( s ) ; s = shapeGenerator . createRectangle ( x , y , 1 , h ) ; g . setPaint ( getLeftShadowGradient ( s ) ) ; g . fill ( s ) ; if ( paintRightShadow ) { s = shapeGenerator . createRectangle ( x + w - 1 , y , 1 , h ) ; g . setPaint ( getRightShadowGradient ( s ) ) ; g . fill ( s ) ; } } | Fill a rectangular shadow . |
37,281 | private void fillInternalShadowRounded ( Graphics2D g , Shape s ) { g . setPaint ( getRoundedShadowGradient ( s ) ) ; g . fill ( s ) ; } | Fill a rounded shadow . |
37,282 | public Paint getRoundedShadowGradient ( Shape s ) { Rectangle r = s . getBounds ( ) ; int x = r . x + r . width / 2 ; int y1 = r . y ; float frac = 1.0f / r . height ; int y2 = r . y + r . height ; return new LinearGradientPaint ( x , y1 , x , y2 , ( new float [ ] { 0f , frac , 1f } ) , new Color [ ] { innerShadow . top , innerShadow . bottom , innerShadow . bottom } ) ; } | Create the gradient for a rounded shadow . |
37,283 | public Paint getTopShadowGradient ( Shape s ) { Rectangle2D bounds = s . getBounds2D ( ) ; float minY = ( float ) bounds . getMinY ( ) ; float maxY = ( float ) bounds . getMaxY ( ) ; float midX = ( float ) bounds . getCenterX ( ) ; return new LinearGradientPaint ( midX , minY , midX , maxY , ( new float [ ] { 0f , 1f } ) , new Color [ ] { innerShadow . top , transparentColor } ) ; } | Create the gradient for the top of a rectangular shadow . |
37,284 | public Paint getLeftShadowGradient ( Shape s ) { Rectangle2D bounds = s . getBounds2D ( ) ; float minX = ( float ) bounds . getMinX ( ) ; float maxX = ( float ) bounds . getMaxX ( ) ; float midY = ( float ) bounds . getCenterY ( ) ; return new LinearGradientPaint ( minX , midY , maxX , midY , ( new float [ ] { 0f , 1f } ) , new Color [ ] { innerShadow . bottom , transparentColor } ) ; } | Create the gradient for the left of a rectangular shadow . |
37,285 | private void rederiveColor ( ) { Color src = UIManager . getColor ( uiDefaultParentName ) ; if ( src != null ) { float [ ] tmp = Color . RGBtoHSB ( src . getRed ( ) , src . getGreen ( ) , src . getBlue ( ) , null ) ; tmp [ 0 ] = clamp ( tmp [ 0 ] + hOffset ) ; tmp [ 1 ] = clamp ( tmp [ 1 ] + sOffset ) ; tmp [ 2 ] = clamp ( tmp [ 2 ] + bOffset ) ; int alpha = clamp ( src . getAlpha ( ) + aOffset ) ; argbValue = ( Color . HSBtoRGB ( tmp [ 0 ] , tmp [ 1 ] , tmp [ 2 ] ) & 0xFFFFFF ) | ( alpha << 24 ) ; } else { float [ ] tmp = new float [ 3 ] ; tmp [ 0 ] = clamp ( hOffset ) ; tmp [ 1 ] = clamp ( sOffset ) ; tmp [ 2 ] = clamp ( bOffset ) ; int alpha = clamp ( aOffset ) ; argbValue = ( Color . HSBtoRGB ( tmp [ 0 ] , tmp [ 1 ] , tmp [ 2 ] ) & 0xFFFFFF ) | ( alpha << 24 ) ; } } | Recalculate the derived color from the UIManager parent color and offsets |
37,286 | public TwoColors getTexturedButtonBorderColors ( CommonControlState type ) { switch ( type ) { case DISABLED : return texturedButtonBorderDisabled ; case DISABLED_SELECTED : return texturedButtonBorderDisabledSelected ; case ENABLED : return texturedButtonBorderEnabled ; case PRESSED : return texturedButtonBorderPressed ; case DEFAULT : return texturedButtonBorderDefault ; case SELECTED : return texturedButtonBorderSelected ; case DEFAULT_PRESSED : return texturedButtonBorderDefaultPressed ; case PRESSED_SELECTED : return texturedButtonBorderPressedSelected ; } return null ; } | Get the colors for the border . |
37,287 | public TwoColors getTexturedButtonInteriorColors ( CommonControlState type ) { switch ( type ) { case DISABLED : return texturedButtonInteriorDisabled ; case DISABLED_SELECTED : return texturedButtonInteriorDisabledSelected ; case ENABLED : return texturedButtonInteriorEnabled ; case PRESSED : return texturedButtonInteriorPressed ; case DEFAULT : return texturedButtonInteriorDefault ; case SELECTED : return texturedButtonInteriorSelected ; case DEFAULT_PRESSED : return texturedButtonInteriorDefaultPressed ; case PRESSED_SELECTED : return texturedButtonInteriorPressedSelected ; } return null ; } | Get the colors for the interior . |
37,288 | private Paint decodeCloseGradient ( Shape s , Color top , Color bottom ) { Rectangle r = s . getBounds ( ) ; int width = r . width ; int height = r . height ; return createGradient ( r . x + width / 2 , r . y , r . x + width / 2 , r . y + height - 1 , new float [ ] { 0f , 1f } , new Color [ ] { top , bottom } ) ; } | Create the gradient for the close button . |
37,289 | private Shape decodeEdge ( int width , int height ) { path . reset ( ) ; path . moveTo ( width - 2 , 0 ) ; path . lineTo ( width - 2 , height - 4 ) ; path . lineTo ( width - 4 , height - 2 ) ; path . lineTo ( 0 , height - 2 ) ; return path ; } | Create the edge of the button . |
37,290 | private Shape decodeShadow ( int width , int height ) { path . reset ( ) ; path . moveTo ( width - 1 , 0 ) ; path . lineTo ( width - 1 , height - 4 ) ; path . lineTo ( width - 4 , height - 1 ) ; path . lineTo ( 0 , height - 1 ) ; return path ; } | Create the shadow for the button . |
37,291 | private Shape decodeMarkBorder ( int width , int height ) { int left = ( width - 3 ) / 2 - 5 ; int top = ( height - 2 ) / 2 - 5 ; path . reset ( ) ; path . moveTo ( left + 1 , top + 0 ) ; path . lineTo ( left + 3 , top + 0 ) ; path . pointAt ( left + 4 , top + 1 ) ; path . pointAt ( left + 5 , top + 2 ) ; path . pointAt ( left + 6 , top + 1 ) ; path . moveTo ( left + 7 , top + 0 ) ; path . lineTo ( left + 9 , top + 0 ) ; path . pointAt ( left + 10 , top + 1 ) ; path . pointAt ( left + 9 , top + 2 ) ; path . pointAt ( left + 8 , top + 3 ) ; path . moveTo ( left + 7 , top + 4 ) ; path . lineTo ( left + 7 , top + 5 ) ; path . pointAt ( left + 8 , top + 6 ) ; path . pointAt ( left + 9 , top + 7 ) ; path . pointAt ( left + 10 , top + 8 ) ; path . moveTo ( left + 9 , top + 9 ) ; path . lineTo ( left + 7 , top + 9 ) ; path . pointAt ( left + 6 , top + 8 ) ; path . pointAt ( left + 5 , top + 7 ) ; path . pointAt ( left + 4 , top + 8 ) ; path . moveTo ( left + 3 , top + 9 ) ; path . lineTo ( left + 1 , top + 9 ) ; path . pointAt ( left + 0 , top + 8 ) ; path . pointAt ( left + 1 , top + 7 ) ; path . pointAt ( left + 2 , top + 6 ) ; path . moveTo ( left + 3 , top + 5 ) ; path . lineTo ( left + 3 , top + 4 ) ; path . pointAt ( left + 2 , top + 3 ) ; path . pointAt ( left + 1 , top + 2 ) ; path . pointAt ( left + 0 , top + 1 ) ; return path ; } | Create the shape for the mark border . |
37,292 | private Shape decodeMarkInterior ( int width , int height ) { int left = ( width - 3 ) / 2 - 5 ; int top = ( height - 2 ) / 2 - 5 ; path . reset ( ) ; path . moveTo ( left + 1 , top + 1 ) ; path . lineTo ( left + 4 , top + 1 ) ; path . lineTo ( left + 5 , top + 3 ) ; path . lineTo ( left + 7 , top + 1 ) ; path . lineTo ( left + 10 , top + 1 ) ; path . lineTo ( left + 7 , top + 4 ) ; path . lineTo ( left + 7 , top + 5 ) ; path . lineTo ( left + 10 , top + 9 ) ; path . lineTo ( left + 6 , top + 8 ) ; path . lineTo ( left + 5 , top + 6 ) ; path . lineTo ( left + 4 , top + 9 ) ; path . lineTo ( left + 0 , top + 9 ) ; path . lineTo ( left + 4 , top + 5 ) ; path . lineTo ( left + 4 , top + 4 ) ; path . closePath ( ) ; return path ; } | Create the shape for the mark interior . |
37,293 | private void paintProgressIndicator ( SeaGlassContext context , Graphics2D g2d , int width , int height , int size , boolean isFinished ) { JProgressBar pBar = ( JProgressBar ) context . getComponent ( ) ; if ( tileWhenIndeterminate && pBar . isIndeterminate ( ) ) { double offsetFraction = ( double ) getAnimationIndex ( ) / ( double ) getFrameCount ( ) ; int offset = ( int ) ( offsetFraction * tileWidth ) ; if ( pBar . getOrientation ( ) == JProgressBar . HORIZONTAL ) { if ( ! SeaGlassLookAndFeel . isLeftToRight ( pBar ) ) { offset = tileWidth - offset ; } for ( int i = - tileWidth + offset ; i <= width ; i += tileWidth ) { context . getPainter ( ) . paintProgressBarForeground ( context , g2d , i , 0 , tileWidth , height , pBar . getOrientation ( ) ) ; } } else { for ( int i = - offset ; i < height + tileWidth ; i += tileWidth ) { context . getPainter ( ) . paintProgressBarForeground ( context , g2d , 0 , i , width , tileWidth , pBar . getOrientation ( ) ) ; } } } else { if ( pBar . getOrientation ( ) == JProgressBar . HORIZONTAL ) { int start = 0 ; if ( isFinished ) { size = width ; } else if ( ! SeaGlassLookAndFeel . isLeftToRight ( pBar ) ) { start = width - size ; } context . getPainter ( ) . paintProgressBarForeground ( context , g2d , start , 0 , size , height , pBar . getOrientation ( ) ) ; } else { int start = height ; if ( isFinished ) { size = height ; } context . getPainter ( ) . paintProgressBarForeground ( context , g2d , 0 , start , width , size , pBar . getOrientation ( ) ) ; } } } | Paint the actual internal progress bar . |
37,294 | private ButtonVariantPainter getButtonPainter ( JComponent c ) { Object buttonType = c . getClientProperty ( "JButton.buttonType" ) ; ButtonVariantPainter button = standard ; if ( "textured" . equals ( buttonType ) || "segmentedTextured" . equals ( buttonType ) ) { button = textured ; } return button ; } | Determine the button painter variant from the component s client property . |
37,295 | protected void paintComponent ( Graphics g ) { SeaGlassPainter painter = ( SeaGlassPainter ) UIManager . get ( "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter" ) ; if ( painter != null ) { Graphics2D g2d = ( Graphics2D ) g ; painter . paint ( g2d , this , getWidth ( ) + 1 , getHeight ( ) ) ; } } | Paint the component using the Nimbus Table Header Background Painter |
37,296 | public static SeaGlassContext getContext ( Class type , JComponent component , Region region , SynthStyle style , int state ) { SeaGlassContext context = null ; synchronized ( contextMap ) { List instances = ( List ) contextMap . get ( type ) ; if ( instances != null ) { int size = instances . size ( ) ; if ( size > 0 ) { context = ( SeaGlassContext ) instances . remove ( size - 1 ) ; } } } if ( context == null ) { try { context = ( SeaGlassContext ) type . newInstance ( ) ; } catch ( IllegalAccessException iae ) { iae . printStackTrace ( ) ; } catch ( InstantiationException ie ) { ie . printStackTrace ( ) ; } } context . reset ( component , region , style , state ) ; return context ; } | The method used to get a context . |
37,297 | static void releaseContext ( SeaGlassContext context ) { synchronized ( contextMap ) { List instances = ( List ) contextMap . get ( context . getClass ( ) ) ; if ( instances == null ) { instances = new ArrayList ( 5 ) ; contextMap . put ( context . getClass ( ) , instances ) ; } instances . add ( context ) ; } } | Release a context for re - use . |
37,298 | @ SuppressWarnings ( "all" ) public void reset ( JComponent component , Region region , SynthStyle style , int state ) { this . component = component ; this . region = region ; this . style = style ; this . state = state ; } | Resets the state of the Context . |
37,299 | @ SuppressWarnings ( "all" ) public SynthPainter getPainter ( ) { SynthPainter painter = getStyle ( ) . getPainter ( this ) ; if ( painter != null ) { return painter ; } return EMPTY_PAINTER ; } | Convenience method to get the Painter from the current SynthStyle . This will NEVER return null . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.