public RelationDecoration(boolean fill, Feature lastChild, LinkedList<Feature> children) { super(); this.fill = fill; this.children = children; this.lastChild = lastChild; final Color decoratorForgroundColor = FMPropertyManager.getDecoratorForgroundColor(); setForegroundColor(decoratorForgroundColor); setBackgroundColor(decoratorForgroundColor); final int diameter = getTargetAnchorDiameter(); setSize(diameter, diameter >> 1); if (lastChild != null) { featureModel = lastChild.getFeatureModel(); this.vertical = FeatureUIHelper.hasVerticalLayout(featureModel); } }
@Override protected void fillShape(Graphics graphics) { if (!fill) return; double highestAngle1 = Integer.MAX_VALUE; double highestAngle2 = Integer.MIN_VALUE; Rectangle r = calculateRectangle(); Point center = r.getCenter(); if (this instanceof LegendRelationDecoration) { highestAngle2 = HALF_ARC ? 360 : calculateAngle(center, getFeatureLocation()); highestAngle1 = HALF_ARC ? 180 : calculateAngle(center, referencePoint); graphics.fillArc(r, (int) highestAngle1, (int) (highestAngle2 - highestAngle1)); } else { if (children != null) { for (int i = 0; i < children.size(); i++) { Feature temp; temp = this.lastChild; this.lastChild = children.get(i); if (!(this.lastChild.isHidden() && !FeatureUIHelper.showHiddenFeatures(featureModel))) { double angle2 = HALF_ARC ? 360 : calculateAngle(center, getFeatureLocation()); double angle1 = HALF_ARC ? 180 : calculateAngle(center, getFeatureLocation()); if (angle2 > 450 && !vertical) { highestAngle1 = 180; } else { if (angle1 < highestAngle1) { highestAngle1 = angle1; } if (angle2 > highestAngle2) { highestAngle2 = angle2; } else { this.lastChild = temp; } } } } } else { highestAngle2 = HALF_ARC ? 360 : calculateAngle(center, getFeatureLocation()); } r.shrink(7, 7); if (vertical) { r.shrink(1, 1); if (highestAngle2 < 270) graphics.fillArc(r.x - 20, r.y + 10, r.width, r.height, 270, (180)); else graphics.fillArc( r.x - 20, r.y + 10, r.width, r.height, (int) highestAngle1, (int) (highestAngle2 - highestAngle1)); } else { if (highestAngle1 > 360) graphics.fillArc(r, 180, 180); // if(highestAngle2>450) graphics.fillArc(r, (int) highestAngle1, (int) (highestAngle2 - highestAngle1)); // else // graphics.fillArc(r,(int) highestAngle1, (int)(highestAngle2 - highestAngle1)); } } }
protected Point getFeatureLocation() { return FeatureUIHelper.getSourceLocation(lastChild); }