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

bibliothek.gui.dock.station.toolbar.group.DefaultToolbarGroupDividierStrategy Maven / Gradle / Ivy

There is a newer version: 1.1.2p6a
Show newest version
/*
 * Bibliothek - DockingFrames
 * Library built on Java/Swing, allows the user to "drag and drop"
 * panels containing any Swing-Component the developer likes to add.
 * 
 * Copyright (C) 2012 Herve Guillaume, Benjamin Sigg
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 * Herve Guillaume
 * [email protected]
 * FR - France
 *
 * Benjamin Sigg
 * [email protected]
 * CH - Switzerland
 */
package bibliothek.gui.dock.station.toolbar.group;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Rectangle;

import bibliothek.gui.Dockable;
import bibliothek.gui.Orientation;
import bibliothek.gui.dock.ToolbarGroupDockStation;
import bibliothek.gui.dock.station.StationChildHandle;
import bibliothek.gui.dock.station.toolbar.layout.ToolbarGridLayoutManager;

/**
 * This implementation of {@link ToolbarGroupDividerStrategy} paints a line between each
 * column and each line, and a line around at the outside of the {@link Dockable}s as well.
 * @author Benjamin Sigg
 */
public class DefaultToolbarGroupDividierStrategy implements ToolbarGroupDividerStrategy{
	/** a factory creating new {@link DefaultToolbarGroupDividierStrategy}s */
	public static final ToolbarGroupDividerStrategyFactory FACTORY = new ToolbarGroupDividerStrategyFactory(){
		@Override
		public ToolbarGroupDividerStrategy create( ToolbarGroupDockStation station ){
			return new DefaultToolbarGroupDividierStrategy( station );
		}
	};
	
	/** the station for which this strategy works */
	private ToolbarGroupDockStation station;
	
	/**
	 * Creates a new strategy for station.
	 * @param station the station which will use this strategy, not null
	 */
	public DefaultToolbarGroupDividierStrategy( ToolbarGroupDockStation station ){
		this.station = station;
	}
	
	@Override
	public int getColumn( int index ){
		return 1;
	}

	@Override
	public int getLine( int column, int index ){
		if( index == 0 ){
			return 0;
		}
		else{
			return 1;
		}
	}

	@Override
	public void paint( Component parent, Graphics g, ToolbarGridLayoutManager layoutManager ){
		g.setColor( parent.getForeground() );
		
		Orientation orientation = station.getOrientation();
		ToolbarColumnModel model = station.getColumnModel();
		for( int i = 0, n = model.getColumnCount(); i column = model.getColumn( i );
			for( int j = 0, m = column.getDockableCount(); j




© 2015 - 2024 Weber Informatics LLC | Privacy Policy