com.alee.laf.splitpane.SplitPanePainter Maven / Gradle / Ivy
package com.alee.laf.splitpane;
import com.alee.api.jdk.Objects;
import com.alee.painter.decoration.AbstractContainerPainter;
import com.alee.painter.decoration.DecorationState;
import com.alee.painter.decoration.IDecoration;
import javax.swing.*;
import java.util.List;
/**
* Basic painter for {@link JSplitPane} component.
* It is used as {@link WSplitPaneUI} default painter.
*
* @param component type
* @param component UI type
* @param decoration type
* @author Alexandr Zernov
*/
public class SplitPanePainter>
extends AbstractContainerPainter implements ISplitPanePainter
{
@Override
protected void propertyChanged ( final String property, final Object oldValue, final Object newValue )
{
// Perform basic actions on property changes
super.propertyChanged ( property, oldValue, newValue );
// Updating split pane decoration states
if ( Objects.equals ( property, JSplitPane.ORIENTATION_PROPERTY ) )
{
updateDecorationState ();
}
}
@Override
public List getDecorationStates ()
{
final List states = super.getDecorationStates ();
// Split pane orientation
final boolean horizontal = component.getOrientation () == JSplitPane.HORIZONTAL_SPLIT;
states.add ( horizontal ? DecorationState.horizontal : DecorationState.vertical );
// One-touch
if ( component.isOneTouchExpandable () )
{
states.add ( DecorationState.oneTouch );
}
return states;
}
}