/** * The user clicked on the clarifier. * * @param x the x of the point clicked * @param y the y of the point clicked * @return the todo item clicked */ public ToDoItem hitClarifier(int x, int y) { int iconPos = 25, xOff = -4, yOff = -4; Point p = new Point(); ToDoList list = Designer.theDesigner().getToDoList(); Vector items = list.elementsForOffender(getOwner()); int size = items.size(); for (int i = 0; i < size; i++) { ToDoItem item = (ToDoItem) items.elementAt(i); Icon icon = item.getClarifier(); stuffPointAlongPerimeter(iconPos, p); int width = icon.getIconWidth(); int height = icon.getIconHeight(); if (y >= p.y + yOff && y <= p.y + height + yOff && x >= p.x + xOff && x <= p.x + width + xOff) return item; iconPos += width; } for (int i = 0; i < size; i++) { ToDoItem item = (ToDoItem) items.elementAt(i); Icon icon = item.getClarifier(); if (icon instanceof Clarifier) { ((Clarifier) icon).setFig(this); ((Clarifier) icon).setToDoItem(item); if (((Clarifier) icon).hit(x, y)) return item; } } items = list.elementsForOffender(this); size = items.size(); for (int i = 0; i < size; i++) { ToDoItem item = (ToDoItem) items.elementAt(i); Icon icon = item.getClarifier(); stuffPointAlongPerimeter(iconPos, p); int width = icon.getIconWidth(); int height = icon.getIconHeight(); if (y >= p.y + yOff && y <= p.y + height + yOff && x >= p.x + xOff && x <= p.x + width + xOff) return item; iconPos += width; } for (int i = 0; i < size; i++) { ToDoItem item = (ToDoItem) items.elementAt(i); Icon icon = item.getClarifier(); if (icon instanceof Clarifier) { ((Clarifier) icon).setFig(this); ((Clarifier) icon).setToDoItem(item); if (((Clarifier) icon).hit(x, y)) return item; } } return null; }
/** @param g the <code>Graphics</code> object */ protected void paintClarifiers(Graphics g) { // #if defined(COGNITIVE) // @#$LPS-COGNITIVE:GranularityType:MethodBody // @#$LPS-COGNITIVE:Localization:EntireMethod int iconPos = 25, gap = 1, xOff = -4, yOff = -4; Point p = new Point(); ToDoList list = Designer.theDesigner().getToDoList(); Vector items = list.elementsForOffender(getOwner()); int size = items.size(); for (int i = 0; i < size; i++) { ToDoItem item = (ToDoItem) items.elementAt(i); Icon icon = item.getClarifier(); if (icon instanceof Clarifier) { ((Clarifier) icon).setFig(this); ((Clarifier) icon).setToDoItem(item); } if (icon != null) { stuffPointAlongPerimeter(iconPos, p); icon.paintIcon(null, g, p.x + xOff, p.y + yOff); iconPos += icon.getIconWidth() + gap; } } items = list.elementsForOffender(this); size = items.size(); for (int i = 0; i < size; i++) { ToDoItem item = (ToDoItem) items.elementAt(i); Icon icon = item.getClarifier(); if (icon instanceof Clarifier) { ((Clarifier) icon).setFig(this); ((Clarifier) icon).setToDoItem(item); } if (icon != null) { stuffPointAlongPerimeter(iconPos, p); icon.paintIcon(null, g, p.x + xOff, p.y + yOff); iconPos += icon.getIconWidth() + gap; } } // #endif }