r405 - in trunk: . nuiton-matrix-gui nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/renderer/jfreechart
Author: echatellier Date: 2012-01-04 15:03:15 +0100 (Wed, 04 Jan 2012) New Revision: 405 Url: http://nuiton.org/repositories/revision/nuiton-matrix/405 Log: #1861 : Graph rendering only works with jfreechart 1.0.12 Modified: trunk/nuiton-matrix-gui/pom.xml trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/renderer/jfreechart/GraphMatrixNDDataset.java trunk/pom.xml Modified: trunk/nuiton-matrix-gui/pom.xml =================================================================== --- trunk/nuiton-matrix-gui/pom.xml 2012-01-04 11:44:38 UTC (rev 404) +++ trunk/nuiton-matrix-gui/pom.xml 2012-01-04 14:03:15 UTC (rev 405) @@ -51,7 +51,7 @@ </dependency> <dependency> - <groupId>jfree</groupId> + <groupId>org.jfree</groupId> <artifactId>jfreechart</artifactId> </dependency> </dependencies> Modified: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/renderer/jfreechart/GraphMatrixNDDataset.java =================================================================== --- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/renderer/jfreechart/GraphMatrixNDDataset.java 2012-01-04 11:44:38 UTC (rev 404) +++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/renderer/jfreechart/GraphMatrixNDDataset.java 2012-01-04 14:03:15 UTC (rev 405) @@ -3,7 +3,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2002 - 2010 Ifremer, CodeLutin, Chatellier Eric + * Copyright (C) 2002 - 2012 Ifremer, CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -47,10 +47,10 @@ private static final long serialVersionUID = -891382923646394164L; /** The series names. */ - protected List<?> seriesNames; + protected List<String> seriesNames; /** The categories. */ - protected List<?> categories; + protected List<String> categoriesNames; /** Storage for the data. */ protected MatrixND mat; @@ -63,11 +63,11 @@ * Constructs a GraphMatrixNDDataset, populates it with the matrix, and uses the * supplied names for the series and the supplied objects for the categories. * - * @param seriesNames series names. + * @param series series names. * @param categories categories. * @param mat matrix. */ - public GraphMatrixNDDataset(List<?> seriesNames, List<?> categories, MatrixND mat) { + public GraphMatrixNDDataset(List<?> series, List<?> categories, MatrixND mat) { this.mat = mat; @@ -80,49 +80,59 @@ if (seriesCount > 0) { // set up the series names... - if (seriesNames != null) { - - if (seriesNames.size() != seriesCount) { + if (series != null) { + + if (series.size() != seriesCount) { throw new IllegalArgumentException( "DefaultCategoryDataset: the number of " + "series names does not match the number of series in the data."); } - this.seriesNames = seriesNames; + //since jfreechart 1.0.13 doesn't work anymore + //because of getRowKey that return toString + //so indexOf(String) in a list of entities always return -1 + //this.seriesNames = seriesNames; + seriesNames = new ArrayList<String>(seriesCount); + for (int i = 0; i < seriesCount; i++) { + Object dim = mat.getSemantic(1).get(i); + seriesNames.add(dim.toString()); // must match getRowKey() + } } else { String prefix = resources - .getString("series.default-prefix") - + " "; + .getString("series.default-prefix") + " "; this.seriesNames = this.generateNames(seriesCount, prefix); } - if (mat.getDimCount() > 1) { - // set up the category names... - int categoryCount = mat.getDim(0); - if (categories != null) { - if (categories.size() != categoryCount) { - throw new IllegalArgumentException( - "DefaultCategoryDataset: the number of " - + "categories does not match the number of categories in the data."); - } - this.categories = categories; - } else { - String prefix = resources - .getString("categories.default-prefix") - + " "; - this.categories = this.generateNames(categoryCount, - prefix); + // set up the category names... + int categoryCount = mat.getDim(0); + if (categories != null) { + if (categories.size() != categoryCount) { + throw new IllegalArgumentException( + "DefaultCategoryDataset: the number of " + + "categories does not match the number of categories in the data."); } + + //since jfreechart 1.0.13 doesn't work anymore + //because of getRowKey that return toString + //so indexOf(String) in a list of entities always return -1 + //this.categoriesNames = categories; + categoriesNames = new ArrayList<String>(categoryCount); + for (int i = 0; i < categoryCount; i++) { + Object dim = mat.getSemantic(0).get(i); + categoriesNames.add(dim.toString()); // must match getRowKey() + } } else { - this.categories = null; + String prefix2 = resources + .getString("categories.default-prefix") + " "; + categoriesNames = this.generateNames(categoryCount, prefix2); } } else { this.seriesNames = null; - this.categories = null; + this.categoriesNames = null; } } else { this.seriesNames = null; - this.categories = null; + this.categoriesNames = null; } } @@ -134,10 +144,9 @@ * @param prefix name prefix. */ protected List<String> generateNames(int count, String prefix) { - List<String> result = new ArrayList<String>(); - String name; + List<String> result = new ArrayList<String>(count); for (int i = 0; i < count; i++) { - name = prefix + (i + 1); + String name = prefix + (i + 1); result.add(name); } return result; @@ -168,7 +177,7 @@ */ @Override public int getColumnIndex(Comparable key) { - return categories.indexOf(key); + return categoriesNames.indexOf(key); } /* @@ -176,7 +185,7 @@ */ @Override public Comparable getColumnKey(int column) { - return categories.get(column).toString(); + return categoriesNames.get(column).toString(); } /* @@ -187,10 +196,10 @@ // the CategoryDataset interface expects a list of categories, but we've stored them in // an array... - if (categories == null) { + if (categoriesNames == null) { return Collections.EMPTY_LIST; } else { - return Collections.unmodifiableList(categories); + return Collections.unmodifiableList(categoriesNames); } } @@ -231,7 +240,7 @@ */ @Override public int getColumnCount() { - return categories.size(); + return categoriesNames.size(); } /* @@ -247,6 +256,7 @@ */ @Override public Number getValue(int row, int column) { - return new Double(mat.getValue(column, row)); + Number result = new Double(mat.getValue(column, row)); + return result; } } // GraphMatrixNDDataset Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-01-04 11:44:38 UTC (rev 404) +++ trunk/pom.xml 2012-01-04 14:03:15 UTC (rev 405) @@ -65,9 +65,9 @@ </dependency> <dependency> - <groupId>jfree</groupId> + <groupId>org.jfree</groupId> <artifactId>jfreechart</artifactId> - <version>1.0.13</version> + <version>1.0.14</version> <scope>compile</scope> </dependency> </dependencies> @@ -147,5 +147,4 @@ <url>${our.site.repository}/${projectId}</url> </site> </distributionManagement> - </project>
participants (1)
-
echatellier@users.nuiton.org