@Test public void testGetNextColor() { System.out.println("getNextColor"); ColorsDispatcher instance = ColorsDispatcherFactory.getColorsDispatcher(); for (int n = 0; n < 2000; n++) { Color c = instance.getNextColor(); System.out.println(c); Assert.assertNotNull(c); } }
public Color getNextColor() { Color color = null; doCycles(); int r = 0, g = 0, b = 0; if ((bits & 1) == 1) { r = level; } if ((bits & 2) == 2) { b = level; } if ((bits & 4) == 4) { g = level; } Color c = new Color(r, g, b); if (assignedColors.contains(c)) { if (log.isDebugEnabled()) { log.debug("Existing " + r + " " + g + " " + b); } color = getNextColor(); } else if ((r + g + b) / 3 < 32) { if (log.isDebugEnabled()) { log.debug("Too dark " + r + " " + g + " " + b); } color = getNextColor(); } else if ((r + g + b) / 3 > 256 - 64) { if (log.isDebugEnabled()) { log.debug("Too light " + r + " " + g + " " + b); } color = getNextColor(); } else { if (log.isDebugEnabled()) { log.debug("New " + r + " " + g + " " + b); } color = new Color(r, g, b); } assignedColors.add(color); return color; }
CycleColors implements ColorsDispatcher { public Color getNextColor() { Color color = null; doCycles(); int r = 0, g = 0, b = 0; if ((bits & 1) == 1) { r = level; } if ((bits & 2) == 2) { b = level; } if ((bits & 4) == 4) { g = level; } Color c = new Color(r, g, b); if (assignedColors.contains(c)) { if (log.isDebugEnabled()) { log.debug("Existing " + r + " " + g + " " + b); } color = getNextColor(); } else if ((r + g + b) / 3 < 32) { if (log.isDebugEnabled()) { log.debug("Too dark " + r + " " + g + " " + b); } color = getNextColor(); } else if ((r + g + b) / 3 > 256 - 64) { if (log.isDebugEnabled()) { log.debug("Too light " + r + " " + g + " " + b); } color = getNextColor(); } else { if (log.isDebugEnabled()) { log.debug("New " + r + " " + g + " " + b); } color = new Color(r, g, b); } assignedColors.add(color); return color; } }
CycleColors implements ColorsDispatcher { public Color getNextColor() { Color color = null; doCycles(); int r = 0, g = 0, b = 0; if ((bits & 1) == 1) { r = level; } if ((bits & 2) == 2) { b = level; } if ((bits & 4) == 4) { g = level; } Color c = new Color(r, g, b); if (assignedColors.contains(c)) { if (log.isDebugEnabled()) { log.debug("Existing " + r + " " + g + " " + b); } color = getNextColor(); } else if ((r + g + b) / 3 < 32) { if (log.isDebugEnabled()) { log.debug("Too dark " + r + " " + g + " " + b); } color = getNextColor(); } else if ((r + g + b) / 3 > 256 - 64) { if (log.isDebugEnabled()) { log.debug("Too light " + r + " " + g + " " + b); } color = getNextColor(); } else { if (log.isDebugEnabled()) { log.debug("New " + r + " " + g + " " + b); } color = new Color(r, g, b); } assignedColors.add(color); return color; } CycleColors(); }
CycleColors implements ColorsDispatcher { public Color getNextColor() { Color color = null; doCycles(); int r = 0, g = 0, b = 0; if ((bits & 1) == 1) { r = level; } if ((bits & 2) == 2) { b = level; } if ((bits & 4) == 4) { g = level; } Color c = new Color(r, g, b); if (assignedColors.contains(c)) { if (log.isDebugEnabled()) { log.debug("Existing " + r + " " + g + " " + b); } color = getNextColor(); } else if ((r + g + b) / 3 < 32) { if (log.isDebugEnabled()) { log.debug("Too dark " + r + " " + g + " " + b); } color = getNextColor(); } else if ((r + g + b) / 3 > 256 - 64) { if (log.isDebugEnabled()) { log.debug("Too light " + r + " " + g + " " + b); } color = getNextColor(); } else { if (log.isDebugEnabled()) { log.debug("New " + r + " " + g + " " + b); } color = new Color(r, g, b); } assignedColors.add(color); return color; } CycleColors(); void reset(); Color getNextColor(); }
CycleColors implements ColorsDispatcher { public Color getNextColor() { Color color = null; doCycles(); int r = 0, g = 0, b = 0; if ((bits & 1) == 1) { r = level; } if ((bits & 2) == 2) { b = level; } if ((bits & 4) == 4) { g = level; } Color c = new Color(r, g, b); if (assignedColors.contains(c)) { if (log.isDebugEnabled()) { log.debug("Existing " + r + " " + g + " " + b); } color = getNextColor(); } else if ((r + g + b) / 3 < 32) { if (log.isDebugEnabled()) { log.debug("Too dark " + r + " " + g + " " + b); } color = getNextColor(); } else if ((r + g + b) / 3 > 256 - 64) { if (log.isDebugEnabled()) { log.debug("Too light " + r + " " + g + " " + b); } color = getNextColor(); } else { if (log.isDebugEnabled()) { log.debug("New " + r + " " + g + " " + b); } color = new Color(r, g, b); } assignedColors.add(color); return color; } CycleColors(); void reset(); Color getNextColor();  }