From 925ca60aa4ad4cdffd42d8aeca5c912af782f5f6 Mon Sep 17 00:00:00 2001 From: Nico Mack Date: Mon, 9 Nov 2020 10:45:10 +0100 Subject: [PATCH] Minor performance improvements by removing unnecessary shape operations. --- .../dkd/tui/widget/corona/CoxcombSlice.java | 76 +++++-------------- 1 file changed, 20 insertions(+), 56 deletions(-) diff --git a/CPS/src/lu/list/itis/dkd/tui/widget/corona/CoxcombSlice.java b/CPS/src/lu/list/itis/dkd/tui/widget/corona/CoxcombSlice.java index 9d19345..528ade5 100644 --- a/CPS/src/lu/list/itis/dkd/tui/widget/corona/CoxcombSlice.java +++ b/CPS/src/lu/list/itis/dkd/tui/widget/corona/CoxcombSlice.java @@ -93,7 +93,6 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider 0) ? new BasicStroke(strokeWidth) : null; - // int availableWidth; - // - // if (wrapToFit) { - // if (!radialLayout) { - // double arcLength = Math.PI * ((upperBoundRadius + lowerBoundRadius) / 2) * (arcSpan / - // AngleUtils.ONE_EIGHTY); - // availableWidth = (int) arcLength - 2 * insetBorder; - // } else { - // availableWidth = (int) (upperBoundRadius - lowerBoundRadius - 2 * insetBorder); - // } - // lines = StringUtils.wrapToFit(label, availableWidth, textFont); - // } else { - // lines = new ArrayList<>(); - // lines.add(label); - // } - // - // if (!radialLayout) { - // labelShape = this.buildCircularText(lines, metrics); - // } else { - // labelShape = this.buildRadialText(lines, metrics, correctedAngle); - // } - this.setInformation(this.variable.getValue()); this.setSelected(this.isSelected); } // --------------------------------------------------------------------------- + private Shape buildSector(double radius, double diameter) { + Shape sector = (arcSpan < AngleUtils.THREE_SIXTY) + ? new Arc2D.Double(-radius, -radius, diameter, diameter, correctedAngle, arcSpan, Arc2D.PIE) + : new Ellipse2D.Double(-radius, -radius, diameter, diameter); + return sector; + } + + // --------------------------------------------------------------------------- + private void updateSlice() { double diameter; List lines; @@ -342,20 +303,22 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider