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

The following examples show how to use com.alee.utils.SwingUtils#max() . 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: PainterSupport.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns component preferred size or {@code null} if there is no preferred size.
 *
 * @param component        component painter is applied to
 * @param preferred        component preferred size
 * @param ignoreLayoutSize whether or not layout preferred size should be ignored
 * @return component preferred size or {@code null} if there is no preferred size
 */
@Nullable
public static Dimension getPreferredSize ( @NotNull final JComponent component, @Nullable final Dimension preferred,
                                           final boolean ignoreLayoutSize )
{
    // Event Dispatch Thread check
    WebLookAndFeel.checkEventDispatchThread ();

    // Painter's preferred size
    final Painter painter = getPainter ( component );
    Dimension ps = SwingUtils.max ( preferred, painter != null ? painter.getPreferredSize () : null );

    // Layout preferred size
    if ( !ignoreLayoutSize )
    {
        final LayoutManager layout = component.getLayout ();
        if ( layout != null )
        {
            ps = SwingUtils.max ( ps, layout.preferredLayoutSize ( component ) );
        }
    }

    return ps;
}
 
Example 2
Source File: ContentDecoration.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Dimension getPreferredSize ( final C c )
{
    if ( size != null )
    {
        return size;
    }
    else
    {
        Dimension ps = null;
        for ( final IContent content : getContent () )
        {
            final BoundsType bt = content.getBoundsType ();
            final Insets bi = isSection () ? bt.border ( c, this ) : bt.border ( c );
            final Dimension available = isSection () ? new Dimension ( Short.MAX_VALUE, Short.MAX_VALUE ) : bt.bounds ( c ).getSize ();
            final Dimension cps = content.getPreferredSize ( c, this, available );
            cps.width += bi.left + bi.right;
            cps.height += bi.top + bi.bottom;
            ps = SwingUtils.max ( cps, ps );
        }
        return ps;
    }
}
 
Example 3
Source File: WebStepProgress.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns maximum component size.
 * Used to determine labels area size.
 *
 * @return maximum component size
 */
public Dimension getMaximumComponentSize ()
{
    Dimension max = new Dimension ( 0, 0 );
    if ( displayLabels && steps.size () > 0 )
    {
        for ( final StepData step : steps )
        {
            if ( step.getLabel () != null )
            {
                max = SwingUtils.max ( max, step.getLabel ().getPreferredSize () );
            }
        }
    }
    return max;
}
 
Example 4
Source File: WebStepProgress.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns maximum size of side components.
 * It is used to determine progress sides spacing.
 *
 * @return maximum size of side components
 */
public Dimension getMaximumSideComponentSize ()
{
    if ( displayLabels && steps.size () > 0 )
    {
        final Component l1 = steps.get ( 0 ).getLabel ();
        final Component l2 = steps.get ( steps.size () - 1 ).getLabel ();
        if ( l1 != null && l2 != null )
        {
            return SwingUtils.max ( l1.getPreferredSize (), l2.getPreferredSize () );
        }
        else if ( l1 != null )
        {
            return l1.getPreferredSize ();
        }
        else if ( l2 != null )
        {
            return l2.getPreferredSize ();
        }
        else
        {
            return new Dimension ( 0, 0 );
        }
    }
    else
    {
        return new Dimension ( 0, 0 );
    }
}
 
Example 5
Source File: SlidingLayout.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
public Dimension preferredLayoutSize ( @NotNull final Container container )
{
    Dimension ps = new Dimension ( 0, 0 );
    for ( final Component c : container.getComponents () )
    {
        ps = SwingUtils.max ( ps, c.getPreferredSize () );
    }
    ps.height = slideY < ps.height ? slideY : ps.height;
    return ps;
}
 
Example 6
Source File: MultiLayout.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
public Dimension preferredLayoutSize ( @NotNull final Container container )
{
    Dimension ps = new Dimension ( 0, 0 );
    for ( final LayoutManager layoutManager : layoutManagers )
    {
        ps = SwingUtils.max ( ps, layoutManager.preferredLayoutSize ( container ) );
    }
    return ps;
}
 
Example 7
Source File: MultiLayout.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
public Dimension minimumLayoutSize ( @NotNull final Container container )
{
    Dimension ms = new Dimension ( 0, 0 );
    for ( final LayoutManager layoutManager : layoutManagers )
    {
        ms = SwingUtils.max ( ms, layoutManager.minimumLayoutSize ( container ) );
    }
    return ms;
}