Author: chatellier Date: 2009-05-27 16:37:08 +0000 (Wed, 27 May 2009) New Revision: 2288 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonSpacializedUI.jaxx Log: Fix switch to non spacialized event triggered at UI init. Improve jaxx code. Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonSpacializedUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonSpacializedUI.jaxx 2009-05-27 14:54:20 UTC (rev 2287) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonSpacializedUI.jaxx 2009-05-27 16:37:08 UTC (rev 2288) @@ -1,13 +1,30 @@ - +<!-- +/* *##% + * Copyright (C) 2005 - 2009 Ifremer, Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + --> + <fr.ifremer.isisfish.ui.input.InputContentUI> <!-- bean property --> <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> - <fr.ifremer.isisfish.entities.PopulationSeasonInfoImpl id='populationSeasonInfo' javaBean='null'/> <Boolean id='popSeasonInfoNotNull' javaBean='false'/> - <Boolean id='ageGroupType' javaBean='false'/> <script><![CDATA[ @@ -19,57 +36,66 @@ import org.codelutin.math.matrix.gui.MatrixPanelListener; import jaxx.runtime.swing.ErrorDialogUI; -protected MatrixPanelListener listener = null; +protected MatrixPanelListener matrixPanelListener; -listener = new MatrixPanelListener() { - +matrixPanelListener = new MatrixPanelListener() { @Override - public void matrixChanged(MatrixPanelEvent arg0) { - if (getPopulationSeasonInfo() != null && fieldPopulationSeasonReproductionDistribution.getMatrix() != null){ - getPopulationSeasonInfo().setLengthChangeMatrix(fieldPopulationSeasonReproductionDistribution.getMatrix().copy()); + public void matrixChanged(MatrixPanelEvent event) { + if (getPopulationSeasonInfo() != null && matrixPanelPopulationSeasonLengthChange.getMatrix() != null) { + // must be a copy for fire event + MatrixND lengthChangeMatrix = matrixPanelPopulationSeasonLengthChange.getMatrix().copy(); + getPopulationSeasonInfo().setLengthChangeMatrix(lengthChangeMatrix); } } }; -public void refresh(){ - fieldPopulationSeasonReproductionDistribution.addMatrixListener(listener); + +public void refresh() { + matrixPanelPopulationSeasonLengthChange.addMatrixListener(matrixPanelListener); } -public void spacialized(){ - getPopulationSeasonInfo().setSimpleLengthChangeMatrix(labelPopulationSeasonGroupChangeLengthNoSpacialized.isSelected()); + +/** + * Called on spacialized radio button change. + */ +protected void spacializedActionPerformed() { PopulationSeasonInfo popInfo = getPopulationSeasonInfo(); + boolean spacializedSelection = radioPopulationSeasonGroupChangeLengthNoSpacialized.isSelected(); + popInfo.setSimpleLengthChangeMatrix(spacializedSelection); try { - MatrixND mat = popInfo.getLengthChangeMatrix(); - if (mat != null){ + MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix(); + if (lengthChangeMatrix != null) { if (popInfo.getSimpleLengthChangeMatrix()) { - mat = popInfo.unspacializeLengthChangeMatrix(mat); + lengthChangeMatrix = popInfo.unspacializeLengthChangeMatrix(lengthChangeMatrix); } else { - mat = popInfo.spacializeLengthChangeMatrix(mat); - popInfo.setLengthChangeMatrix(mat); + lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix); + popInfo.setLengthChangeMatrix(lengthChangeMatrix); } } - }catch(Exception eee){ - log.error("Can't (un)spacialize Matrix Change Of Group", eee); + } catch(Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't (un)spacialize Matrix Change Of Group", eee); + } ErrorDialogUI.showError(eee); } } -public void computeMatrixChangeOfGroup(){ +protected void computeMatrixChangeOfGroup() { PopulationSeasonInfo popInfo = getPopulationSeasonInfo(); - MatrixND mat = popInfo.computeLengthChangeMatrix(); - if(!popInfo.getSimpleLengthChangeMatrix()){ - mat = popInfo.spacializeLengthChangeMatrix(mat); + MatrixND lengthChangeMatrix = popInfo.computeLengthChangeMatrix(); + if (!popInfo.getSimpleLengthChangeMatrix()){ + lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix); } - popInfo.setLengthChangeMatrix(mat); + popInfo.setLengthChangeMatrix(lengthChangeMatrix); } -public void showSpacializedMatrixChangeOfGroup(){ +protected void showSpacializedMatrixChangeOfGroup() { PopulationSeasonInfo popInfo = getPopulationSeasonInfo(); - MatrixND mat = popInfo.getLengthChangeMatrix(); - if(popInfo.getSimpleLengthChangeMatrix()){ - mat = popInfo.spacializeLengthChangeMatrix(mat); + MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix(); + if (popInfo.getSimpleLengthChangeMatrix()){ + lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix); } JAXXMatrixEditor panel = new JAXXMatrixEditor(false, 800, 300); - panel.setMatrix(mat); - JOptionPane.showMessageDialog(null, panel, _("isisfish.message.spacialized.visualisation"), JOptionPane.INFORMATION_MESSAGE); + panel.setMatrix(lengthChangeMatrix); + JOptionPane.showMessageDialog(null, panel, _("isisfish.populationSeasons.spacialized.visualisation"), JOptionPane.INFORMATION_MESSAGE); } ]]></script> @@ -79,19 +105,20 @@ <Panel/> </cell> <cell fill='horizontal' weightx='0.5'> - <JRadioButton id="labelPopulationSeasonGroupChangeLengthNoSpacialized" - buttonGroup="labelPopulationSeasonGroupChangeLengthSpacializedGroup" + <JRadioButton id="radioPopulationSeasonGroupChangeLengthNoSpacialized" + buttonGroup="radioPopulationSeasonGroupChangeLengthSpacializedGroup" selected='{getPopulationSeasonInfo().getSimpleLengthChangeMatrix()}' - text="isisfish.populationSeasons.noSpacialized" decorator='boxed' - enabled='{isPopSeasonInfoNotNull()}' onItemStateChanged='spacialized()' - visible='{isAgeGroupType()}'/> + enabled='{isPopSeasonInfoNotNull()}' + text="isisfish.populationSeasons.noSpacialized" onActionPerformed='spacializedActionPerformed()' + visible='{isAgeGroupType()}' decorator='boxed' /> </cell> <cell fill='horizontal' weightx='0.5'> - <JRadioButton id="labelPopulationSeasonGroupChangeLengthSpacialized" - buttonGroup="labelPopulationSeasonGroupChangeLengthSpacializedGroup" + <JRadioButton id="radioPopulationSeasonGroupChangeLengthSpacialized" + buttonGroup="radioPopulationSeasonGroupChangeLengthSpacializedGroup" selected='{!getPopulationSeasonInfo().getSimpleLengthChangeMatrix()}' - text="isisfish.populationSeasons.spacialized" enabled='{isPopSeasonInfoNotNull()}' - visible='{isAgeGroupType()}' decorator='boxed'/> + enabled='{isPopSeasonInfoNotNull()}' + text="isisfish.populationSeasons.spacialized" onActionPerformed='spacializedActionPerformed()' + visible='{isAgeGroupType()}' decorator='boxed' /> </cell> </row> <row> @@ -103,8 +130,8 @@ enabled='{isPopSeasonInfoNotNull()}' onActionPerformed='computeMatrixChangeOfGroup()'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id="labelPopulationSeasonGroupChangeLengthButtonShow" text="isisfish.populationSeasons.showSpacialized" - enabled='{labelPopulationSeasonGroupChangeLengthNoSpacialized.isSelected()}' decorator='boxed' + <JButton id="buttonPopulationSeasonGroupChangeLengthButtonShow" text="isisfish.populationSeasons.showSpacialized" + enabled='{radioPopulationSeasonGroupChangeLengthNoSpacialized.isSelected()}' decorator='boxed' onActionPerformed='showSpacializedMatrixChangeOfGroup()' visible='{isAgeGroupType()}'/> </cell> @@ -114,10 +141,11 @@ <Panel/> </cell> <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> - <org.codelutin.math.matrix.gui.JAXXMatrixEditor id ='fieldPopulationSeasonReproductionDistribution' - matrix='{getPopulationSeasonInfo() == null ? null : getPopulationSeasonInfo().getLengthChangeMatrix()}' enabled='{isPopSeasonInfoNotNull()}' - decorator='boxed' _bean='{PopulationSeasonInfoImpl.class}' _method='"LengthChangeMatrix"' - visible='{isAgeGroupType()}'/> + <org.codelutin.math.matrix.gui.JAXXMatrixEditor id ='matrixPanelPopulationSeasonLengthChange' + matrix='{getPopulationSeasonInfo() == null ? null : getPopulationSeasonInfo().getLengthChangeMatrix().copy()}' + enabled='{isPopSeasonInfoNotNull()}' + _bean='{PopulationSeasonInfoImpl.class}' _method='"LengthChangeMatrix"' + visible='{isAgeGroupType()}' decorator='boxed' /> </cell> </row> </Table>
participants (1)
-
chatellierï¼ users.labs.libre-entreprise.org