KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > monitorenter > gui > util > IColorDistributor


1 /*
2  * IColorDistributor.java, interface for choosing visual different colors.
3  * Copyright (C) Achim Westermann, created on 19.05.2005, 22:01:51
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * If you modify or optimize the code in a useful way please let me know.
20  * Achim.Westermann@gmx.de
21  *
22  */

23 package info.monitorenter.gui.util;
24
25 /**
26  * An interface for distributing colors.
27  * <p>
28  *
29  * Implementations are keeping track of the java.awt.Color - instances they gave
30  * away during invocation of <code>getColor()</code>. The aim is to provide
31  * an interface that allows to get unique colors from. As all colors given away
32  * are remembered, it is possible to avoid lending the same color several times.
33  * <p>
34  * It will be tricky to implement this in a good way because of the fact that
35  * the ColorLessor should not be limited to a maximum amount of colors, it does
36  * not know how much different colors there will be asked for a priori, the
37  * amount of colors given away should be the most visual different and the
38  * background color should be especially different from all ohter colors given
39  * away.
40  * <p>
41  *
42  * @see info.monitorenter.gui.chart.Chart2D
43  *
44  * @author <a HREF='mailto:Achim.Westermann@gmx.de'>Achim Westermann </a>
45  */

46
47 public interface IColorDistributor {
48
49   /**
50    * Puts the given color back into the color- space of free colors.
51    * <p>
52    * Do not forget to give your colors back if not used any more to allow the
53    * biggest possible visual difference of the colors given away.
54    * <p>
55    *
56    * @see #getColor()
57    */

58   public void freeColor(java.awt.Color JavaDoc color);
59
60   /**
61    * Returns a color, that has not been retrieved before from this instance.
62    * <p>
63    *
64    * @return a color, that has not been retrieved before from this instance.
65    */

66   public java.awt.Color JavaDoc getColor();
67
68   /**
69    * Informs the IColorDistributor that a client already uses the given color.
70    * <p>
71    *
72    * This ensures that the IColorDistributor does never return the given color
73    * to clients. Furthermore implementations may use the given informations of
74    * the color, e.g. an IColorDistributor that tries to return always the most
75    * different colors (from each other).
76    * <p>
77    *
78    * @param color
79    * the color to reserve.
80    */

81   void reserveColor(java.awt.Color JavaDoc color);
82
83   /**
84    * No other color returned from instances must come "too near" to this color
85    * to guarantee a good visibility of the other colors returned.
86    * <p>
87    * Calls to this method are of course optional but should be regarded in the
88    * computations of implemenatations.
89    * <p>
90    *
91    * @param background
92    * the background color to keep a viewable distance to.
93    */

94   public void setBgColor(final java.awt.Color JavaDoc background);
95 }
96
Popular Tags