Nuiton-matrix-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
April 2011
- 2 participants
- 13 discussions
08 Apr '11
Author: echatellier
Date: 2011-04-08 15:10:03 +0200 (Fri, 08 Apr 2011)
New Revision: 347
Url: http://nuiton.org/repositories/revision/nuiton-matrix/347
Log:
Modify version (api break)
Modified:
trunk/nuiton-matrix-gui/pom.xml
trunk/nuiton-matrix/pom.xml
trunk/pom.xml
Modified: trunk/nuiton-matrix/pom.xml
===================================================================
--- trunk/nuiton-matrix/pom.xml 2011-04-07 12:26:45 UTC (rev 346)
+++ trunk/nuiton-matrix/pom.xml 2011-04-08 13:10:03 UTC (rev 347)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>matrix</artifactId>
- <version>2.1.1-SNAPSHOT</version>
+ <version>2.2-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.matrix</groupId>
Modified: trunk/nuiton-matrix-gui/pom.xml
===================================================================
--- trunk/nuiton-matrix-gui/pom.xml 2011-04-07 12:26:45 UTC (rev 346)
+++ trunk/nuiton-matrix-gui/pom.xml 2011-04-08 13:10:03 UTC (rev 347)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>matrix</artifactId>
- <version>2.1.1-SNAPSHOT</version>
+ <version>2.2-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.matrix</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-04-07 12:26:45 UTC (rev 346)
+++ trunk/pom.xml 2011-04-08 13:10:03 UTC (rev 347)
@@ -14,7 +14,7 @@
</parent>
<artifactId>matrix</artifactId>
- <version>2.1.1-SNAPSHOT</version>
+ <version>2.2-SNAPSHOT</version>
<modules>
<module>nuiton-matrix</module>
1
0
r346 - in trunk/nuiton-matrix-gui/src: main/java/org/nuiton/math/matrix/viewer test/java/org/nuiton/math/matrix/viewer
by echatellier@users.nuiton.org 07 Apr '11
by echatellier@users.nuiton.org 07 Apr '11
07 Apr '11
Author: echatellier
Date: 2011-04-07 14:26:45 +0200 (Thu, 07 Apr 2011)
New Revision: 346
Url: http://nuiton.org/repositories/revision/nuiton-matrix/346
Log:
Evolution #1437: Remove MatrixPanelViewer matrix list
Evolution #1441: Add dimension action support
Added:
trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixDimensionAction.java
trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/SumAllAction.java
Modified:
trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixDimensionPanel.java
trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixRenderer.java
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/package-info.java
trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/viewer/MatrixViewerPanelTest.java
Added: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixDimensionAction.java
===================================================================
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixDimensionAction.java (rev 0)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixDimensionAction.java 2011-04-07 12:26:45 UTC (rev 346)
@@ -0,0 +1,82 @@
+/*
+ * #%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 javax.swing.Icon;
+
+/**
+ * Action de regroupement des valeurs d'une dimension, pour faire des sommes...
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface MatrixDimensionAction {
+
+ /**
+ * Action icon.
+ *
+ * @return action icon
+ */
+ public Icon getIcon();
+
+ /**
+ * Action selected icon.
+ *
+ * @return action selected icon
+ */
+ public Icon getSelectedIcon();
+
+ /**
+ * Return l'index de la dimension sur lequel porte l'action.
+ *
+ * Used only if {@link #getDimensionType} returns {@code null}.
+ *
+ * Return -1 to affect all dimensions.
+ *
+ * @return dimension index
+ */
+ public int getDimensionIndex();
+
+ /**
+ * Return le type de dimension concerné par les actions.
+ *
+ * @return dimension type
+ */
+ public Class<?> getDimensionType();
+
+ /**
+ * Method getSumStep indique le pas d'increment pour la somme sur
+ * la dimension.
+ *
+ * @return -1 indique de faire la somme sur tous les elements. 1
+ * indique de faire la somme 1 a 1 (donc de ne pas faire de
+ * somme), 2 indiques de faire la somme 2 a 2, ...
+ */
+ public int getSumStep();
+}
Property changes on: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixDimensionAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixDimensionPanel.java
===================================================================
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixDimensionPanel.java 2011-04-04 13:09:43 UTC (rev 345)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixDimensionPanel.java 2011-04-07 12:26:45 UTC (rev 346)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Codelutin, Chatellier Eric
+ * Copyright (C) 2010 - 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
@@ -31,21 +31,24 @@
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;
+import javax.swing.ButtonGroup;
+import javax.swing.ButtonModel;
import javax.swing.DefaultListModel;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JToggleButton;
+import javax.swing.JToggleButton.ToggleButtonModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.AbstractMatrixND;
import org.nuiton.math.matrix.MatrixND;
-import org.nuiton.util.Resource;
/**
* Panel d'affichage des dimensions.
@@ -56,31 +59,45 @@
* Last update : $Date$
* By : $Author$
*/
-public class MatrixDimensionPanel extends JPanel {
+public class MatrixDimensionPanel extends JPanel implements PropertyChangeListener {
/** serialVersionUID. */
private static final long serialVersionUID = -1919447532660452240L;
/** Class logger. */
- private static Log log = LogFactory.getLog(AbstractMatrixND.class);
+ private static Log log = LogFactory.getLog(MatrixDimensionPanel.class);
/** Matrix to display (original). */
protected MatrixND matrix;
protected List<SubDimensionPanel> subPanelList;
+ protected List<MatrixDimensionAction> matrixDimentionActions;
+
public MatrixDimensionPanel() {
setLayout(new GridLayout(0, 1));
subPanelList = new ArrayList<MatrixDimensionPanel.SubDimensionPanel>();
+ matrixDimentionActions = new ArrayList<MatrixDimensionAction>();
+
+ // default sum all action
+ matrixDimentionActions.add(new SumAllAction());
}
- public MatrixND getMatrix() {
- return matrix;
+ /**
+ * Add new action. Protected to force call on MatrixViewerPanel.
+ *
+ * @param matrixDimentionAction new action
+ */
+ protected void addMatrixDimentionAction(MatrixDimensionAction matrixDimentionAction) {
+ matrixDimentionActions.add(matrixDimentionAction);
}
- public void setMatrix(MatrixND matrix) {
- this.matrix = matrix;
-
+ /*
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ this.matrix = (MatrixND)evt.getNewValue();
buildDimensionPanel();
validate();
repaint();
@@ -91,43 +108,108 @@
return reducedMatrix;
}
- protected static class SubDimensionPanel extends JPanel {
+ /** Button model from button containing action instance */
+ protected static class MatrixActionButtonModel extends ToggleButtonModel {
/** serialVersionUID. */
+ private static final long serialVersionUID = -5737246124430280412L;
+
+ protected MatrixDimensionAction matrixAction;
+
+ public MatrixActionButtonModel(MatrixDimensionAction matrixAction) {
+ this.matrixAction = matrixAction;
+ }
+
+ public MatrixDimensionAction getMatrixAction() {
+ return matrixAction;
+ }
+ }
+
+ protected class SubDimensionPanel extends JPanel {
+
+ /** serialVersionUID. */
private static final long serialVersionUID = 9170588695850504050L;
+ protected int index;
+
protected String semanticName;
protected List<?> semantic;
- protected JToggleButton sumAll;
+ /**
+ * Declaration d'un button group avec possibilité de deselectionne
+ * tous les boutons (methode setSelected surchargée).
+ */
+ protected ButtonGroup buttonGroup = new ButtonGroup() {
+ @Override
+ public void setSelected(ButtonModel m, boolean b) {
+ if (b) {
+ super.setSelected(m, b);
+ }
+ else {
+ clearSelection();
+ }
+ }
+ };
+
+ /**
+ * Gere a la main le group de bouton, car sinon, lors que le premier
+ * bouton est sélectionné, on ne peut pas le deselection
+ *
+ protected List<JToggleButton> buttonList = new ArrayList<JToggleButton>();*/
protected JList semList;
- public SubDimensionPanel(String semanticName, List<?> semantic) {
+ public SubDimensionPanel(int index, String semanticName, List<?> semantic) {
super(new GridBagLayout());
+ this.index = index;
this.semanticName = semanticName;
this.semantic = semantic;
renderSubPanel();
}
-
+
protected void renderSubPanel() {
// semantic name
JLabel semName = new JLabel(semanticName);
add(semName, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
-
- // sum all button
- sumAll = new JToggleButton(Resource.getIcon("/icons/sigma-barre.gif"));
- sumAll.setSelectedIcon(Resource.getIcon("/icons/sigma.gif"));
- add(sumAll, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST,
- GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
-
+
+ int nbActionAdded = 0;
+ for (MatrixDimensionAction matrixDimensionAction : matrixDimentionActions) {
+
+ boolean addSumAll = false;
+ Class<?> semType = matrixDimensionAction.getDimensionType();
+ if (semType != null) {
+ for (Object semValue : semantic) {
+ if (semValue != null && semValue.getClass().isAssignableFrom(semType)) {
+ addSumAll = true;
+ }
+ }
+ }
+ else {
+ int semIndex = matrixDimensionAction.getDimensionIndex();
+ if (semIndex == -1 || semIndex == index) {
+ addSumAll = true;
+ }
+ }
+
+ if (addSumAll) {
+ // sum all button
+ JToggleButton sumAll = new JToggleButton(matrixDimensionAction.getIcon());
+ sumAll.setSelectedIcon(matrixDimensionAction.getSelectedIcon());
+ sumAll.setModel(new MatrixActionButtonModel(matrixDimensionAction));
+ add(sumAll, new GridBagConstraints(1 + nbActionAdded, 0, 1, 1, 0, 0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
+ buttonGroup.add(sumAll);
+ nbActionAdded++;
+ }
+ }
+
// semantic list
semList = new JList();
SemanticListModel semModel = new SemanticListModel(semantic);
semList.setModel(semModel);
- add(new JScrollPane(semList), new GridBagConstraints(0, 1, 2, 1, 1, 1, GridBagConstraints.WEST,
+ add(new JScrollPane(semList), new GridBagConstraints(0, 1, 1 + nbActionAdded, 1, 1, 1, GridBagConstraints.WEST,
GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0));
}
@@ -139,14 +221,15 @@
* Method getSumStep indique le pas d'increment pour la somme sur
* la dimension.
*
- * @return -1 indique de faire la somme sur tous les elmements. 1
+ * @return -1 indique de faire la somme sur tous les elements. 1
* indique de faire la somme 1 a 1 (donc de ne pas faire de
* somme), 2 indiques de faire la somme 2 a 2, ...
*/
public int getSumStep() {
int result = 1;
- if (sumAll.isSelected()) {
- result = -1;
+ MatrixActionButtonModel buttonModel = (MatrixActionButtonModel)buttonGroup.getSelection();
+ if (buttonModel != null) {
+ result = buttonModel.getMatrixAction().getSumStep();
}
return result;
}
@@ -162,7 +245,7 @@
if (matrix != null) {
int index = 0;
for (List<?> semantic : matrix.getSemantics()) {
- SubDimensionPanel dimPanel = new SubDimensionPanel(_(matrix.getDimensionName(index)), semantic);
+ SubDimensionPanel dimPanel = new SubDimensionPanel(index, _(matrix.getDimensionName(index)), semantic);
add(dimPanel);
subPanelList.add(dimPanel);
index++;
Modified: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixRenderer.java
===================================================================
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixRenderer.java 2011-04-04 13:09:43 UTC (rev 345)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixRenderer.java 2011-04-07 12:26:45 UTC (rev 346)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Codelutin, Chatellier Eric
+ * Copyright (C) 2010 - 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
@@ -45,8 +45,9 @@
/**
* Renderer component for matrix.
*
- * @param matrix matrix to display
+ * @param matrix matrix to display (can be null with default rendering support)
* @return component
+ * @see MatrixViewerPanel#addMatrixRenderer(MatrixRenderer, boolean)
*/
Component getComponent(MatrixND matrix);
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 2011-04-04 13:09:43 UTC (rev 345)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/MatrixViewerPanel.java 2011-04-07 12:26:45 UTC (rev 346)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Codelutin, Chatellier Eric
+ * Copyright (C) 2010 - 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
@@ -34,21 +34,18 @@
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.swing.ButtonGroup;
-import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JButton;
-import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
@@ -74,32 +71,24 @@
/** serialVersionUID. */
private static final long serialVersionUID = -5447856858278176837L;
- public static final String PROPERTY_MATRIX_COMBO_VISIBLE = "matrixComboVisible";
-
public static final String PROPERTY_MATRIX_RENDERER_SOLUTION = "matrixRendererSolution";
public static final String PROPERTY_MATRIX_RENDERERS = "matrixRenderers";
- public static final String PROPERTY_MATRICES = "matrices";
+ public static final String PROPERTY_MATRIX = "matrix";
- /** Matrix list combo visibility (defaut to false). */
- protected boolean matrixComboVisible;
-
/** Matrix renderer list solution. (default to {@link MatrixRendererSolution#RADIO_BUTTON} */
protected MatrixRendererSolution matrixRendererSolution = MatrixRendererSolution.RADIO_BUTTON;
/** Matrix renderer plugins. */
- protected List<MatrixRenderer> matrixRenderers;
+ protected Map<MatrixRenderer, Boolean> 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;
+ /** La matrice courrement affichées. */
+ protected MatrixND matrix;
- /** Matrix list combo box. */
- protected MatrixComboBox matrixComboBox;
-
protected MatrixDimensionPanel dimensionPanel;
protected RadioButtonRenderingPanel radioPanel;
@@ -115,24 +104,14 @@
protected Map<MatrixRenderer, Component> componentForRenderers;
public MatrixViewerPanel() {
- matrixRenderers = new ArrayList<MatrixRenderer>();
+ // keep order
+ matrixRenderers = new LinkedHashMap<MatrixRenderer, Boolean>();
matrixFilters = new ArrayList<MatrixFilter>();
- matrices = new ArrayList<MatrixND>();
componentForRenderers = new HashMap<MatrixRenderer, Component>();
buildPanel();
}
- protected boolean isMatrixComboVisible() {
- return matrixComboVisible;
- }
-
- public void setMatrixComboVisible(boolean matrixComboVisible) {
- boolean oldValue = this.matrixComboVisible;
- this.matrixComboVisible = matrixComboVisible;
- firePropertyChange(PROPERTY_MATRIX_COMBO_VISIBLE, oldValue, matrixComboVisible);
- }
-
public MatrixRendererSolution getMatrixRendererSolution() {
return matrixRendererSolution;
}
@@ -143,16 +122,24 @@
firePropertyChange(PROPERTY_MATRIX_RENDERER_SOLUTION, oldValue, matrixRendererSolution);
}
- public boolean addMatrixRenderer(MatrixRenderer matrixRenderer) {
- boolean result = matrixRenderers.add(matrixRenderer);
+ public void addMatrixRenderer(MatrixRenderer matrixRenderer) {
+ addMatrixRenderer(matrixRenderer, false);
+ }
+
+ /**
+ * Add new matrix renderer.
+ *
+ * @param matrixRenderer matrix renderer
+ * @param defautRenderer renderer can be called with a null matrix to get default rendering
+ */
+ public void addMatrixRenderer(MatrixRenderer matrixRenderer, boolean defautRenderer) {
+ matrixRenderers.put(matrixRenderer, defautRenderer);
firePropertyChange(PROPERTY_MATRIX_RENDERERS, null, matrixRenderers);
- return result;
}
- public boolean removeMatrixRenderer(Object matrixRenderer) {
- boolean result = matrixRenderers.remove(matrixRenderer);
+ public void removeMatrixRenderer(Object matrixRenderer) {
+ matrixRenderers.remove(matrixRenderer);
firePropertyChange(PROPERTY_MATRIX_RENDERERS, null, matrixRenderers);
- return result;
}
/**
@@ -172,83 +159,35 @@
return result;
}
- public void addMatrix(MatrixND... matrices) {
- for (MatrixND matrix : matrices) {
- this.matrices.add(matrix);
- }
- firePropertyChange(PROPERTY_MATRICES, null, matrices);
+ /**
+ * Set currently displayed matrix.
+ *
+ * @param matrix new matrix to display
+ */
+ public void setMatrix(MatrixND matrix) {
+ MatrixND oldValue = this.matrix;
+ this.matrix = matrix;
+ firePropertyChange(PROPERTY_MATRIX, oldValue, matrix);
}
- public void removeMatrix(Object... matrices) {
- for (Object matrix : matrices) {
- this.matrices.remove(matrix);
- }
- firePropertyChange(PROPERTY_MATRICES, null, matrices);
+ /**
+ * Get currently displayed matrix.
+ *
+ * @return current matrix
+ */
+ public MatrixND getMatrix() {
+ return matrix;
}
- public void clearMatrix() {
- matrices.clear();
- firePropertyChange(PROPERTY_MATRICES, null, matrices);
+ /**
+ * Add new action.
+ *
+ * @param matrixDimentionAction new action
+ */
+ public void addMatrixDimentionAction(MatrixDimensionAction matrixDimentionAction) {
+ dimensionPanel.addMatrixDimentionAction(matrixDimentionAction);
}
- /** Matrix list combo box. */
- protected class MatrixComboBox extends JComboBox implements PropertyChangeListener, ItemListener {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -3166642639854195273L;
-
- public MatrixComboBox() {
- addItemListener(this);
- }
-
- /*
- * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
- */
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- setVisible(matrixComboVisible);
- }
-
- /*
- * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
- */
- @Override
- public void itemStateChanged(ItemEvent e) {
- dimensionPanel.setMatrix((MatrixND)getSelectedItem());
- }
- }
-
- /** Matrix list combo box model. */
- protected class MatrixComboBoxModel extends DefaultComboBoxModel implements PropertyChangeListener {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 4294576545040155208L;
-
- @Override
- public int getSize() {
- int result = matrices.size();
- return result;
- }
-
- @Override
- public Object getElementAt(int index) {
- Object matrix = matrices.get(index);
- return matrix;
- }
-
- /*
- * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
- */
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- fireContentsChanged(this, 0, matrices.size() - 1);
-
- if (getSelectedItem() == null && getSize() > 0) {
- setSelectedItem(getElementAt(0));
- }
- }
- }
-
/** Matrix list combo renderer. */
protected static class MatrixComboRenderer extends DefaultListCellRenderer {
@@ -259,10 +198,9 @@
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
- MatrixND matrix = (MatrixND)value;
String matrixName = null;
- if (matrix != null) {
- matrixName = _(matrix.getName());
+ if (value != null) {
+ matrixName = _((String)value);
}
return super.getListCellRendererComponent(list, matrixName, index, isSelected, cellHasFocus);
}
@@ -295,11 +233,11 @@
private static final long serialVersionUID = 2591696695747738619L;
protected ButtonGroup buttonGroup;
-
+
public IconButtonRenderingPanel() {
super(new GridBagLayout());
}
-
+
/*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
@@ -309,13 +247,13 @@
validate();
repaint();
}
-
+
/**
* Rebuild radio button lists.
*/
protected void rebuildPanel() {
removeAll();
-
+
JButton renderButton = new JButton(Resource.getIcon("/icons/1rightarrow.png"));
renderButton.setActionCommand("render");
renderButton.addActionListener(this);
@@ -326,11 +264,11 @@
int index = 1;
buttonGroup = new ButtonGroup();
- for (MatrixRenderer renderer : matrixRenderers) {
+ for (MatrixRenderer renderer : matrixRenderers.keySet()) {
JToggleButton radioButton = new JToggleButton(renderer.getIcon());
radioButton.addActionListener(this);
radioButton.setModel(new RendererButtonModel(renderer));
-
+
// auto select first matrix renderer
if (index == 1) {
radioButton.setSelected(true);
@@ -375,7 +313,7 @@
else {
// get all display component for each renderer
componentForRenderers.clear();
- for (MatrixRenderer matrixRenderer : matrixRenderers) {
+ for (MatrixRenderer matrixRenderer : matrixRenderers.keySet()) {
Component component = matrixRenderer.getComponent(matrix);
componentForRenderers.put(matrixRenderer, component);
}
@@ -436,7 +374,7 @@
int index = 0;
buttonGroup = new ButtonGroup();
- for (MatrixRenderer renderer : matrixRenderers) {
+ for (MatrixRenderer renderer : matrixRenderers.keySet()) {
JRadioButton radioButton = new JRadioButton(renderer.getName());
radioButton.addActionListener(this);
radioButton.setModel(new RendererButtonModel(renderer));
@@ -491,19 +429,10 @@
mainSplitPane.setDividerLocation(0.3);
add(mainSplitPane, BorderLayout.CENTER);
- // matrix list combo
- matrixComboBox = new MatrixComboBox();
- MatrixComboBoxModel matrixListComboBoxModel = new MatrixComboBoxModel();
- matrixComboBox.setModel(matrixListComboBoxModel);
- matrixComboBox.setRenderer(new MatrixComboRenderer());
- matrixComboBox.setVisible(matrixComboVisible);
- addPropertyChangeListener(PROPERTY_MATRIX_COMBO_VISIBLE, matrixComboBox);
- addPropertyChangeListener(PROPERTY_MATRICES, matrixListComboBoxModel);
- editionSidePanel.add(matrixComboBox, BorderLayout.NORTH);
-
// panel d'affichage des dimensions
dimensionPanel = new MatrixDimensionPanel();
editionSidePanel.add(dimensionPanel, BorderLayout.CENTER);
+ addPropertyChangeListener(PROPERTY_MATRIX, dimensionPanel);
// fleche de d'action de rendu
// render type : icon
@@ -528,7 +457,7 @@
/**
* Set rendering component in rendering container.
*/
- protected void updateSelectedRenderingComponent() {
+ public void updateSelectedRenderingComponent() {
renderingComponentContainer.removeAll();
MatrixRenderer matrixRenderer = null;
@@ -541,12 +470,23 @@
break;
}
- if (matrixRenderer != null) {
- Component component = componentForRenderers.get(matrixRenderer);
- if (component != null) {
- renderingComponentContainer.add(component, BorderLayout.CENTER);
+ if (!componentForRenderers.isEmpty()) {
+ if (matrixRenderer != null) {
+ Component component = componentForRenderers.get(matrixRenderer);
+ if (component != null) {
+ renderingComponentContainer.add(component, BorderLayout.CENTER);
+ }
}
}
+ else {
+ // if enables default rendering
+ if (matrixRenderers.get(matrixRenderer)) {
+ Component component = matrixRenderer.getComponent(null);
+ if (component != null) {
+ renderingComponentContainer.add(component, BorderLayout.CENTER);
+ }
+ }
+ }
renderingComponentContainer.validate();
renderingComponentContainer.repaint();
Added: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/SumAllAction.java
===================================================================
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/SumAllAction.java (rev 0)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/SumAllAction.java 2011-04-07 12:26:45 UTC (rev 346)
@@ -0,0 +1,85 @@
+/*
+ * #%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 javax.swing.Icon;
+
+import org.nuiton.util.Resource;
+
+/**
+ * Sum all raw action.
+ *
+ * Default matrix viewer panel action to sum all elements.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SumAllAction implements MatrixDimensionAction {
+
+ /*
+ * @see org.nuiton.math.matrix.viewer.MatrixGroupAction#getIcon()
+ */
+ @Override
+ public Icon getIcon() {
+ return Resource.getIcon("/icons/sigma-barre.gif");
+ }
+
+ /*
+ * @see org.nuiton.math.matrix.viewer.MatrixGroupAction#getSelectedIcon()
+ */
+ @Override
+ public Icon getSelectedIcon() {
+ return Resource.getIcon("/icons/sigma.gif");
+ }
+
+ /*
+ * @see org.nuiton.math.matrix.viewer.MatrixGroupAction#getDimensionIndex()
+ */
+ @Override
+ public int getDimensionIndex() {
+ return -1;
+ }
+
+ /*
+ * @see org.nuiton.math.matrix.viewer.MatrixGroupAction#getDimensionType()
+ */
+ @Override
+ public Class<?> getDimensionType() {
+ return null;
+ }
+
+ /*
+ * @see org.nuiton.math.matrix.viewer.MatrixGroupAction#getSumStep()
+ */
+ @Override
+ public int getSumStep() {
+ // sum all => -1
+ return -1;
+ }
+}
Property changes on: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/SumAllAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/package-info.java
===================================================================
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/package-info.java 2011-04-04 13:09:43 UTC (rev 345)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/package-info.java 2011-04-07 12:26:45 UTC (rev 346)
@@ -3,7 +3,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2010 CodeLutin, Chatellier Eric
+ * Copyright (C) 2004 - 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
Modified: trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/viewer/MatrixViewerPanelTest.java
===================================================================
--- trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/viewer/MatrixViewerPanelTest.java 2011-04-04 13:09:43 UTC (rev 345)
+++ trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/viewer/MatrixViewerPanelTest.java 2011-04-07 12:26:45 UTC (rev 346)
@@ -28,6 +28,7 @@
import java.util.ArrayList;
import java.util.List;
+import javax.swing.Icon;
import javax.swing.JFrame;
import org.junit.Test;
@@ -38,6 +39,7 @@
import org.nuiton.math.matrix.viewer.renderer.MatrixChartRenderer;
import org.nuiton.math.matrix.viewer.renderer.MatrixInfoTableRenderer;
import org.nuiton.math.matrix.viewer.renderer.MatrixPanelRenderer;
+import org.nuiton.util.Resource;
/**
* Test for matrix viewer panel.
@@ -51,14 +53,14 @@
public class MatrixViewerPanelTest {
protected MatrixND getTestMatrix(boolean proxy) {
- List<String> years = new ArrayList<String>();
- years.add("1999");
- years.add("2000");
- years.add("2001");
- years.add("2002");
- years.add("2003");
- years.add("2004");
- years.add("2005");
+ List<Integer> years = new ArrayList<Integer>();
+ years.add(1999);
+ years.add(2000);
+ years.add(2001);
+ years.add(2002);
+ years.add(2003);
+ years.add(2004);
+ years.add(2005);
List<String> cities = new ArrayList<String>();
cities.add("Nantes");
@@ -73,15 +75,15 @@
matrix = MatrixFactory.getInstance().createProxy("test matrix", new List<?>[]{years, cities}, new String[]{"Years", "Cities"}, new MatrixProvider() {
@Override
public void fillValues(MatrixND matrix) {
- MatrixHelper.fill(matrix, 10000.0);
- matrix.setValue(0, 0, 1000);
+ MatrixHelper.fill(matrix, Math.random()*10000);
+ matrix.setValue(0, 0, Math.random()*10000);
}
});
}
else {
matrix = MatrixFactory.getInstance().create("test matrix", new List<?>[]{years, cities}, new String[]{"Years", "Cities"});
- MatrixHelper.fill(matrix, 10000.0);
- matrix.setValue(0, 0, 1000);
+ MatrixHelper.fill(matrix, Math.random()*10000);
+ matrix.setValue(0, 0, Math.random()*10000);
}
return matrix;
}
@@ -95,7 +97,7 @@
MatrixViewerPanel panel = new MatrixViewerPanel();
MatrixND testMatrix = getTestMatrix(false);
- panel.addMatrix(testMatrix, testMatrix);
+ panel.setMatrix(testMatrix);
panel.addMatrixRenderer(new MatrixInfoTableRenderer());
panel.addMatrixRenderer(new MatrixChartRenderer());
panel.addMatrixRenderer(new MatrixPanelRenderer());
@@ -121,9 +123,53 @@
MatrixViewerPanel panel = new MatrixViewerPanel();
MatrixND testMatrix = getTestMatrix(true);
- panel.addMatrix(testMatrix, testMatrix);
panel.addMatrixRenderer(new MatrixInfoTableRenderer());
panel.addMatrixRenderer(new MatrixChartRenderer());
+ panel.addMatrixDimentionAction(new MatrixDimensionAction() {
+ @Override
+ public int getSumStep() {
+ return 2;
+ }
+ @Override
+ public Icon getSelectedIcon() {
+ return null;
+ }
+ @Override
+ public Icon getIcon() {
+ return Resource.getIcon("/icons/table.png");
+ }
+ @Override
+ public Class<?> getDimensionType() {
+ return null;
+ }
+ @Override
+ public int getDimensionIndex() {
+ return 1;
+ }
+ });
+ panel.addMatrixDimentionAction(new MatrixDimensionAction() {
+ @Override
+ public int getSumStep() {
+ return 3;
+ }
+ @Override
+ public Icon getSelectedIcon() {
+ return null;
+ }
+ @Override
+ public Icon getIcon() {
+ return Resource.getIcon("/icons/chart_curve.png");
+ }
+ @Override
+ public Class<?> getDimensionType() {
+ return Integer.class;
+ }
+ @Override
+ public int getDimensionIndex() {
+ return -1;
+ }
+ });
+ panel.setMatrix(testMatrix);
frame.add(panel);
frame.pack();
1
0
r345 - in trunk/src/site: . resources resources/images rst
by echatellier@users.nuiton.org 04 Apr '11
by echatellier@users.nuiton.org 04 Apr '11
04 Apr '11
Author: echatellier
Date: 2011-04-04 15:09:43 +0200 (Mon, 04 Apr 2011)
New Revision: 345
Url: http://nuiton.org/repositories/revision/nuiton-matrix/345
Log:
Add doc about matrix panel viewer.
Added:
trunk/src/site/resources/
trunk/src/site/resources/images/
trunk/src/site/resources/images/matrixpanelviewer.png
trunk/src/site/rst/gui-matrixpanelviewer.rst
Modified:
trunk/src/site/site_fr.xml
Added: trunk/src/site/resources/images/matrixpanelviewer.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/images/matrixpanelviewer.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/site/rst/gui-matrixpanelviewer.rst
===================================================================
--- trunk/src/site/rst/gui-matrixpanelviewer.rst (rev 0)
+++ trunk/src/site/rst/gui-matrixpanelviewer.rst 2011-04-04 13:09:43 UTC (rev 345)
@@ -0,0 +1,89 @@
+MatrixPanelViewer component
+===========================
+
+This component goals are :
+ - display a list of matrix to manipulate
+ - display dimension of selected matrix with semantic
+ - render selected matrix with selected dimensions
+
+.. image:: images/matrixpanelviewer.png
+
+
+Simple matrix viewing
+---------------------
+
+This component can be used to display only one matrix.
+
+Use following code ::
+
+ MatrixViewerPanel matrixViewerPanel = new MatrixViewerPanel();
+ matrixViewerPanel.setMatrix(myMatrix);
+
+Then ``MatrixViewerPanel`` is a simple swing component, you can place it
+wherever you want.
+
+
+Display a list of matrix
+------------------------
+
+You can display multiples matrix in a ``MatrixViewerPanel``. User will have
+to select it in a ``ComboBox``.
+
+For performance reason, instantiating multiples huge matrix at init time can't
+be done. The matrix list can only contains matrix name, and matrix data
+will be loaded with a provider when user select it.
+
+Code example::
+
+ MatrixViewerPanel matrixViewerPanel = new MatrixViewerPanel();
+ matrixViewerPanel.setComboBoxVisible(true);
+ matrixViewerPanel.addMatrix("myMatrix1");
+ matrixViewerPanel.addMatrix("myMatrix2");
+ matrixViewerPanel.setMatrixLabelProvider(new MyMatrixLabelProvider());
+
+
+Use various renderer
+--------------------
+
+MatrixPanelViewer can render matrix in various way, including your own (just
+implements ``MatrixRenderer`` interface) ::
+
+ MatrixViewerPanel matrixViewerPanel = new MatrixViewerPanel();
+ matrixViewerPanel.addMatrixRenderer(new MatrixChartRenderer());
+ matrixViewerPanel.addMatrixRenderer(new MatrixInfoTableRenderer());
+ matrixViewerPanel.addMatrixRenderer(new MyCustomMatrixRenderer());
+
+
+Use matrix filter
+-----------------
+
+You can also add a matrix filter to modify matrix just after dimension
+selection and before applying all renderers.
+
+For example, you can use a filter to remove non significant values
+from a matrix (0 at each bounds).
+
+To do so::
+
+ MatrixViewerPanel matrixViewerPanel = new MatrixViewerPanel();
+ matrixViewerPanel.addMatrixFilter(new MyCustomFilter());
+
+
+Use matrix proxy and data provider
+----------------------------------
+
+When matrix contains huge set of data, render then is not possible. Do solve
+this, you can use a matrix "empty" just filled with semantics for each
+dimension. At rendering phase, ``MatrixViewerPanel`` will call getSubMatrix()
+with selected semantics on proxy witch is implemented by a call to
+``MatrixProvider`` to get filled data.
+
+Example::
+
+ MatrixND matrix = MatrixFactory.getInstance().createProxy("myMatrixName,
+ new List<?>[] { semantic1 , semantic2, semantic3, semantic4},
+ new String[] {"semantic1", "semantic2", "semantic3", "semantic4"},
+ new MyMatrixProvider());
+ MatrixViewerPanel matrixViewerPanel = new MatrixViewerPanel();
+ matrixViewerPanel.setMatrix(matrix);
+
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2011-03-21 14:45:21 UTC (rev 344)
+++ trunk/src/site/site_fr.xml 2011-04-04 13:09:43 UTC (rev 345)
@@ -45,6 +45,7 @@
<menu name="Utilisateur">
<item href="index.html" name="Accueil"/>
+ <item href="gui-matrixpanelviewer.png" name="Matrix panel viewer"/>
</menu>
<menu name="Développeur">
1
0