From ed6eee466c185fbc257e9228da41678c6d527b02 Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Mon, 30 Oct 2017 11:50:05 +0000 Subject: [PATCH] JAL-2795 foresterMatrix now stores distance values itself --- src/jalview/ext/forester/ForesterMatrix.java | 28 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/jalview/ext/forester/ForesterMatrix.java b/src/jalview/ext/forester/ForesterMatrix.java index d4864cf..0500704 100644 --- a/src/jalview/ext/forester/ForesterMatrix.java +++ b/src/jalview/ext/forester/ForesterMatrix.java @@ -17,27 +17,37 @@ public class ForesterMatrix implements DistanceMatrix private final static NumberFormat PHYLIP_FORMATTER = new DecimalFormat( "0.000000"); // straight from forester - private final MatrixI jalviewMatrix; - private final Sequence[] sequences; + private Sequence[] sequences; + + private int width; + + private int height; private final double[][] values; + private String[] identifiers; + public ForesterMatrix(MatrixI jalviewInputMatrix, Sequence[] matrixSequences) { - this.jalviewMatrix = jalviewInputMatrix; + width = jalviewInputMatrix.width(); + height = jalviewInputMatrix.height(); + values = new double[width][height]; + this.sequences = matrixSequences; - if (jalviewMatrix.width() != jalviewMatrix.height()) + + if (width != height) { // some kind of warning? } - values = new double[jalviewMatrix.width()][jalviewMatrix.height()]; + } + @Override public String getIdentifier(int i) { @@ -54,13 +64,13 @@ public class ForesterMatrix implements DistanceMatrix @Override public int getSize() { - return jalviewMatrix.width(); + return values.length; } @Override public double getValue(int col, int row) { - return jalviewMatrix.getValue(row, col); + return values[row][col]; } @Override @@ -73,7 +83,7 @@ public class ForesterMatrix implements DistanceMatrix @Override public void setValue(int col, int row, double distance) { - jalviewMatrix.setValue(row, col, distance); + values[row][col] = distance; } @@ -88,7 +98,7 @@ public class ForesterMatrix implements DistanceMatrix public double[][] getValues() { - return null; + return values; } @Override -- 1.7.10.2