All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alee.extended.dock.DockableAreaPainter Maven / Gradle / Ivy

There is a newer version: 1.2.14
Show newest version
/*
 * This file is part of WebLookAndFeel library.
 *
 * WebLookAndFeel library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WebLookAndFeel library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with WebLookAndFeel library.  If not, see .
 */

package com.alee.extended.dock;

import com.alee.api.annotations.NotNull;
import com.alee.api.data.CompassDirection;
import com.alee.painter.decoration.AbstractSectionDecorationPainter;
import com.alee.painter.decoration.IDecoration;

import java.util.List;

/**
 * Simple sidebar painter based on {@link AbstractSectionDecorationPainter}.
 * It is used within {@link DockablePanePainter} to paint sidebar areas background.
 *
 * @param  component type
 * @param  component UI type
 * @param  decoration type
 * @author Mikle Garin
 */
public class DockableAreaPainter, D extends IDecoration>
        extends AbstractSectionDecorationPainter implements IDockableAreaPainter
{
    /**
     * Painted {@link WebDockablePane} area.
     */
    protected transient CompassDirection area;

    @Override
    public String getSectionId ()
    {
        return "sidebar";
    }

    @Override
    protected boolean isFocused ()
    {
        return false;
    }

    @NotNull
    @Override
    public List getDecorationStates ()
    {
        final List states = super.getDecorationStates ();

        // Dockable pane area state
        if ( area != null )
        {
            states.add ( area.name () );
        }

        return states;
    }

    @Override
    public boolean hasDecorationFor ( @NotNull final CompassDirection area )
    {
        return usesState ( area.name () );
    }

    @Override
    public void prepareToPaint ( @NotNull final CompassDirection area )
    {
        this.area = area;
        updateDecorationState ();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy