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

net.java.dev.designgridlayout.RowIterator Maven / Gradle / Ivy

Go to download

DesignGridLayout is a Swing LayoutManager that helps developers build always good looking dialogs through a very easy-to-use API, without any need for a graphical GUI designer.

There is a newer version: 1.11
Show newest version
//  Copyright 2005-2013 Jason Aaron Osgood, Jean-Francois Poilpret
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package net.java.dev.designgridlayout;

import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;

final class RowIterator implements Iterator
{
	static public Iterable each(final List rows)
	{
		return new Iterable()
		{
			@Override public Iterator iterator()
			{
				return new RowIterator(rows);
			}
		};
	}

	private RowIterator(List rows)
	{
		_rows = rows;
	}
	
	@Override public AbstractRow next()
	{
		int index = findNext();
		if (index != -1)
		{
			_index = index + 1;
			return _rows.get(index);
		}
		else
		{
			throw new NoSuchElementException();
		}
	}
	
	@Override public boolean hasNext()
	{
		return findNext() != -1;
	}
	
	@Override public void remove()
	{
		throw new UnsupportedOperationException();
	}
	
	private int findNext()
	{
		for (int i = _index; i < _rows.size(); i++)
		{
			AbstractRow row = _rows.get(i);
			if (!row.isEmpty())
			{
				return i;
			}
		}
		return -1;
	}
	
	private final List _rows;
	private int _index = 0;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy