r322 - trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer
Author: echatellier Date: 2011-01-04 18:39:14 +0100 (Tue, 04 Jan 2011) New Revision: 322 Url: http://nuiton.org/repositories/revision/nuiton-matrix/322 Log: Ajout de filtres pour transformer les matrices apres reduction et avant rendu Added: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixFilter.java Modified: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixViewerPanel.java Added: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixFilter.java =================================================================== --- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixFilter.java (rev 0) +++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixFilter.java 2011-01-04 17:39:14 UTC (rev 322) @@ -0,0 +1,48 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 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 + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package org.nuiton.math.matrix.viewer; + +import org.nuiton.math.matrix.MatrixND; + +/** + * Matrix filtering used by matrix panel viewer. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public interface MatrixFilter { + + /** + * Filter input matrix. + * + * @param matrix matrix to filter + * @return filtered matrix + */ + public MatrixND filter(MatrixND matrix); +} Property changes on: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixFilter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixViewerPanel.java =================================================================== --- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixViewerPanel.java 2010-12-21 16:20:31 UTC (rev 321) +++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixViewerPanel.java 2011-01-04 17:39:14 UTC (rev 322) @@ -39,6 +39,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -90,6 +91,9 @@ /** Matrix renderer plugins. */ protected List<MatrixRenderer> matrixRenderers; + /** Matrix filters (used after matrix reduction). */ + protected List<MatrixFilter> matrixFilters; + /** Matrices to render (depend on {@link #matrixComboVisible} to {@code true}). */ protected List<MatrixND> matrices; @@ -112,6 +116,7 @@ public MatrixViewerPanel() { matrixRenderers = new ArrayList<MatrixRenderer>(); + matrixFilters = new ArrayList<MatrixFilter>(); matrices = new ArrayList<MatrixND>(); componentForRenderers = new HashMap<MatrixRenderer, Component>(); @@ -150,6 +155,23 @@ return result; } + /** + * Add new matrix filter. + * Used after matrix reduction and before matrix rendering. + * + * @param matrixFilter matrix filter + * @return {@code true} (as specified by {@link Collection#add(Object)} + */ + public boolean addMatrixFilter(MatrixFilter matrixFilter) { + boolean result = matrixFilters.add(matrixFilter); + return result; + } + + public boolean removeMatrixFilter(Object matrixFilter) { + boolean result = matrixFilters.remove(matrixFilter); + return result; + } + public void addMatrix(MatrixND... matrices) { for (MatrixND matrix : matrices) { this.matrices.add(matrix); @@ -342,7 +364,9 @@ if ("render".equals(actionCommand)) { // get matrix to display MatrixND matrix = dimensionPanel.getModifiedMatrix(); - + // filter matrix + matrix = getFilteredMatrix(matrix); + // matrice superieur a 2 dimensions non geree!! if (matrix.getDimCount() > 2) { JOptionPane.showMessageDialog(this, _("nuitonmatrix.viewer.matrix.more.2d"), @@ -364,6 +388,21 @@ updateSelectedRenderingComponent(); } } + + /** + * Filter matrix if any filter is defined. + * (after reduction and before rendering) + * + * @param matrix matrix to filter + * @return filtered matrix + */ + protected MatrixND getFilteredMatrix(MatrixND matrix) { + MatrixND filteredMatrix = matrix; + for (MatrixFilter matrixFilter : matrixFilters) { + filteredMatrix = matrixFilter.filter(filteredMatrix); + } + return filteredMatrix; + } } /** Radio button rendering panel. */
participants (1)
-
echatellier@users.nuiton.org