Skip to content

Commit

Permalink
fixed the issue that the direct contributions in the
Browse files Browse the repository at this point in the history
Sankey diagram are strange: The direct contributions were related to
the maximum direct contribution of all processes. This makes no sense:
they should be related to the maximum value of the upstream
contributions (which is in most cases the total result of the product
system)
  • Loading branch information
msrocka committed Mar 20, 2019
1 parent a4f2b4f commit 69e2d46
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,30 @@ public void calculate(Object selection) {
} else {
directResults = upstreamResults = new double[processIndex.size()];
}
upstreamContributions = calcContributions(upstreamResults);
directContributions = calcContributions(directResults);

// calculate the contributions
double refVal = Math.max(
Math.abs(Doubles.min(upstreamResults)),
Math.abs(Doubles.max(upstreamResults)));
upstreamContributions = calcContributions(
upstreamResults, refVal);
directContributions = calcContributions(
directResults, refVal);

log.trace("Calculation done");
}

private double[] calcContributions(double[] values) {
private double[] calcContributions(double[] values, double ref) {
if (values == null || values.length == 0)
return new double[0];
double min = Doubles.min(values);
double max = Doubles.max(values);
double ref = Math.max(Math.abs(min), Math.abs(max));
double[] contributions = new double[values.length];
double[] conts = new double[values.length];
if (ref == 0)
return contributions;
for (int i = 0; i < contributions.length; i++) {
return conts;
for (int i = 0; i < conts.length; i++) {
double val = values[i];
contributions[i] = val / ref;
conts[i] = val / ref;
}
return contributions;
return conts;
}

private double[] vec(ToDoubleFunction<CategorizedDescriptor> fn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public class ProcessFigure extends Figure {
/** Must be disposed when the edit part is deactivated */
Font boldFont;

public ProcessFigure(ProcessNode processNode) {
setToolTip(new Label(Labels.getDisplayName(processNode.process)));
processNode.figure = this;
this.node = processNode;
public ProcessFigure(ProcessNode node) {
setToolTip(new Label(Labels.getDisplayName(node.process)));
node.figure = this;
this.node = node;
setSize(WIDTH, HEIGHT);
processNode.setXyLayoutConstraints(getBounds());
addMouseListener(new ProcessMouseClick(processNode));
node.setXyLayoutConstraints(getBounds());
addMouseListener(new ProcessMouseClick(node));
setVisible(false);
}

Expand Down

0 comments on commit 69e2d46

Please sign in to comment.