From: <kon...@us...> - 2010-10-29 02:47:40
|
Revision: 1148 http://cishell.svn.sourceforge.net/cishell/?rev=1148&view=rev Author: kongchinhua Date: 2010-10-29 02:47:34 +0000 (Fri, 29 Oct 2010) Log Message: ----------- - Reuse color if all color been used Modified Paths: -------------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/color/ColorRegistry.java Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/color/ColorRegistry.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/color/ColorRegistry.java 2010-10-29 02:38:19 UTC (rev 1147) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/color/ColorRegistry.java 2010-10-29 02:47:34 UTC (rev 1148) @@ -70,13 +70,15 @@ } /* - * Return next color index + * Return next color index. This will reuse the color if it out of color */ private int getNextIndex() { int index = currentIndex; - if (currentIndex < colorSchema.size()) { + if (currentIndex < colorSchema.size() - 1) { currentIndex++; + } else { + currentIndex = 0; } return index; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2012-01-27 00:06:02
|
Revision: 1302 http://cishell.svn.sourceforge.net/cishell/?rev=1302&view=rev Author: david-coe Date: 2012-01-27 00:05:56 +0000 (Fri, 27 Jan 2012) Log Message: ----------- I added a way to access the default color for the colorschema from the colorregistry. reviewed by joseph. Modified Paths: -------------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/color/ColorRegistry.java Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/color/ColorRegistry.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/color/ColorRegistry.java 2012-01-20 19:12:00 UTC (rev 1301) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/color/ColorRegistry.java 2012-01-27 00:05:56 UTC (rev 1302) @@ -41,7 +41,7 @@ * @param key - key must be type of <E> * @return Return color that assigned to the specific * key. If all the colors are fully used, the default - * color denied by the ColorSchema will be returned + * color defined by the ColorSchema will be returned */ public Color getColorOf(K key) { if (registedColors.containsKey(key)) { @@ -52,6 +52,14 @@ } /** + * Request the default color as defined by the ColorSchema. + * @return the default color. + */ + public Color getDefaultColor() { + return colorSchema.getDefaultColor(); + } + + /** * Clear all entry and reset to initial state. */ public void clear() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2012-03-07 14:01:46
|
Revision: 1312 http://cishell.svn.sourceforge.net/cishell/?rev=1312&view=rev Author: david-coe Date: 2012-03-07 14:01:35 +0000 (Wed, 07 Mar 2012) Log Message: ----------- You can optionally create a registry that will not recycle the colors. Reviewed by Chin Hua. Modified Paths: -------------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/color/ColorRegistry.java Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/color/ColorRegistry.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/color/ColorRegistry.java 2012-03-06 22:05:17 UTC (rev 1311) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/color/ColorRegistry.java 2012-03-07 14:01:35 UTC (rev 1312) @@ -21,9 +21,15 @@ private int currentIndex; private ColorSchema colorSchema; private Map<K, Color> registedColors; + private boolean recycleColor; public ColorRegistry(ColorSchema colorSchema) { + this(colorSchema, true); + } + + public ColorRegistry(ColorSchema colorSchema, boolean recycleColor) { this.currentIndex = 0; + this.recycleColor = recycleColor; this.colorSchema = colorSchema; this.registedColors = new HashMap<K, Color>(); } @@ -33,7 +39,7 @@ * @return Return the registered keys */ public Set<K> getKeySet() { - return registedColors.keySet(); + return this.registedColors.keySet(); } /** @@ -44,11 +50,10 @@ * color defined by the ColorSchema will be returned */ public Color getColorOf(K key) { - if (registedColors.containsKey(key)) { - return registedColors.get(key); - } else { - return reserveColorFor(key); + if (this.registedColors.containsKey(key)) { + return this.registedColors.get(key); } + return reserveColorFor(key); } /** @@ -56,14 +61,14 @@ * @return the default color. */ public Color getDefaultColor() { - return colorSchema.getDefaultColor(); + return this.colorSchema.getDefaultColor(); } /** * Clear all entry and reset to initial state. */ public void clear() { - registedColors.clear(); + this.registedColors.clear(); } /* @@ -71,22 +76,24 @@ */ private Color reserveColorFor(K key) { - Color color = colorSchema.get(getNextIndex()); - registedColors.put(key, color); + Color color = this.colorSchema.get(getNextIndex()); + this.registedColors.put(key, color); return color; } /* - * Return next color index. This will reuse the color if it out of color + * Return next color index. This will recycle the color + * if the recycleColor is true */ private int getNextIndex() { - int index = currentIndex; + int index = this.currentIndex; - if (currentIndex < colorSchema.size() - 1) { - currentIndex++; + if (this.currentIndex < this.colorSchema.size() - 1 + || !this.recycleColor) { + this.currentIndex++; } else { - currentIndex = 0; + this.currentIndex = 0; } return index; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |