class RhythmGroupItem extends SimpleMapItem { String id; RhythmGroupBinItem parent; float depth; float hue; float sat = 80; float bri = 80; //rhythmgroupitems inherit a size and order from SimpleMapItem float boxLeft, boxTop, boxRight, boxBottom; float textPadding = 8; RhythmGroupItem(RhythmGroupBinItem parent, String id, int order, float depth) { this.parent = parent; this.id = id; this.depth = depth; //for now, rhythm groups are all equivalently sized size = 1; //and they are just ordered numerically this.order = order; } float boxOffset = 0.01; void draw() { calcBox(); colorMode(HSB, 360, 100, 100); fill(hue, sat, bri); strokeWeight(0.2f); stroke(hue, 100, 20); rect(boxLeft + boxOffset, boxTop + boxOffset, boxRight - boxOffset, boxBottom - boxOffset); //rect(boxLeft+depth-1, boxTop+depth-1, boxRight-depth-1, boxBottom-depth-1); //rect(boxLeft + depth/2, boxTop + depth/2, boxRight - depth/2, boxBottom - depth/2); //drawTitle(); } void drawOutline() { calcBox(); noFill(); stroke(255, 0, 100); strokeWeight(2.0f); rect(boxLeft + boxOffset, boxTop + boxOffset, boxRight - boxOffset, boxBottom - boxOffset); } void drawTitle() { fill(0); textAlign(LEFT); text(id, boxLeft + textPadding, boxBottom - textPadding); } boolean mousePressed(boolean expandTree) { if (mouseInside()) { if (mouseButton == RIGHT && parent != null) { if (expandTree) { parent.hideContents(); } selectedItem = null; selectedItemRGs = null; statusTranslateY = 0; return true; } if (mouseButton == LEFT) { selectedItem = this; selectedItemRGs = this.getContainedRhythmGroups(); Collections.shuffle(selectedItemRGs); statusTranslateY = 0; } } return false; } void calcBox() { boxLeft = x; boxTop = y; boxRight = x+w; boxBottom = y+h; } boolean mouseInside() { return (mouseX > boxLeft && mouseX < boxRight && mouseY > boxTop && mouseY < boxBottom); } boolean textFits() { float wide = textWidth(id) + textPadding*2; float high = textAscent() + textDescent() + textPadding*2; return (boxRight - boxLeft > wide) && (boxBottom - boxTop > high); } ArrayList getContainedRhythmGroups() { ArrayList retList = new ArrayList(); retList.add(int(id)); return retList; } double getSize() { return size; } ArrayList getBinsAtDepth(float d) { return new ArrayList(); } void propagateColorToChildren(float _hue) { hue = _hue; } ArrayList getSiblings() { return new ArrayList(); } }