Author: chatellier Date: 2010-12-09 14:06:27 +0000 (Thu, 09 Dec 2010) New Revision: 382 Log: Extract common method to inherited handler. Add length structure matrix display with matrix viewer. Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/CommonHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/DataHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixDataset.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixRenderer.java Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/CommonHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/CommonHandler.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/CommonHandler.java 2010-12-09 14:06:27 UTC (rev 382) @@ -0,0 +1,88 @@ +/* + * #%L + * + * + * $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 + * 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 fr.ifremer.coser.ui.common; + +import static org.nuiton.i18n.I18n._; + +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Desktop; +import java.io.File; +import java.io.IOException; + +import javax.swing.JOptionPane; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import fr.ifremer.coser.ui.control.ControlHandler; + +/** + * Common application handler. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class CommonHandler { + + private static final Log log = LogFactory.getLog(ControlHandler.class); + + /** + * Install le curseur sablier. + * + * @param comp component to set cursor + */ + public void setWaitCursor(Component comp) { + comp.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + } + + /** + * Repositionne le curseur a sa valeur par defaut. + * + * @param comp component to set cursor + */ + public void setDefaultCursor(Component comp) { + comp.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + + /** + * Ouvre un fichier dans le navigateur systeme. + * + * @param parentComponent parent component + * @param report report to open + */ + protected void browseFile(Component parentComponent, File report) { + try { + Desktop.getDesktop().browse(report.toURI()); + } catch (IOException ex) { + JOptionPane.showMessageDialog(parentComponent, _("coser.ui.error.htmlReportCantBeOpened", report.getAbsolutePath()), + _("coser.ui.error.htmlReportError"), JOptionPane.WARNING_MESSAGE); + } + } +} Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/CommonHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/DataHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/DataHandler.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/DataHandler.java 2010-12-09 14:06:27 UTC (rev 382) @@ -0,0 +1,46 @@ +/* + * #%L + * + * + * $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 + * 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 fr.ifremer.coser.ui.common; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import fr.ifremer.coser.ui.control.ControlHandler; + +/** + * Data application handler. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class DataHandler extends CommonHandler { + + private static final Log log = LogFactory.getLog(ControlHandler.class); + +} Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/DataHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixDataset.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixDataset.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixDataset.java 2010-12-09 14:06:27 UTC (rev 382) @@ -0,0 +1,66 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 Ifremer, CodeLutin, Chatellier Eric + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.coser.ui.common; + +import java.util.List; + +import org.nuiton.math.matrix.MatrixND; +import org.nuiton.math.matrix.viewer.renderer.jfreechart.GraphMatrixNDDataset; + +/** + * LengthStructureMatrixDataset + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class LengthStructureMatrixDataset extends GraphMatrixNDDataset { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6859245574029509304L; + + protected List<Double> categoryKeys; + + public LengthStructureMatrixDataset(MatrixND mat) { + this(mat.getSemantic(1), mat.getSemantic(0), mat); + } + + public LengthStructureMatrixDataset(List<?> seriesNames, List<?> categories, MatrixND mat) { + super(seriesNames, categories, mat); + } + + /*@Override + public Number getValue(int row, int column) { + Number number = super.getValue(row, column); + if (number.doubleValue() < 0.1) { + number = null; + } + return number; + }*/ + +} // GraphMatrixNDDataset Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixDataset.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixRenderer.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixRenderer.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixRenderer.java 2010-12-09 14:06:27 UTC (rev 382) @@ -0,0 +1,51 @@ +/* + * #%L + * + * + * $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 + * 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 fr.ifremer.coser.ui.common; + +import org.jfree.data.category.CategoryDataset; +import org.nuiton.math.matrix.MatrixND; +import org.nuiton.math.matrix.viewer.renderer.MatrixChartRenderer; + +/** + * JFreeChart matrix panel renderer. + * + * Only redefine {@link #getCategoryDataset(MatrixND)} because in coser, we need to + * generate graph with missing value. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class LengthStructureMatrixRenderer extends MatrixChartRenderer { + + @Override + protected CategoryDataset getCategoryDataset(MatrixND matrix) { + return new LengthStructureMatrixDataset(matrix); + } + +} Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-12-09 14:05:20 UTC (rev 381) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-12-09 14:06:27 UTC (rev 382) @@ -27,7 +27,6 @@ import java.awt.BorderLayout; import java.awt.Component; -import java.awt.Cursor; import java.awt.Desktop; import java.awt.GridBagConstraints; import java.awt.Insets; @@ -94,6 +93,7 @@ import fr.ifremer.coser.services.ControlService; import fr.ifremer.coser.services.ProjectService; import fr.ifremer.coser.services.PublicationService; +import fr.ifremer.coser.ui.common.DataHandler; import fr.ifremer.coser.ui.util.CoserProgressBar; /** @@ -105,29 +105,11 @@ * Last update : $Date$ * By : $Author$ */ -public class ControlHandler { +public class ControlHandler extends DataHandler { private static final Log log = LogFactory.getLog(ControlHandler.class); /** - * Install le curseur sablier. - * - * @param comp component to set cursor - */ - public void setWaitCursor(Component comp) { - comp.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - } - - /** - * Repositionne le curseur a sa valeur par defaut. - * - * @param comp component to set cursor - */ - public void setDefaultCursor(Component comp) { - comp.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - - /** * Return l'intance de la table qui est selectionnée. * * Les 4 table sont dupliquées juste pour concerver l'etat des colonnes. @@ -665,28 +647,13 @@ File htmlFile = null; try { htmlFile = publicationService.exportErrorsAsHTML(project, project.getControl(), controlErrors); - displayReport(controlView, htmlFile); + browseFile(controlView, htmlFile); } catch (CoserBusinessException ex) { throw new CoserException("Can't generate html report", ex); } } /** - * Ouvre un fichier html dans le navigateur systeme. - * - * @param component component - * @param report report to open - */ - protected void displayReport(Component component, File report) { - try { - Desktop.getDesktop().browse(report.toURI()); - } catch (IOException ex) { - JOptionPane.showMessageDialog(component, _("coser.ui.error.htmlReportCantBeOpened", report.getAbsolutePath()), - _("coser.ui.error.htmlReportError"), JOptionPane.WARNING_MESSAGE); - } - } - - /** * Contruit le panel d'edition du bean. * * Vide le panel si line est {@code null}. @@ -1071,7 +1038,7 @@ File htmlFile = null; try { htmlFile = publicationService.extractLogAsHTML(project, project.getControl()); - displayReport(controlView, htmlFile); + browseFile(controlView, htmlFile); } catch (CoserBusinessException ex) { throw new CoserException("Can't generate html report", ex); } Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-12-09 14:05:20 UTC (rev 381) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-12-09 14:06:27 UTC (rev 382) @@ -26,14 +26,12 @@ import static org.nuiton.i18n.I18n._; import java.awt.Component; -import java.awt.Desktop; import java.awt.GridBagConstraints; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -69,7 +67,7 @@ import fr.ifremer.coser.bean.Selection; import fr.ifremer.coser.services.ProjectService; import fr.ifremer.coser.services.PublicationService; -import fr.ifremer.coser.ui.control.ControlView; +import fr.ifremer.coser.ui.common.DataHandler; import fr.ifremer.coser.ui.result.SelectionAddResultDialog; import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpecyListModel; import fr.ifremer.coser.ui.util.CoserListSelectionModel; @@ -83,7 +81,7 @@ * Last update : $Date$ * By : $Author$ */ -public class SelectionHandler { +public class SelectionHandler extends DataHandler { private static final Log log = LogFactory.getLog(SelectionHandler.class); @@ -1006,24 +1004,9 @@ File htmlFile = null; try { htmlFile = publicationService.extractLogAsHTML(project, selection); - displayReport(view, htmlFile); + browseFile(view, htmlFile); } catch (CoserBusinessException ex) { throw new CoserException("Can't generate html report", ex); } } - - /** - * Ouvre un fichier html dans le navigateur systeme. - * - * @param view view - * @param report report to open - */ - protected void displayReport(Component component, File report) { - try { - Desktop.getDesktop().browse(report.toURI()); - } catch (IOException ex) { - JOptionPane.showMessageDialog(component, _("coser.ui.error.htmlReportCantBeOpened", report.getAbsolutePath()), - _("coser.ui.error.htmlReportError"), JOptionPane.WARNING_MESSAGE); - } - } }