public static synchronized void drawSingleGradientRect( MenuItem item, float x, float y, float width, float height, float roundOff) { Menu menu = item.menu; MenuStyle style = item.getStyle(); roundRect.setRoundRect(x, y, width, height, roundOff, roundOff); Graphics2D g2 = menu.buff.g2; /* * Set the correct fill gradient */ if (item.isOpen()) { g2.setPaint(item.getStyle().getGradient(MenuItem.DOWN, y, y + height)); } else { g2.setPaint(item.getStyle().getGradient(MenuItem.OVER, y, y + height)); } /* * Only perform the fill if the mood is right. */ if (item.getState() != MenuItem.UP || item.isOpen()) { g2.fill(roundRect); } /* * Draw the rounded rectangle outline. */ if (item.getState() != MenuItem.UP || item.isOpen()) { drawRoundOutline(item, roundRect); } }
public boolean hasOpenChildren() { for (int i = 0; i < items.size(); i++) { MenuItem item = (MenuItem) items.get(i); if (item.isOpen()) return true; } return false; }
int maxDepth(MenuItem item) { int max = 0; if (!item.isOpen()) { max = 0; } else { for (int i = 0; i < item.items.size(); i++) { MenuItem child = (MenuItem) item.items.get(i); int childDepth = maxDepth(child); if (childDepth + 1 > max) max = childDepth + 1; } } return max; }
public void findMaxLevelOpen() { MenuItem item = this; maxLevelOpen = 0; boolean shouldContinue = true; while (shouldContinue) { maxLevelOpen++; shouldContinue = false; for (int i = 0; i < item.items.size(); i++) { MenuItem item2 = (MenuItem) item.items.get(i); if (item2.isOpen()) { item = item2; shouldContinue = true; break; } } } }