Java Code Examples for com.alee.utils.SwingUtils#increase()

The following examples show how to use com.alee.utils.SwingUtils#increase() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebDecoration.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Insets getBorderInsets ( final C c )
{
    final Insets insets = super.getBorderInsets ( c );
    if ( isVisible () )
    {
        final IShape shape = getShape ();
        final BorderWidth bw = getBorderWidth ();
        final int sw = getShadowWidth ( ShadowType.outer );
        if ( shape instanceof IPartialShape )
        {
            final IPartialShape ps = ( IPartialShape ) shape;
            final int top = ps.isPaintTop ( c, this ) ? bw.top + sw : ps.isPaintTopLine ( c, this ) ? bw.top : 0;
            final int left = ps.isPaintLeft ( c, this ) ? bw.left + sw : ps.isPaintLeftLine ( c, this ) ? bw.left : 0;
            final int bottom = ps.isPaintBottom ( c, this ) ? bw.bottom + sw : ps.isPaintBottomLine ( c, this ) ? bw.bottom : 0;
            final int right = ps.isPaintRight ( c, this ) ? bw.right + sw : ps.isPaintRightLine ( c, this ) ? bw.right : 0;
            SwingUtils.increase ( insets, new Insets ( top, left, bottom, right ) );
        }
        else
        {
            SwingUtils.increase ( insets, new Insets ( bw.top + sw, bw.left + sw, bw.bottom + sw, bw.right + sw ) );
        }
    }
    return insets;
}
 
Example 2
Source File: OverlayLayout.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
public Dimension preferredLayoutSize ( @NotNull final Container parent )
{
    Dimension ps = new Dimension ( 0, 0 );

    // Adding content size
    final WebOverlay container = ( WebOverlay ) parent;
    final JComponent content = container.getContent ();
    if ( content != null )
    {
        final Dimension cps = content.getPreferredSize ();
        ps = SwingUtils.maxNonNull ( ps, cps );
    }

    // Adding maximum overlay margin
    ps = SwingUtils.increase ( ps, getOverlaysPadding ( container ) );

    // Adding container insets
    SwingUtils.increase ( ps, container.getInsets () );

    return ps;
}
 
Example 3
Source File: NinePatchDecoration.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Insets getBorderInsets ( final C c )
{
    final Insets insets = super.getBorderInsets ( c );
    if ( isVisible () )
    {
        final NinePatchIcon icon = getIcon ();
        if ( icon != null )
        {
            SwingUtils.increase ( insets, icon.getMargin () );
        }
    }
    return insets;
}
 
Example 4
Source File: OverlayLayout.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void layoutContainer ( @NotNull final Container parent )
{
    final WebOverlay container = ( WebOverlay ) parent;
    final Insets overlayPadding = container.getInsets ();
    final Insets contentPadding = SwingUtils.increase ( overlayPadding, getOverlaysPadding ( container ) );
    final Rectangle contentBounds = new Rectangle (
            contentPadding.left,
            contentPadding.top,
            container.getWidth () - contentPadding.left - contentPadding.right,
            container.getHeight () - contentPadding.top - contentPadding.bottom
    );

    // Laying out content
    final JComponent content = container.getContent ();
    if ( content != null )
    {
        container.setComponentZOrder ( content, container.getComponentCount () - 1 );
        content.setBounds ( contentBounds );
    }

    // Laying out overlays
    for ( final Overlay overlay : container.getOverlays () )
    {
        // Each overlay is aligned according to it's own extra padding
        final Insets padding = overlay.margin ();
        overlay.component ().setBounds (
                overlay.bounds (
                        container,
                        content,
                        new Rectangle (
                                contentBounds.x - padding.left,
                                contentBounds.y - padding.top,
                                contentBounds.width + padding.left + padding.right,
                                contentBounds.height + padding.top + padding.bottom
                        )
                )
        );
    }
}
 
Example 5
Source File: TabbedPaneLayout.java    From weblaf with GNU General Public License v3.0 4 votes vote down vote up
@NotNull
@Override
public Dimension preferredLayoutSize ( @NotNull final Container parent )
{
    final Dimension preferredSize;

    // Calculating maximum content preferred size
    final JTabbedPane tabbedPane = ( JTabbedPane ) parent;
    final ComponentSize contentSize = getContentSize ();
    Dimension contentPreferredSize = new Dimension ( 0, 0 );
    for ( int i = 0; i < tabbedPane.getTabCount (); i++ )
    {
        final Component componentAt = tabbedPane.getComponentAt ( i );
        if ( componentAt != null )
        {
            contentPreferredSize = SwingUtils.maxNonNull (
                    contentPreferredSize,
                    contentSize.size ( componentAt )
            );
        }
    }

    // Calculating resulting preferred size
    final TabArea tabArea = getTabArea ( tabbedPane );
    if ( tabArea != null && tabArea.isVisible () )
    {
        final Dimension tabAreaSize = tabArea.getPreferredSize ();
        switch ( tabbedPane.getTabPlacement () )
        {
            default:
            case SwingConstants.TOP:
            case SwingConstants.BOTTOM:
            {
                preferredSize = new Dimension (
                        Math.max ( tabAreaSize.width, contentPreferredSize.width ),
                        tabAreaSize.height + contentPreferredSize.height
                );
            }
            break;

            case SwingConstants.LEFT:
            case SwingConstants.RIGHT:
            {
                preferredSize = new Dimension (
                        tabAreaSize.width + contentPreferredSize.width,
                        Math.max ( tabAreaSize.height, contentPreferredSize.height )
                );
            }
            break;
        }
    }
    else
    {
        preferredSize = contentPreferredSize;
    }

    // Adding tabbed pane insets
    SwingUtils.increase ( preferredSize, tabbedPane.getInsets () );

    return preferredSize;
}