From: kjvdheide Date: Mon, 30 Oct 2017 13:22:17 +0000 (+0000) Subject: JAL-2795 add get for all matrix values to MatrixI (and concrete classes) X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=433c0001db1f1771ede8e2e6a010ba5a1aea06eb;p=jalview.git JAL-2795 add get for all matrix values to MatrixI (and concrete classes) --- diff --git a/src/jalview/ext/forester/ForesterMatrix.java b/src/jalview/ext/forester/ForesterMatrix.java index 0500704..9090d94 100644 --- a/src/jalview/ext/forester/ForesterMatrix.java +++ b/src/jalview/ext/forester/ForesterMatrix.java @@ -17,13 +17,10 @@ public class ForesterMatrix implements DistanceMatrix private final static NumberFormat PHYLIP_FORMATTER = new DecimalFormat( "0.000000"); // straight from forester + private final MatrixI jalviewMatrix; private Sequence[] sequences; - private int width; - - private int height; - private final double[][] values; private String[] identifiers; @@ -31,22 +28,34 @@ public class ForesterMatrix implements DistanceMatrix public ForesterMatrix(MatrixI jalviewInputMatrix, Sequence[] matrixSequences) { - width = jalviewInputMatrix.width(); - height = jalviewInputMatrix.height(); - values = new double[width][height]; - + this.jalviewMatrix = jalviewInputMatrix; this.sequences = matrixSequences; - if (width != height) + if (jalviewMatrix.width() != jalviewMatrix.height()) { // some kind of warning? } - + values = new double[jalviewMatrix.width()][jalviewMatrix.height()]; } + public ForesterMatrix(MatrixI jalviewInputMatrix, + String[] matrixIdentifiers) + { + this.jalviewMatrix = jalviewInputMatrix; + this.identifiers = matrixIdentifiers; + + + if (jalviewMatrix.width() != jalviewMatrix.height()) + { + // some kind of warning? + } + + values = new double[jalviewMatrix.width()][jalviewMatrix.height()]; + + } @Override public String getIdentifier(int i) @@ -64,13 +73,13 @@ public class ForesterMatrix implements DistanceMatrix @Override public int getSize() { - return values.length; + return jalviewMatrix.width(); } @Override public double getValue(int col, int row) { - return values[row][col]; + return jalviewMatrix.getValue(row, col); } @Override @@ -83,7 +92,7 @@ public class ForesterMatrix implements DistanceMatrix @Override public void setValue(int col, int row, double distance) { - values[row][col] = distance; + jalviewMatrix.setValue(row, col, distance); } @@ -98,7 +107,7 @@ public class ForesterMatrix implements DistanceMatrix public double[][] getValues() { - return values; + return null; } @Override diff --git a/src/jalview/math/Matrix.java b/src/jalview/math/Matrix.java index 8910c67..21c5a4d 100755 --- a/src/jalview/math/Matrix.java +++ b/src/jalview/math/Matrix.java @@ -995,4 +995,10 @@ public class Matrix implements MatrixI } } } + + @Override + public double[][] getValues() + { + return value; + } } diff --git a/src/jalview/math/MatrixI.java b/src/jalview/math/MatrixI.java index 5b93c76..f4d5030 100644 --- a/src/jalview/math/MatrixI.java +++ b/src/jalview/math/MatrixI.java @@ -63,6 +63,9 @@ public interface MatrixI */ double[] getRow(int i); + double[][] getValues(); + + MatrixI copy(); MatrixI transpose();