From echatellier@users.nuiton.org Wed Apr 13 17:59:26 2011
From: echatellier@users.nuiton.org
To: nuiton-matrix-commits@list.nuiton.org
Subject: [Nuiton-matrix-commits] r353 - in trunk/nuiton-matrix-gui/src:
main/java/org/nuiton/math/matrix/gui
main/java/org/nuiton/math/matrix/viewer/renderer main/resources/i18n
test/java/org/nuiton/math/matrix/gui test/java/org/nuiton/math/matrix/viewer
Date: Wed, 13 Apr 2011 17:59:26 +0200
Message-ID: <20110413155926.9C3CB5A3A7@nuiton.codelutin.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============7178908402197989395=="
--===============7178908402197989395==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Author: echatellier
Date: 2011-04-13 17:59:26 +0200 (Wed, 13 Apr 2011)
New Revision: 353
Url: http://nuiton.org/repositories/revision/nuiton-matrix/353
Log:
Evolution #1150: Add new toolbar on matrix panel to perform some operation on=
matrix
Added:
trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixPan=
elEditorHandler.java
trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixTab=
leModelOption.java
trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/gui/MatrixPan=
elEditorTest.java
Removed:
trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/render=
er/MatrixInfoTableModel.java
trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/render=
er/MatrixInfoTableRenderer.java
Modified:
trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixPan=
elEditor.jaxx
trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixTab=
leModel.java
trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixTab=
leModelLinear.java
trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixTab=
leModelND.java
trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/render=
er/MatrixPanelRenderer.java
trunk/nuiton-matrix-gui/src/main/resources/i18n/nuiton-matrix-gui_en_GB.pr=
operties
trunk/nuiton-matrix-gui/src/main/resources/i18n/nuiton-matrix-gui_fr_FR.pr=
operties
trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/gui/MatrixPan=
elListenerTest.java
trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/viewer/Matrix=
ViewerPanelTest.java
Modified: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/Ma=
trixPanelEditor.jaxx
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixPa=
nelEditor.jaxx 2011-04-13 15:50:50 UTC (rev 352)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixPa=
nelEditor.jaxx 2011-04-13 15:59:26 UTC (rev 353)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2004 - 2010 CodeLutin
+ 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=20
@@ -24,8 +24,15 @@
-->
=20
-
+
+ org.nuiton.math.matrix.MatrixND
+
=20
+
+
+
+
+
=20
@@ -35,132 +42,68 @@
=20
-
+
+
+ |
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
-
+
-
+
Added: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/Matri=
xPanelEditorHandler.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixPa=
nelEditorHandler.java (rev 0)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixPa=
nelEditorHandler.java 2011-04-13 15:59:26 UTC (rev 353)
@@ -0,0 +1,156 @@
+/*
+ * #%L
+ *=20
+ *=20
+ * $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=20
+ * published by the Free Software Foundation, either version 3 of the=20
+ * License, or (at your option) any later version.
+ *=20
+ * 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.
+ *=20
+ * You should have received a copy of the GNU General Lesser Public=20
+ * License along with this program. If not, see
+ * .
+ * #L%
+ */
+
+package org.nuiton.math.matrix.gui;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.awt.Event;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.swing.JOptionPane;
+import javax.swing.JTable;
+import javax.swing.KeyStroke;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+
+import org.nuiton.math.matrix.MatrixFactory;
+import org.nuiton.math.matrix.MatrixND;
+
+/**
+ * Handler for matrix panel editor.
+ *=20
+ * @author chatellier
+ * @version $Revision$
+ *=20
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class MatrixPanelEditorHandler {
+
+ protected Collection matrixPanelListeners =3D new H=
ashSet();
+
+ protected MatrixPopupMenu popupMenu =3D null;
+
+ public void addMatrixPanelListener(MatrixPanelListener l) {
+ matrixPanelListeners.add(l);
+ }
+
+ public void removeMatrixPanelListener(MatrixPanelListener l) {
+ matrixPanelListeners.remove(l);
+ }
+
+ protected void fireEvent(MatrixPanelEditor matrixPanelEditor) {
+ MatrixPanelEvent event =3D new MatrixPanelEvent(matrixPanelEditor);
+ for (MatrixPanelListener matrixPanelListener : matrixPanelListeners)=
{
+ matrixPanelListener.matrixChanged(event);
+ }
+ }
+
+ /**
+ * Init panel with current panel matrix.
+ *=20
+ * @param matrixPanelEditor panel to init
+ */
+ protected void initEditor(final MatrixPanelEditor matrixPanelEditor) {
+ =20
+ MatrixND matrix =3D matrixPanelEditor.getMatrix();
+
+ JTable matrixTable =3D null;
+ if (matrix !=3D null) {
+ popupMenu =3D new MatrixPopupMenu(matrixPanelEditor);
+ matrixTable =3D new JTable() {
+ public void processMouseEvent(MouseEvent event) {
+ if (event.isPopupTrigger()) {
+ popupMenu.show(event.getComponent(), event.getX(), e=
vent.getY());
+ }
+ super.processMouseEvent(event);
+ }
+ };
+
+ matrixTable.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK=
_C, Event.CTRL_MASK), "copy");
+ matrixTable.getActionMap().put("copy", popupMenu.getSendToClipBo=
ardSelectionCopyAction());
+ matrixTable.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK=
_V, Event.CTRL_MASK), "paste");
+ matrixTable.getActionMap().put("paste", popupMenu.getSendToClipB=
oardCurrentPasteAction());
+ =20
+ MatrixTableModel matrixTableModel =3D null;
+ if (matrixPanelEditor.isLinearModel()) {
+ matrixTableModel =3D new MatrixTableModelLinear(matrix, matr=
ixPanelEditor.isLinearModelShowDefault());
+ }
+ else {
+ matrixTableModel =3D new MatrixTableModelND(matrix);
+ }
+
+ // unique gestion des options par modele interpos=C3=A9
+ if (matrixPanelEditor.isDisplayOptions()) {
+ matrixTableModel =3D new MatrixTableModelOption(matrixTableM=
odel,
+ matrixPanelEditor.getSumOptionCheckBox().isSelected(=
),
+ matrixPanelEditor.getMeanOptionCheckBox().isSelected=
(),
+ matrixPanelEditor.getTransposeOptionCheckBox().isSel=
ected());
+ =20
+ }
+
+ matrixTableModel.addTableModelListener(new TableModelListener() {
+ @Override
+ public void tableChanged(TableModelEvent e) {
+ matrixPanelEditor.fireEvent();
+ }
+ });
+
+ matrixTable.setModel(matrixTableModel);
+ matrixTable.setDefaultRenderer(String.class, matrixTableModel.ge=
tMatrixCellRenderer());
+ matrixTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
+ matrixTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_=
SELECTION);
+ matrixPanelEditor.table =3D matrixTable;
+ }
+ matrixPanelEditor.getEditArea().setViewportView(matrixTable);
+ matrixPanelEditor.repaint();
+ }
+
+ /**
+ * Modify matrix dimensions
+ *=20
+ * @param matrixPanelEditor matrix panel editor
+ */
+ public void modifyMatrixDimension(MatrixPanelEditor matrixPanelEditor) {
+ String dim =3D JOptionPane.showInputDialog(matrixPanelEditor,
+ _("nuitonmatrix.create.matrix.message"),
+ _("nuitonmatrix.create.matrix.title"));
+
+ if (dim !=3D null && dim.indexOf(';') !=3D -1) {
+ String[] sdim =3D dim.split(";");
+ int[] idim =3D new int[sdim.length];
+ for (int i =3D 0; i < idim.length; i++) {
+ idim[i] =3D Integer.parseInt(sdim[i]);
+ }
+ MatrixND newMatrix =3D MatrixFactory.getInstance().create(idim);
+ matrixPanelEditor.setMatrix(newMatrix);
+ }
+ }
+}
Property changes on: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/ma=
trix/gui/MatrixPanelEditorHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/Ma=
trixTableModel.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixTa=
bleModel.java 2011-04-13 15:50:50 UTC (rev 352)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixTa=
bleModel.java 2011-04-13 15:59:26 UTC (rev 353)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2010 CodeLutin
+ * 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=20
@@ -25,13 +25,14 @@
=20
package org.nuiton.math.matrix.gui;
=20
+import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
=20
import org.nuiton.math.matrix.MatrixND;
=20
/**
- * MatrixTableModel.
+ * {@link TableModel} that can display matrix in a {@link JTable}.
*
* Created: 22 mars 2006 12:53:22
*
@@ -40,15 +41,26 @@
*
* Last update: $Date$
* by : $Author$
- *
- * TODO Javadoc ?
*/
public interface MatrixTableModel extends TableModel {
=20
void setMatrix(MatrixND m);
+ =20
+ MatrixND getMatrix();
=20
- void setEnabled(boolean enabled);
-
TableCellRenderer getMatrixCellRenderer();
=20
+ /**
+ * Get how many additional rows table model need to renderer matrix.
+ *=20
+ * @return additional rows
+ */
+ int getAdditionalRows();
+ =20
+ /**
+ * Get how many additional columns table model need to renderer matrix.
+ *=20
+ * @return additional columns
+ */
+ int getAdditionalColumns();
}
Modified: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/Ma=
trixTableModelLinear.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixTa=
bleModelLinear.java 2011-04-13 15:50:50 UTC (rev 352)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixTa=
bleModelLinear.java 2011-04-13 15:59:26 UTC (rev 353)
@@ -66,7 +66,6 @@
/** Logger for this class. */
private static Log log =3D LogFactory.getLog(MatrixTableModelLinear.clas=
s);
=20
- protected boolean enabled =3D true;
protected MatrixND m =3D null;
protected boolean showDefault =3D false;
protected double defaultValue =3D 0;
@@ -78,7 +77,15 @@
setMatrix(m);
}
=20
+ /*
+ * @see org.nuiton.math.matrix.gui.MatrixTableModel#getMatrix()
+ */
@Override
+ public MatrixND getMatrix() {
+ return m;
+ }
+
+ @Override
public void setMatrix(MatrixND m) {
this.m =3D m;
computeMapping();
@@ -97,21 +104,6 @@
}
=20
/**
- * @return Returns the enabled.
- */
- public boolean isEnabled() {
- return this.enabled;
- }
-
- /**
- * @param enabled The enabled to set.
- */
- @Override
- public void setEnabled(boolean enabled) {
- this.enabled =3D enabled;
- }
-
- /**
* @return Returns the showDefault.
*/
public boolean isShowDefault() {
@@ -178,7 +170,7 @@
*/
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
- return isEnabled() && columnIndex =3D=3D m.getDimCount();
+ return columnIndex =3D=3D m.getDimCount();
}
=20
/*
@@ -282,4 +274,19 @@
}
}
=20
+ /*
+ * @see org.nuiton.math.matrix.gui.MatrixTableModel#getAdditionalRows()
+ */
+ @Override
+ public int getAdditionalRows() {
+ return 0;
+ }
+
+ /*
+ * @see org.nuiton.math.matrix.gui.MatrixTableModel#getAdditionalColumns=
()
+ */
+ @Override
+ public int getAdditionalColumns() {
+ return m.getDimCount();
+ }
}
Modified: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/Ma=
trixTableModelND.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixTa=
bleModelND.java 2011-04-13 15:50:50 UTC (rev 352)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixTa=
bleModelND.java 2011-04-13 15:59:26 UTC (rev 353)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2010 CodeLutin
+ * 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=20
@@ -72,9 +72,6 @@
=20
protected int[] multRowCol =3D null;
=20
- /** par defaut, la matrice est editable. */
- protected boolean enabled =3D true;
-
protected TableCellRenderer renderer =3D null;
=20
/**
@@ -106,7 +103,15 @@
setMatrix(m);
}
=20
+ /*
+ * @see org.nuiton.math.matrix.gui.MatrixTableModel#getMatrix()
+ */
@Override
+ public MatrixND getMatrix() {
+ return m;
+ }
+
+ @Override
public void setMatrix(MatrixND m) {
this.m =3D m;
addRow =3D m.getDimCount() / 2;
@@ -303,15 +308,10 @@
} else if (m.getDimCount() =3D=3D 1 && row < 1) {
return false;
}
- return enabled;
+ return true;
}
=20
@Override
- public void setEnabled(boolean enabled) {
- this.enabled =3D enabled;
- }
-
- @Override
public Class> getColumnClass(int column) {
return String.class;
}
@@ -376,4 +376,20 @@
}
}
=20
+ /*
+ * @see org.nuiton.math.matrix.gui.MatrixTableModel#getAdditionalRows()
+ */
+ @Override
+ public int getAdditionalRows() {
+ return addRow;
+ }
+
+ /*
+ * @see org.nuiton.math.matrix.gui.MatrixTableModel#getAdditionalColumns=
()
+ */
+ @Override
+ public int getAdditionalColumns() {
+ return addCol;
+ }
+
}
Added: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/Matri=
xTableModelOption.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixTa=
bleModelOption.java (rev 0)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/gui/MatrixTa=
bleModelOption.java 2011-04-13 15:59:26 UTC (rev 353)
@@ -0,0 +1,414 @@
+/*
+ * #%L
+ * NuitonMatrix
+ *=20
+ * $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=20
+ * published by the Free Software Foundation, either version 3 of the=20
+ * License, or (at your option) any later version.
+ *=20
+ * 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.
+ *=20
+ * You should have received a copy of the GNU General Lesser Public=20
+ * License along with this program. If not, see
+ * .
+ * #L%
+ */
+
+package org.nuiton.math.matrix.gui;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.event.TableModelListener;
+import javax.swing.table.TableCellRenderer;
+
+import org.nuiton.math.matrix.MatrixND;
+
+/**
+ * Model that take a delegate model to add additional lines during
+ * rendering (such as row sum, column sum, row mean, column mean...)
+ *=20
+ * Created: 21 mars 2006 19:01:27
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class MatrixTableModelOption implements MatrixTableModel {
+
+ protected MatrixTableModel delegate;
+
+ protected boolean sumOption;
+
+ protected boolean meanOption;
+
+ protected boolean transposeOption;
+
+ public MatrixTableModelOption(MatrixTableModel delegate) {
+ this(delegate, false, false, false);
+ }
+
+ public MatrixTableModelOption(MatrixTableModel delegate, boolean sumOpti=
on,
+ boolean meanOption, boolean transposeOption) {
+ this.delegate =3D delegate;
+ this.sumOption =3D sumOption;
+ this.meanOption =3D meanOption;
+ this.transposeOption =3D transposeOption;
+ }
+ =20
+ public boolean isSumOption() {
+ return sumOption;
+ }
+
+ public void setSumOption(boolean sumOption) {
+ this.sumOption =3D sumOption;
+ }
+
+ public boolean isMeanOption() {
+ return meanOption;
+ }
+
+ public void setMeanOption(boolean meanOption) {
+ this.meanOption =3D meanOption;
+ }
+
+ public boolean isTransposeOption() {
+ return transposeOption;
+ }
+
+ public void setTransposeOption(boolean transposeOption) {
+ this.transposeOption =3D transposeOption;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getRowCount()
+ */
+ @Override
+ public int getRowCount() {
+ int result =3D -1;
+ if (transposeOption) {
+ result =3D delegate.getColumnCount();
+ }
+ else {
+ result =3D delegate.getRowCount();
+ }
+ if (sumOption) {
+ result++;
+ }
+ if (meanOption) {
+ result++;
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnCount()
+ */
+ @Override
+ public int getColumnCount() {
+ int result =3D -1;
+ if (transposeOption) {
+ result =3D delegate.getRowCount();
+ }
+ else {
+ result =3D delegate.getColumnCount();
+ }
+ if (sumOption) {
+ result++;
+ }
+ if (meanOption) {
+ result++;
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnName(int)
+ */
+ @Override
+ public String getColumnName(int columnIndex) {
+ String result =3D null;
+ if (sumOption && columnIndex =3D=3D delegate.getColumnCount() + 0) {
+ result =3D null; //_("matrix.gui.model.sum");
+ }
+ else if (meanOption && columnIndex =3D=3D delegate.getColumnCount() =
+ 1) {
+ result =3D null; //_("matrix.gui.model.mean");
+ }
+ else {
+ result =3D delegate.getColumnName(columnIndex);
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnClass(int)
+ */
+ @Override
+ public Class> getColumnClass(int columnIndex) {
+ return delegate.getColumnClass(columnIndex);
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#isCellEditable(int, int)
+ */
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return delegate.isCellEditable(rowIndex, columnIndex);
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getValueAt(int, int)
+ */
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ int rowCount =3D delegate.getRowCount();
+ int columnCount =3D delegate.getColumnCount();
+
+ Object result =3D null;
+ if (transposeOption) {
+ result =3D getValueAtTranposable(columnIndex, rowIndex, rowCount=
, columnCount);
+ }
+ else {
+ result =3D getValueAtTranposable(rowIndex, columnIndex, rowCount=
, columnCount);
+ }
+ return result;
+ }
+
+ /**
+ * Get value qui fonctionne aussi en transpos=C3=A9e.
+ *=20
+ * Le principe est que des que les bornes sur modele deleg=C3=A9 sont d=
=C3=A9pass=C3=A9es
+ * on r=C3=A9alise des op=C3=A9ration (mean/sum).
+ *=20
+ * Actuellement le code n'est vraiment pas evident.
+ *=20
+ * @param rowIndex rowIndex
+ * @param columnIndex columnIndex
+ * @param rowCount rowCount
+ * @param columnCount columnCount
+ * @return object at rowIndex/columnCount
+ */
+ protected Object getValueAtTranposable(int rowIndex, int columnIndex, in=
t rowCount, int columnCount) {
+ Object result =3D null;
+ // operation sur la derniere ligne
+ if (rowIndex >=3D rowCount) {=20
+ // une seule operation
+ if (columnIndex =3D=3D 0) {
+ if (rowIndex =3D=3D rowCount + 1) {
+ result =3D _("matrix.gui.model.mean");
+ }
+ else {
+ if (sumOption) {
+ result =3D _("matrix.gui.model.sum");
+ }
+ else {
+ result =3D _("matrix.gui.model.mean");
+ }
+ }
+ }
+ // deux operation (forcement mean) (cas somme des sommes)
+ else if (columnIndex =3D=3D columnCount + 1) {
+ if (rowIndex =3D=3D rowCount + 1) { // pas de sens
+ result =3D delegate.getMatrix().meanAll();
+ }
+ }
+ // une seule operation (cas somme des sommes)
+ else if (columnIndex =3D=3D columnCount) {
+ if (rowIndex =3D=3D rowCount) { // pas de sens
+ if (sumOption) {
+ result =3D delegate.getMatrix().sumAll();
+ }
+ else {
+ result =3D delegate.getMatrix().sumAll();
+ }
+ }
+ }
+ // deux operation (forcement mean)
+ else if (rowIndex =3D=3D rowCount + 1) {
+ result =3D getComputedValueForColumn(columnIndex, true); // =
mean
+ }
+ // une seule operation
+ else {
+ if (sumOption) {
+ result =3D getComputedValueForColumn(columnIndex, false)=
; // sum
+ }
+ else {
+ // sum
+ result =3D getComputedValueForColumn(columnIndex, true);=
// mean
+ }
+ }
+ }
+
+ // operation sur la derniere colonne
+ else if (columnIndex >=3D columnCount) {
+ // une seule operation
+ if (rowIndex =3D=3D 0) {
+ if (columnIndex =3D=3D columnCount + 1) {
+ result =3D _("matrix.gui.model.mean");
+ }
+ else {
+ if (sumOption) {
+ result =3D _("matrix.gui.model.sum");
+ }
+ else {
+ result =3D _("matrix.gui.model.mean");
+ }
+ }
+ }
+ // cas sommes de somme deja g=C3=A9r=C3=A9e
+ // par le premier if mais il faut quand meme les conditions
+ // pour qu'il ne passe pas dans le else final
+ else if (rowIndex =3D=3D rowCount + 1) {}
+ else if (rowIndex =3D=3D rowCount) {}
+ // deux operation (forcement mean)
+ else if (columnIndex =3D=3D columnCount + 1) {
+ result =3D getComputedValueForRow(rowIndex, true); // mean
+ }
+ // une seule operation
+ else {
+ if (sumOption) {
+ result =3D getComputedValueForRow(rowIndex, false); // s=
um
+ }
+ else {
+ // sum
+ result =3D getComputedValueForRow(rowIndex, true); // me=
an
+ }
+ }
+ }
+
+ else {
+ // reste du tableau
+ result =3D delegate.getValueAt(rowIndex, columnIndex);
+ }
+ return result;
+ }
+
+ /**
+ * Compute sum for delegate model row index.
+ *=20
+ * @param delegateRowIndex delegate model row index
+ * @return sum for row
+ */
+ protected Double getComputedValueForRow(int delegateRowIndex, boolean me=
an) {
+ double sum =3D 0.0;
+ double count =3D 0;
+ for (int col =3D delegate.getAdditionalColumns() ; col < delegate.ge=
tColumnCount() ; col++) {
+ sum +=3D (Double)delegate.getValueAt(delegateRowIndex, col);
+ count++;
+ }
+ double result =3D sum;
+ if (mean) {
+ result =3D sum / count;
+ }
+ return result;
+ }
+ =20
+ /**
+ * Compute sum for delegate model column index.
+ *=20
+ * @param delegateColumnIndex delegate model column index
+ * @return sum for column
+ */
+ protected Double getComputedValueForColumn(int delegateColumnIndex, bool=
ean mean) {
+ double sum =3D 0.0;
+ double count =3D 0;
+ for (int row =3D delegate.getAdditionalRows() ; row < delegate.getRo=
wCount() ; row++) {
+ sum +=3D (Double)delegate.getValueAt(row, delegateColumnIndex);
+ count++;
+ }
+ double result =3D sum;
+ if (mean) {
+ result =3D sum / count;
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, i=
nt)
+ */
+ @Override
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+ if (transposeOption) {
+ delegate.setValueAt(aValue, rowIndex, columnIndex);
+ } else {
+ delegate.setValueAt(aValue, columnIndex, rowIndex);
+ }
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#addTableModelListener(javax.swing.e=
vent.TableModelListener)
+ */
+ @Override
+ public void addTableModelListener(TableModelListener l) {
+ delegate.addTableModelListener(l);
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#removeTableModelListener(javax.swin=
g.event.TableModelListener)
+ */
+ @Override
+ public void removeTableModelListener(TableModelListener l) {
+ delegate.removeTableModelListener(l);
+ }
+
+ /*
+ * @see org.nuiton.math.matrix.gui.MatrixTableModel#setMatrix(org.nuiton=
.math.matrix.MatrixND)
+ */
+ @Override
+ public void setMatrix(MatrixND m) {
+ delegate.setMatrix(m);
+ }
+
+ @Override
+ public MatrixND getMatrix() {
+ return delegate.getMatrix();
+ }
+
+ /*
+ * @see org.nuiton.math.matrix.gui.MatrixTableModel#getMatrixCellRendere=
r()
+ */
+ @Override
+ public TableCellRenderer getMatrixCellRenderer() {
+ return delegate.getMatrixCellRenderer();
+ }
+
+ /*
+ * @see org.nuiton.math.matrix.gui.MatrixTableModel#getAdditionalRows()
+ */
+ @Override
+ public int getAdditionalRows() {
+ int result =3D 0;
+ if (sumOption) {
+ result++;
+ }
+ if (meanOption) {
+ result++;
+ }
+ return result;
+ }
+
+ /*
+ * @see org.nuiton.math.matrix.gui.MatrixTableModel#getAdditionalColumns=
()
+ */
+ @Override
+ public int getAdditionalColumns() {
+ int result =3D 0;
+ if (sumOption) {
+ result++;
+ }
+ if (meanOption) {
+ result++;
+ }
+ return result;
+ }
+}
Property changes on: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/ma=
trix/gui/MatrixTableModelOption.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/=
renderer/MatrixInfoTableModel.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/rende=
rer/MatrixInfoTableModel.java 2011-04-13 15:50:50 UTC (rev 352)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/rende=
rer/MatrixInfoTableModel.java 2011-04-13 15:59:26 UTC (rev 353)
@@ -1,104 +0,0 @@
-/*
- * #%L
- *=20
- *=20
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2002 - 2010 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=20
- * published by the Free Software Foundation, either version 3 of the=20
- * License, or (at your option) any later version.
- *=20
- * 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.
- *=20
- * You should have received a copy of the GNU General Lesser Public=20
- * License along with this program. If not, see
- * .
- * #L%
- */
-package org.nuiton.math.matrix.viewer.renderer;
-
-import org.nuiton.math.matrix.MatrixND;
-import org.nuiton.math.matrix.MatrixException;
-import javax.swing.table.AbstractTableModel;
-
-/**
- * Matrix info table model.
- *=20
- * @author chatellier
- * @version $Revision$
- *=20
- * Last update : $Date$
- * By : $Author$
- */
-public class MatrixInfoTableModel extends AbstractTableModel {
-
- /** serialVersionUID. */
- private static final long serialVersionUID =3D 2632133167225155487L;
-
- protected MatrixND matrix;
-
- public MatrixInfoTableModel(MatrixND mat) {
- if (mat.getDimCount() > 2) {
- throw new MatrixException(
- "matrice with more than 2 dimension not supported.");
- }
- this.matrix =3D mat;
- }
-
- /**
- * @return Le nombre de lignes de la table.
- */
- public int getRowCount() {
- if (matrix =3D=3D null || matrix.getDimCount() < 1) {
- return 0;
- } else {
- return matrix.getDim(0);
- }
- }
-
- /**
- * @return Le nombre de colonnes de la table.
- */
- public int getColumnCount() {
- if (matrix =3D=3D null || matrix.getDimCount() < 1) {
- return 0;
- } else {
- return matrix.getDim(1) + 1;
- }
- }
-
- /**
- * @param row La ligne
- * @param column La colonnes
- * @return L'Object correspondant dans la matrice.
- */
- public Object getValueAt(int row, int column) {
- if (column =3D=3D 0) {
- Object obj =3D matrix.getSemantic(0).get(row);
- return obj;
- } else {
- if (matrix.getDimCount() =3D=3D 1) {
- return String.valueOf(matrix.getValue(column - 1));
- } else {
- return String.valueOf(matrix.getValue(row, column - 1));
- }
- }
- }
-
- public String getColumnName(int column) {
- if (column =3D=3D 0) {
- return matrix.getDimensionName(0) + "\\"
- + matrix.getDimensionName(1);
- } else {
- return "" + matrix.getSemantic(1).get(column - 1);
- }
- }
-
-}// MatrixInfoTableModel
Deleted: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/=
renderer/MatrixInfoTableRenderer.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/rende=
rer/MatrixInfoTableRenderer.java 2011-04-13 15:50:50 UTC (rev 352)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/rende=
rer/MatrixInfoTableRenderer.java 2011-04-13 15:59:26 UTC (rev 353)
@@ -1,142 +0,0 @@
-/*
- * #%L
- *=20
- *=20
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 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=20
- * published by the Free Software Foundation, either version 3 of the=20
- * License, or (at your option) any later version.
- *=20
- * 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.
- *=20
- * You should have received a copy of the GNU General Lesser Public=20
- * License along with this program. If not, see
- * .
- * #L%
- */
-
-package org.nuiton.math.matrix.viewer.renderer;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import javax.swing.Icon;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixND;
-import org.nuiton.math.matrix.viewer.MatrixRenderer;
-import org.nuiton.util.FileUtil;
-import org.nuiton.util.Resource;
-
-/**
- * Matrix info table renderer.
- *=20
- * @author chatellier
- * @version $Revision$
- *=20
- * Last update : $Date$
- * By : $Author$
- */
-public class MatrixInfoTableRenderer implements MatrixRenderer, ActionListen=
er {
-
- /** Class logger. */
- private static Log log =3D LogFactory.getLog(MatrixInfoTableRenderer.cla=
ss);
-
- protected MatrixND matrix;
-
- /*
- * @see org.nuiton.math.matrix.viewer.MatrixRenderer#getPanel(org.nuiton=
.math.matrix.MatrixND)
- */
- @Override
- public Component getComponent(MatrixND matrix) {
- this.matrix =3D matrix;
-
- JPanel panel =3D new JPanel(new BorderLayout());
-
- // label matrix name
- JLabel nameLabel =3D new JLabel(_(matrix.getName()));
- nameLabel.setHorizontalAlignment(JLabel.CENTER);
- panel.add(nameLabel, BorderLayout.NORTH);
-
- // data table
- JTable table =3D new JTable();
- table.setModel(new MatrixInfoTableModel(matrix));
- panel.add(new JScrollPane(table), BorderLayout.CENTER);
-
- // export button
- JButton exportButton =3D new JButton(_("nuitonmatrix.viewer.renderer=
.exportascsv"));
- exportButton.addActionListener(this);
- exportButton.setActionCommand("exportascsv");
- exportButton.setEnabled(this.matrix !=3D null);
- panel.add(exportButton, BorderLayout.SOUTH);
- return panel;
- }
-
- /*
- * @see org.nuiton.math.matrix.viewer.MatrixRenderer#getIcon()
- */
- @Override
- public Icon getIcon() {
- return Resource.getIcon("/icons/table.png");
- }
-
- /*
- * @see org.nuiton.math.matrix.viewer.MatrixRenderer#getName()
- */
- @Override
- public String getName() {
- return _("nuitonmatrix.viewer.renderer.data");
- }
-
- /*
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.Act=
ionEvent)
- */
- @Override
- public void actionPerformed(ActionEvent e) {
-
- if ("exportascsv".equals(e.getActionCommand())) {
- FileWriter writer =3D null;
- try {
- File file =3D FileUtil.getFile(".+\\.csv", "CSV file");
- if (file !=3D null) {
-
- // add csv extension
- if (!file.getName().endsWith(".csv")) {
- file =3D new File(file.getAbsolutePath() + ".csv");
- }
-
- writer =3D new FileWriter(file);
- matrix.exportCSV(writer, true);
- }
- } catch (IOException eee) {
- log.error(":104:Error during export" + eee);
- }
- finally {
- IOUtils.closeQuietly(writer);
- }
- }
- }
-
-}
Modified: trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer=
/renderer/MatrixPanelRenderer.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/rende=
rer/MatrixPanelRenderer.java 2011-04-13 15:50:50 UTC (rev 352)
+++ trunk/nuiton-matrix-gui/src/main/java/org/nuiton/math/matrix/viewer/rende=
rer/MatrixPanelRenderer.java 2011-04-13 15:59:26 UTC (rev 353)
@@ -27,13 +27,25 @@
=20
import static org.nuiton.i18n.I18n._;
=20
+import java.awt.BorderLayout;
import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
=20
import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JPanel;
=20
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixPanelEditor;
import org.nuiton.math.matrix.viewer.MatrixRenderer;
+import org.nuiton.util.FileUtil;
import org.nuiton.util.Resource;
=20
/**
@@ -45,16 +57,57 @@
* Last update : $Date$
* By : $Author$
*/
-public class MatrixPanelRenderer implements MatrixRenderer {
+public class MatrixPanelRenderer implements ActionListener, MatrixRenderer {
=20
+ /** Class logger. */
+ private static Log log =3D LogFactory.getLog(MatrixPanelRenderer.class);
+
+ /** Renderer main component. */
+ protected JPanel panel;
+
+ /** Matrix editor. */
+ protected MatrixPanelEditor editor;
+
+ /** Export button. */
+ protected JButton exportButton;
+
+ /** Current matrix. */
+ protected MatrixND matrix;
+
+ public MatrixPanelRenderer() {
+ =20
+ panel =3D new JPanel(new BorderLayout());
+ =20
+ // main component
+ editor =3D new MatrixPanelEditor();
+ panel.add(editor, BorderLayout.CENTER);
+ =20
+ // export button
+ exportButton =3D new JButton(_("nuitonmatrix.viewer.renderer.exporta=
scsv"));
+ exportButton.addActionListener(this);
+ exportButton.setActionCommand("exportascsv");
+ exportButton.setEnabled(false);
+ panel.add(exportButton, BorderLayout.SOUTH);
+ }
+
+ /**
+ * Get editor instance to allow configuration.
+ *=20
+ * @return internal editor reference
+ */
+ public MatrixPanelEditor getEditor() {
+ return editor;
+ }
+
/*
* @see org.nuiton.math.matrix.viewer.MatrixRenderer#getPanel(org.nuiton=
.math.matrix.MatrixND)
*/
@Override
public Component getComponent(MatrixND matrix) {
+ this.matrix =3D matrix;
+ editor.setMatrix(matrix);
+ exportButton.setEnabled(matrix !=3D null);
=20
- MatrixPanelEditor panel =3D new MatrixPanelEditor();
- panel.setMatrix(matrix);
return panel;
}
=20
@@ -73,6 +126,36 @@
public String getName() {
return _("nuitonmatrix.viewer.renderer.panel");
}
+ =20
+ /*
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.Act=
ionEvent)
+ */
+ @Override
+ public void actionPerformed(ActionEvent e) {
=20
- =20
+ if ("exportascsv".equals(e.getActionCommand())) {
+ FileWriter writer =3D null;
+ try {
+ File file =3D FileUtil.getFile(".+\\.csv", "CSV file");
+ if (file !=3D null) {
+
+ // add csv extension
+ if (!file.getName().endsWith(".csv")) {
+ file =3D new File(file.getAbsolutePath() + ".csv");
+ }
+
+ writer =3D new FileWriter(file);
+ matrix.exportCSV(writer, true);
+ }
+ } catch (IOException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during export", eee);
+ }
+ }
+ finally {
+ IOUtils.closeQuietly(writer);
+ }
+ }
+ }
+
}
Modified: trunk/nuiton-matrix-gui/src/main/resources/i18n/nuiton-matrix-gui_e=
n_GB.properties
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/main/resources/i18n/nuiton-matrix-gui_en_GB.p=
roperties 2011-04-13 15:50:50 UTC (rev 352)
+++ trunk/nuiton-matrix-gui/src/main/resources/i18n/nuiton-matrix-gui_en_GB.p=
roperties 2011-04-13 15:59:26 UTC (rev 353)
@@ -1,3 +1,5 @@
+matrix.gui.model.mean=3DMean
+matrix.gui.model.sum=3DSum
nuitonmatrix.create.matrix.button=3DNew matrix
nuitonmatrix.create.matrix.message=3DMatrix size (separate by ';')
nuitonmatrix.create.matrix.title=3DNew matrix
@@ -6,6 +8,9 @@
nuitonmatrix.error.clipboard.write=3DCannot write clipboard
nuitonmatrix.error.file.read=3DCannot read file
nuitonmatrix.error.file.write=3DCannot write file
+nuitonmatrix.gui.meanOption=3DMean
+nuitonmatrix.gui.sumOption=3DSum
+nuitonmatrix.gui.transposeOption=3DTranspose
nuitonmatrix.menu.action=3DCopy/Paste
nuitonmatrix.menu.action.copy=3DCopy
nuitonmatrix.menu.action.copy.selection=3DCopy selection
@@ -28,7 +33,6 @@
nuitonmatrix.viewer.graphcomborender.surface.stacked=3DStacked area rendering
nuitonmatrix.viewer.matrix.more.2d=3DMatrix dimensions count over 2 \!\nChoo=
se less elements or apply sum operator.
nuitonmatrix.viewer.renderer.chart=3DChart
-nuitonmatrix.viewer.renderer.data=3DData
nuitonmatrix.viewer.renderer.exportascsv=3DExport as CSV
nuitonmatrix.viewer.renderer.panel=3DMatrix
nuitonmatrix.viewer.sum=3DSum
Modified: trunk/nuiton-matrix-gui/src/main/resources/i18n/nuiton-matrix-gui_f=
r_FR.properties
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/main/resources/i18n/nuiton-matrix-gui_fr_FR.p=
roperties 2011-04-13 15:50:50 UTC (rev 352)
+++ trunk/nuiton-matrix-gui/src/main/resources/i18n/nuiton-matrix-gui_fr_FR.p=
roperties 2011-04-13 15:59:26 UTC (rev 353)
@@ -1,3 +1,5 @@
+matrix.gui.model.mean=3DMoyenne
+matrix.gui.model.sum=3DSomme
nuitonmatrix.create.matrix.button=3DCr\u00E9er une matrice
nuitonmatrix.create.matrix.message=3DDimensions de la matrice (s\u00E9par\u0=
0E9es par ';')
nuitonmatrix.create.matrix.title=3DCr\u00E9er une matrice
@@ -6,6 +8,9 @@
nuitonmatrix.error.clipboard.write=3DImpossible d'\u00E9crire dans le bloc n=
ote
nuitonmatrix.error.file.read=3DImpossible de lire le fichier
nuitonmatrix.error.file.write=3DImpossible d'\u00E9crire dans le fichier
+nuitonmatrix.gui.meanOption=3DMoyenne
+nuitonmatrix.gui.sumOption=3DSomme
+nuitonmatrix.gui.transposeOption=3DTranspos\u00E9e
nuitonmatrix.menu.action=3DCopier/Coller
nuitonmatrix.menu.action.copy=3DCopier
nuitonmatrix.menu.action.copy.selection=3DCopier la s\u00E9lection
@@ -28,7 +33,6 @@
nuitonmatrix.viewer.graphcomborender.surface.stacked=3DRendu en aires empil\=
u00E9es
nuitonmatrix.viewer.matrix.more.2d=3DMatrice de plus de 2 dimensions \!\nS\u=
00E9lectionnez moins d'\u00E9l\u00E9ments ou utilisez l'op\u00E9rateur somme.
nuitonmatrix.viewer.renderer.chart=3DGraphique
-nuitonmatrix.viewer.renderer.data=3DDonn\u00E9es
nuitonmatrix.viewer.renderer.exportascsv=3DExporter en CSV
nuitonmatrix.viewer.renderer.panel=3DMatrice
nuitonmatrix.viewer.sum=3DSomme
Added: trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/gui/Matri=
xPanelEditorTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/gui/MatrixPa=
nelEditorTest.java (rev 0)
+++ trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/gui/MatrixPa=
nelEditorTest.java 2011-04-13 15:59:26 UTC (rev 353)
@@ -0,0 +1,147 @@
+/*
+ * #%L
+ *=20
+ *=20
+ * $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=20
+ * published by the Free Software Foundation, either version 3 of the=20
+ * License, or (at your option) any later version.
+ *=20
+ * 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.
+ *=20
+ * You should have received a copy of the GNU General Lesser Public=20
+ * License along with this program. If not, see
+ * .
+ * #L%
+ */
+
+package org.nuiton.math.matrix.gui;
+
+import java.awt.Component;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JFrame;
+
+import org.junit.Test;
+import org.nuiton.math.matrix.MatrixFactory;
+import org.nuiton.math.matrix.MatrixHelper;
+import org.nuiton.math.matrix.MatrixND;
+
+/**
+ * Test to diplay matrix in MatrixPanelEditor using differents model.
+ *=20
+ * @author chatellier
+ * @version $Revision$
+ *=20
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class MatrixPanelEditorTest {
+
+ protected MatrixND getMatrixTest(int dimCount) {
+ List>[] dims =3D new List>[dimCount];
+
+ List years =3D new ArrayList();
+ years.add(1999);
+ years.add(2000);
+ years.add(2001);
+ years.add(2002);
+ years.add(2003);
+ years.add(2004);
+ years.add(2005);
+ dims[0] =3D years;
+ =20
+ if (dimCount >=3D 2) {
+ List cities =3D new ArrayList();
+ cities.add("Nantes");
+ cities.add("Paris");
+ cities.add("Lyon");
+ cities.add("Lille");
+ cities.add("Toulouse");
+ cities.add("Marseille");
+ dims[1] =3D cities;
+ }
+ =20
+ if (dimCount >=3D 3) {
+ List sectors =3D new ArrayList();
+ sectors.add("Informatique");
+ sectors.add("Administration");
+ sectors.add("Livraison");
+ sectors.add("Achat");
+ dims[2] =3D sectors;
+ }
+ =20
+ if (dimCount >=3D 4) {
+ List persons =3D new ArrayList();
+ persons.add("Bob");
+ persons.add("Joe");
+ persons.add("Louis");
+ persons.add("Jean");
+ dims[3] =3D persons;
+ }
+ =20
+ MatrixND matrix =3D MatrixFactory.getInstance().create(dims);
+ matrix.setName("test matrix");
+ MatrixHelper.fill(matrix, Math.random()*10000);
+
+ return matrix;
+ }
+
+ protected void show(Component comp) {
+ JFrame frame =3D new JFrame();
+ frame.add(comp);
+ frame.pack();
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+
+ try {
+ Thread.sleep(60000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testModelNDDim3() {
+ MatrixND matrix =3D getMatrixTest(3);
+ MatrixPanelEditor editor =3D new MatrixPanelEditor();
+ editor.setMatrix(matrix);
+ show(editor);
+ }
+ =20
+ @Test
+ public void testModelNDDim4() {
+ MatrixND matrix =3D getMatrixTest(4);
+ MatrixPanelEditor editor =3D new MatrixPanelEditor();
+ editor.setMatrix(matrix);
+ show(editor);
+ }
+ =20
+ @Test
+ public void testModelLinearDim3() {
+ MatrixND matrix =3D getMatrixTest(3);
+ MatrixPanelEditor editor =3D new MatrixPanelEditor();
+ editor.setLinearModel(true);
+ editor.setLinearModelShowDefault(true);
+ editor.setMatrix(matrix);
+ show(editor);
+ }
+ =20
+ @Test
+ public void testModelLinearDim4() {
+ MatrixND matrix =3D getMatrixTest(4);
+ MatrixPanelEditor editor =3D new MatrixPanelEditor();
+ editor.setLinearModel(true);
+ editor.setMatrix(matrix);
+ show(editor);
+ }
+}
Property changes on: trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/ma=
trix/gui/MatrixPanelEditorTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/gui/Ma=
trixPanelListenerTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/gui/MatrixPa=
nelListenerTest.java 2011-04-13 15:50:50 UTC (rev 352)
+++ trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/gui/MatrixPa=
nelListenerTest.java 2011-04-13 15:59:26 UTC (rev 353)
@@ -33,7 +33,7 @@
import org.junit.Test;
=20
/**
- * A test to verify that {@link MatrixPanelListener} is trully a JavaBeans
+ * A test to verify that {@link MatrixPanelListener} is truly a JavaBeans
* listener implementation in editors.
*=20
* @author chemit
@@ -44,7 +44,7 @@
public static final String MATRIX_PANEL_LISTENER_NAME =3D "matrixPanel";
=20
/**
- * Test if editors are trully JavaBeans listeners implementations
+ * Test if editors are truly JavaBeans listeners implementations
* @throws Exception
*/
@Test
Modified: trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/viewer=
/MatrixViewerPanelTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/viewer/Matri=
xViewerPanelTest.java 2011-04-13 15:50:50 UTC (rev 352)
+++ trunk/nuiton-matrix-gui/src/test/java/org/nuiton/math/matrix/viewer/Matri=
xViewerPanelTest.java 2011-04-13 15:59:26 UTC (rev 353)
@@ -37,7 +37,6 @@
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.MatrixProvider;
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;
=20
@@ -83,7 +82,8 @@
else {
matrix =3D MatrixFactory.getInstance().create("test matrix", new=
List>[]{years, cities}, new String[]{"Years", "Cities"});
MatrixHelper.fill(matrix, Math.random()*10000);
- matrix.setValue(0, 0, Math.random()*10000);
+ matrix.setValue(1, 0, Math.random()*10000);
+ matrix.setValue(0, 4, Math.random()*10000);
}
return matrix;
}
@@ -98,9 +98,10 @@
MatrixViewerPanel panel =3D new MatrixViewerPanel();
MatrixND testMatrix =3D getTestMatrix(false);
panel.setMatrix(testMatrix);
- panel.addMatrixRenderer(new MatrixInfoTableRenderer());
panel.addMatrixRenderer(new MatrixChartRenderer());
- panel.addMatrixRenderer(new MatrixPanelRenderer());
+ MatrixPanelRenderer panelRenderer =3D new MatrixPanelRenderer();
+ panelRenderer.getEditor().setDisplayOptions(true);
+ panel.addMatrixRenderer(panelRenderer);
frame.add(panel);
=20
frame.pack();
@@ -123,7 +124,7 @@
=20
MatrixViewerPanel panel =3D new MatrixViewerPanel();
MatrixND testMatrix =3D getTestMatrix(true);
- panel.addMatrixRenderer(new MatrixInfoTableRenderer());
+ panel.addMatrixRenderer(new MatrixPanelRenderer());
panel.addMatrixRenderer(new MatrixChartRenderer());
panel.addMatrixDimentionAction(new MatrixDimensionAction() {
@Override
--===============7178908402197989395==--