Frames | No Frames |
1: /** 2: * ======================================== 3: * JFreeReport : a free Java report library 4: * ======================================== 5: * 6: * Project Info: http://reporting.pentaho.org/ 7: * 8: * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. 9: * 10: * This library is free software; you can redistribute it and/or modify it under the terms 11: * of the GNU Lesser General Public License as published by the Free Software Foundation; 12: * either version 2.1 of the License, or (at your option) any later version. 13: * 14: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 15: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16: * See the GNU Lesser General Public License for more details. 17: * 18: * You should have received a copy of the GNU Lesser General Public License along with this 19: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20: * Boston, MA 02111-1307, USA. 21: * 22: * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 23: * in the United States and other countries.] 24: * 25: * ------------ 26: * $Id: ActionPluginToolbarComparator.java 2725 2007-04-01 18:49:29Z taqua $ 27: * ------------ 28: * (C) Copyright 2000-2005, by Object Refinery Limited. 29: * (C) Copyright 2005-2007, by Pentaho Corporation. 30: */ 31: 32: package org.jfree.report.modules.gui.swing.common; 33: 34: import java.util.Comparator; 35: 36: /** 37: * Creation-Date: 16.11.2006, 16:50:39 38: * 39: * @author Thomas Morgner 40: */ 41: public class ActionPluginToolbarComparator implements Comparator 42: { 43: public ActionPluginToolbarComparator() 44: { 45: } 46: 47: /** 48: * Compares its two arguments for order. Returns a negative integer, zero, or 49: * a positive integer as the first argument is less than, equal to, or greater 50: * than the second.<p> 51: * <p/> 52: * The implementor must ensure that <tt>sgn(compare(x, y)) == -sgn(compare(y, 53: * x))</tt> for all <tt>x</tt> and <tt>y</tt>. (This implies that 54: * <tt>compare(x, y)</tt> must throw an exception if and only if 55: * <tt>compare(y, x)</tt> throws an exception.)<p> 56: * <p/> 57: * The implementor must also ensure that the relation is transitive: 58: * <tt>((compare(x, y)>0) && (compare(y, z)>0))</tt> implies 59: * <tt>compare(x, z)>0</tt>.<p> 60: * <p/> 61: * Finally, the implementer must ensure that <tt>compare(x, y)==0</tt> implies 62: * that <tt>sgn(compare(x, z))==sgn(compare(y, z))</tt> for all 63: * <tt>z</tt>.<p> 64: * <p/> 65: * It is generally the case, but <i>not</i> strictly required that 66: * <tt>(compare(x, y)==0) == (x.equals(y))</tt>. Generally speaking, any 67: * comparator that violates this condition should clearly indicate this fact. 68: * The recommended language is "Note: this comparator imposes orderings that 69: * are inconsistent with equals." 70: * 71: * @param o1 the first object to be compared. 72: * @param o2 the second object to be compared. 73: * @return a negative integer, zero, or a positive integer as the first 74: * argument is less than, equal to, or greater than the second. 75: * @throws ClassCastException if the arguments' types prevent them from being 76: * compared by this Comparator. 77: */ 78: public int compare(final Object o1, final Object o2) 79: { 80: final ActionPlugin a1 = (ActionPlugin) o1; 81: final ActionPlugin a2 = (ActionPlugin) o2; 82: 83: final int toolbarOrder = a1.getToolbarOrder(); 84: final int toolbarOrder2 = a2.getToolbarOrder(); 85: if (toolbarOrder < toolbarOrder2) 86: { 87: return -1; 88: } 89: if (toolbarOrder > toolbarOrder2) 90: { 91: return 1; 92: } 93: return 0; 94: } 95: }