Author: chatellier Date: 2010-11-10 16:47:00 +0000 (Wed, 10 Nov 2010) New Revision: 202 Log: Refactoring sur les mod?\195?\168les. Filtrage de la liste L2 par l'occurrence et la densit?\195?\169. Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListOccDensRenderer.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyTypesListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearComboBoxModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/ZoneListModel.java Removed: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListCheckBoxRenderer.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListRenderer.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyTypesListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListRenderer.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListTestModel.java Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-11-10 16:47:00 UTC (rev 202) @@ -515,7 +515,7 @@ // fichier de validation existe ici ou pas Project localProject = project; - if (!localProject.getControl().isDataLoaded()) { + if (localProject.getControl() == null || !localProject.getControl().isDataLoaded()) { localProject = loadControlData(localProject); } @@ -1350,7 +1350,7 @@ * @param selection * @return occurence as matrix */ - public MatrixND getOccurence(Project project, Selection selection) { + public MatrixND getOccurrence(Project project, Selection selection) { // map species > "year, hauls" Map<String, Map<String, Set<String>>> dynMatrix = new HashMap<String, Map<String, Set<String>>>(); @@ -1535,6 +1535,12 @@ try { Double number = Double.valueOf(numberAsString); Double sweptSurface = haulAndSweptSurface.get(year + ";" + haul); + if (sweptSurface == null) { + if (log.isWarnEnabled()) { + log.warn("Can't find swept surface for " + year + ";" + haul); + } + continue; + } Double density = number / sweptSurface; // count for species and year @@ -1591,7 +1597,7 @@ double meanDensity = totalDensity / densityCount; // surfaceparstrate - double surfaceparstrate = surfacesParStrates.get(haulCountForYearEntry.getKey() + ";" + dynMatrixEntry.getKey()); + //double surfaceparstrate = surfacesParStrates.get(haulCountForYearEntry.getKey() + ";" + dynMatrixEntry.getKey()); //TODO echatellier 20101109 finir //matrix.setValue(dynMatrixEntry.getKey(), haulCountForYearEntry.getKey(), occurence); Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java =================================================================== --- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-10 16:47:00 UTC (rev 202) @@ -324,7 +324,7 @@ Project project = createTestProject(projectService); Selection selection = projectService.initProjectSelection(project); selection.setName("test"); - MatrixND matrix = projectService.getOccurence(project, selection); + MatrixND matrix = projectService.getOccurrence(project, selection); Assert.assertNotNull(matrix); } } Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx 2010-11-10 16:47:00 UTC (rev 202) @@ -25,7 +25,7 @@ <JFrame title="coser.ui.mainview.title" layout="{new BorderLayout()}" name="mainFrame" onWindowClosing="getHandler().quit()"> - <CoserFrameHandler id="handler" javaBean="new CoserFrameHandler(this)" /> + <CoserFrameHandler id="handler" constructorParams="this" /> <JMenuBar id='coserMenuBar'> Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-11-10 16:47:00 UTC (rev 202) @@ -418,7 +418,7 @@ */ protected boolean checkControlSession() { - boolean result = false; + boolean result = true; // basé sur un hack, car ici, on ne sais pas ce que contient // le panel principal @@ -457,10 +457,14 @@ SelectionHandler handler = new SelectionHandler(); selectionView.setHandler(handler); handler.reloadSelection(selectionView); - - File file = new File("/home/chatellier/tmp/coser/zones.png"); - selectionView.getSelectionDetailsTab().getZonesMap().setImage(file); - + + try { + File file = new File("/home/chatellier/tmp/coser/zones.png"); + selectionView.getSelectionDetailsTab().getZonesMap().setImage(file); + } catch(Exception e) { + e.printStackTrace(); + }; + setMainComponent(selectionView); } catch (CoserBusinessException ex) { throw new CoserException("Can't reload selection data", ex); Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-11-10 16:47:00 UTC (rev 202) @@ -25,8 +25,8 @@ <Table> <script><![CDATA[ - import fr.ifremer.coser.ui.selection.model.SpecyListTestModel; - import fr.ifremer.coser.ui.util.CoserListSelectionModel; + import fr.ifremer.coser.ui.selection.model.*; + import fr.ifremer.coser.ui.util.*; ]]></script> <SelectionHandler id="handler" javaBean="null" /> @@ -105,7 +105,6 @@ <JScrollPane> <ZoneListModel id="zoneListModel" /> <JList id="zoneList" model="{zoneListModel}" - cellRenderer="{new ZoneListRenderer()}" enabled="{beginYearComboBox.getSelectedItem() != null && endYearComboBox.getSelectedItem() != null}" selectionModel="{new CoserListSelectionModel(zoneList.getSelectionModel(), zoneListModel)}" onValueChanged="getHandler().zoneListChanged(this, event);"/> @@ -138,9 +137,8 @@ <row> <cell weighty="2" fill="both" columns="2"> <JScrollPane> - <fr.ifremer.coser.ui.selection.model.SpecyListTestModel id="specyListModel" /> + <SpecyListModel id="specyListModel" /> <JList id="specyList" model="{specyListModel}" - cellRenderer="{new SpecyListRenderer()}" enabled="{beginYearComboBox.getSelectedItem() != null && endYearComboBox.getSelectedItem() != null}" onMouseClicked="getHandler().showSpeciesContextMenu(this, event)" selectionModel="{new CoserListSelectionModel(specyList.getSelectionModel(), specyListModel)}" 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-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-10 16:47:00 UTC (rev 202) @@ -49,6 +49,7 @@ import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.bean.Selection; import fr.ifremer.coser.services.ProjectService; +import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpecyListModel; import fr.ifremer.coser.ui.util.CoserListSelectionModel; /** @@ -80,18 +81,34 @@ if (log.isDebugEnabled()) { log.debug("List details tab selected"); } - + Selection selection = view.getContextValue(Selection.class); // si la selection n'est pas la même que que celle de la sélection // on met à jour la liste de "Toutes les especes" (L1) - + List<String> currentList = selectionListsView.getSelectionAllSpeciesListModel().getSpecies(); List<String> selectionSpecyList = selection.getSpecies(); - + if (!selectionSpecyList.equals(currentList)) { + // on calcul également les matrices de d'occurence, densité + Project project = view.getContextValue(Project.class); + ProjectService projectService = view.getContextValue(ProjectService.class); + MatrixND occurrence = projectService.getOccurrence(project, selection); + //MatrixND density = projectService.getDensity(project, selection); + //MatrixND samplingEffort = projectService.getSamplingEffort(project, selection); + + // set matrix on list model + selectionListsView.getSelectionOccurrenceDensityListModel().setOccurrence(occurrence); + + // fill all specy data (at final) selectionListsView.getSelectionAllSpeciesListModel().setSpecies(selectionSpecyList); + + // select all list (not to do for reload) ((CoserListSelectionModel)selectionListsView.getSelectionAllSpeciesList().getSelectionModel()).fillSelection(); + updateOccurrenceDensityFilter(selectionListsView); + ((CoserListSelectionModel)selectionListsView.getSelectionSizeAllYearList().getSelectionModel()).fillSelection(); + ((CoserListSelectionModel)selectionListsView.getSelectionMaturityList().getSelectionModel()).fillSelection(); } } } @@ -365,6 +382,43 @@ } /** + * Mise à jour du filtre d'ocurrence et densité. + * + * Selectionne dans la liste seulement les especes ayant une densité + * suppérieure à celle indique (idem pour l'occurence). + * + * @param view selection list view + */ + public void updateOccurrenceDensityFilter(SelectionListsView view) { + String stringOccurrence = view.getSelectionFilterOccurrenceField().getText().trim(); + String stringDensity = view.getSelectionFilterDensityField().getText().trim(); + + try { + double occurrence = Double.valueOf(stringOccurrence); + double density = Double.valueOf(stringDensity); + + // construction de la liste de selection des especes + OccurrenceDensitySpecyListModel model = view.getSelectionOccurrenceDensityListModel(); + int speciesCount = model.getSize(); + List<String> filteredSpecies = new ArrayList<String>(); + for (int speciesIndex = 0 ; speciesIndex < speciesCount ; speciesIndex++) { + String specy = (String)model.getElementAt(speciesIndex); + if (model.getDensity(specy) > density && model.getOccurrence(specy) > occurrence) { + filteredSpecies.add(specy); + } + } + + // application de la nouvelle selection + ((CoserListSelectionModel)view.getSelectionOccurrenceDensityList().getSelectionModel()).setSelectedObjects(filteredSpecies); + } + catch (NumberFormatException ex) { + if (log.isWarnEnabled()) { + log.warn("Can't parse occurrence or density as double", ex); + } + } + } + + /** * Sauvegarde des listes des selectino d'especes. * * @param view view Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 2010-11-10 16:47:00 UTC (rev 202) @@ -26,18 +26,18 @@ <SelectionHandler id="handler" javaBean="null" /> <script><![CDATA[ - import fr.ifremer.coser.ui.selection.model.SpecyListTestModel; - import fr.ifremer.coser.ui.util.CoserListSelectionModel; + import fr.ifremer.coser.ui.selection.model.*; + import fr.ifremer.coser.ui.util.*; // le modele de la liste est allimenté par la selection de la précédente liste // la selection est mise à jour par la modification du model de la liste void $afterCompleteSetup() { // modification (all species -> all species list) - selectionAllSpeciesList.addListSelectionListener(selectionOccurenceDensityListModel); - selectionOccurenceDensityListModel.addListDataListener((CoserListSelectionModel)selectionOccurenceDensityList.getSelectionModel()); + selectionAllSpeciesList.addListSelectionListener(selectionOccurrenceDensityListModel); + selectionOccurrenceDensityListModel.addListDataListener((CoserListSelectionModel)selectionOccurrenceDensityList.getSelectionModel()); - selectionOccurenceDensityList.addListSelectionListener(selectionSizeAllYearListModel); + selectionOccurrenceDensityList.addListSelectionListener(selectionSizeAllYearListModel); selectionSizeAllYearListModel.addListDataListener((CoserListSelectionModel)selectionSizeAllYearList.getSelectionModel()); selectionSizeAllYearList.addListSelectionListener(selectionMaturityListModel); @@ -69,7 +69,7 @@ <JTextField id="selectionFilterOccurrenceField" columns="3" text="5" /> <JLabel text="coser.ui.selection.filter.density" /> <JTextField id="selectionFilterDensityField" columns="3" text="5" /> - <JButton text="coser.ui.selection.filter.filter" /> + <JButton text="coser.ui.selection.filter.filter" onActionPerformed="getHandler().updateOccurrenceDensityFilter(this)" /> </JPanel> </cell> <cell columns="2"> @@ -82,34 +82,31 @@ <row> <cell weighty="1" weightx="1" fill="both" columns="2"> <JScrollPane> - <SpecyListTestModel id="selectionAllSpeciesListModel" /> + <SpecyListModel id="selectionAllSpeciesListModel" /> <JList id="selectionAllSpeciesList" model="{selectionAllSpeciesListModel}" - cellRenderer="{new SpecyListCheckBoxRenderer()}" selectionModel="{new CoserListSelectionModel(selectionAllSpeciesList.getSelectionModel(), selectionAllSpeciesListModel)}" enabled="false" /> </JScrollPane> </cell> <cell weightx="1" fill="both" columns="2"> <JScrollPane> - <SpecyListTestModel id="selectionOccurenceDensityListModel" /> - <JList id="selectionOccurenceDensityList" model="{selectionOccurenceDensityListModel}" - cellRenderer="{new SpecyListCheckBoxRenderer(true)}" - selectionModel="{new CoserListSelectionModel(selectionOccurenceDensityList.getSelectionModel(), selectionOccurenceDensityListModel)}"/> + <OccurrenceDensitySpecyListModel id="selectionOccurrenceDensityListModel" /> + <JList id="selectionOccurrenceDensityList" model="{selectionOccurrenceDensityListModel}" + cellRenderer="{new SpecyListOccDensRenderer(selectionOccurrenceDensityListModel)}" + selectionModel="{new CoserListSelectionModel(selectionOccurrenceDensityList.getSelectionModel(), selectionOccurrenceDensityListModel)}"/> </JScrollPane> </cell> <cell weightx="1" fill="both" columns="2"> <JScrollPane> - <SpecyListTestModel id="selectionSizeAllYearListModel" /> + <SpecyListModel id="selectionSizeAllYearListModel" /> <JList id="selectionSizeAllYearList" model="{selectionSizeAllYearListModel}" - cellRenderer="{new SpecyListCheckBoxRenderer()}" selectionModel="{new CoserListSelectionModel(selectionSizeAllYearList.getSelectionModel(), selectionSizeAllYearListModel)}"/> </JScrollPane> </cell> <cell weightx="1" fill="both" columns="2"> <JScrollPane> - <SpecyListTestModel id="selectionMaturityListModel" /> + <SpecyListModel id="selectionMaturityListModel" /> <JList id="selectionMaturityList" model="{selectionMaturityListModel}" - cellRenderer="{new SpecyListCheckBoxRenderer()}" selectionModel="{new CoserListSelectionModel(selectionMaturityList.getSelectionModel(), selectionMaturityListModel)}"/> </JScrollPane> </cell> @@ -125,11 +122,11 @@ </cell> <cell fill="horizontal" weightx="1"> <JButton text='coser.ui.common.selectAll.short' - onActionPerformed="((CoserListSelectionModel)selectionOccurenceDensityList.getSelectionModel()).fillSelection()"/> + onActionPerformed="((CoserListSelectionModel)selectionOccurrenceDensityList.getSelectionModel()).fillSelection()"/> </cell> <cell fill="horizontal" weightx="1"> <JButton text='coser.ui.common.unselectAll.short' - onActionPerformed="((CoserListSelectionModel)selectionOccurenceDensityList.getSelectionModel()).clearSelection()"/> + onActionPerformed="((CoserListSelectionModel)selectionOccurrenceDensityList.getSelectionModel()).clearSelection()"/> </cell> <cell fill="horizontal" weightx="1"> <JButton text='coser.ui.common.selectAll.short' Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListCheckBoxRenderer.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListCheckBoxRenderer.java 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListCheckBoxRenderer.java 2010-11-10 16:47:00 UTC (rev 202) @@ -1,77 +0,0 @@ -/* - * #%L - * Coser :: UI - * - * $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 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 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-3.0.html>. - * #L% - */ - -package fr.ifremer.coser.ui.selection; - -import java.awt.Component; - -import javax.swing.JList; - -import org.jdesktop.swingx.renderer.DefaultListRenderer; - -/** - * Check box list renderer. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class SpecyListCheckBoxRenderer extends DefaultListRenderer { - - /** serialVersionUID. */ - private static final long serialVersionUID = 4329272863520663978L; - - protected boolean displayOccurrenceAndDensity; - - public SpecyListCheckBoxRenderer() { - this(false); - } - - public SpecyListCheckBoxRenderer(boolean displayOccurrenceAndDensity) { - this.displayOccurrenceAndDensity = displayOccurrenceAndDensity; - } - - @Override - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { - - String specy = (String)value; - //JCheckBox comboBox = new JCheckBox(); - - String stringValue = null; - /*if (displayOccurrenceAndDensity) { - stringValue = "<html>" + specy.getName() + " <span style='font-size:85%;color:gray;'>(X=44, Y=21)</span><html>"; - } - else {*/ - stringValue = specy; - //} - //comboBox.setText(stringValue); - - return super.getListCellRendererComponent(list, stringValue, index, isSelected, cellHasFocus); - } - -} Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListOccDensRenderer.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListOccDensRenderer.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListOccDensRenderer.java 2010-11-10 16:47:00 UTC (rev 202) @@ -0,0 +1,77 @@ +/* + * #%L + * Coser :: UI + * + * $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 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 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-3.0.html>. + * #L% + */ + +package fr.ifremer.coser.ui.selection; + +import static org.nuiton.i18n.I18n._; + +import java.awt.Component; + +import javax.swing.JList; + +import org.jdesktop.swingx.renderer.DefaultListRenderer; + +import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpecyListModel; + +/** + * Specy renderer with occurrence and density display. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class SpecyListOccDensRenderer extends DefaultListRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -5404111064519251687L; + + protected OccurrenceDensitySpecyListModel model; + + public SpecyListOccDensRenderer(OccurrenceDensitySpecyListModel model) { + this.model = model; + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + String specy = (String)value; + + String stringValue = null; + if (model != null) { + double occurrence = model.getOccurrence(specy); + double density = model.getDensity(specy); + stringValue = _("coser.ui.selection.occurrencedensityrenderer", specy, occurrence, density); + } + else { + stringValue = specy; + } + + return super.getListCellRendererComponent(list, stringValue, index, isSelected, cellHasFocus); + } + +} Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListOccDensRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListRenderer.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListRenderer.java 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListRenderer.java 2010-11-10 16:47:00 UTC (rev 202) @@ -1,58 +0,0 @@ -/* - * #%L - * Coser :: UI - * - * $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 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 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-3.0.html>. - * #L% - */ - -package fr.ifremer.coser.ui.selection; - -import java.awt.Component; - -import javax.swing.DefaultListCellRenderer; -import javax.swing.JList; - -/** - * Basic list renderer. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class SpecyListRenderer extends DefaultListCellRenderer { - - /** serialVersionUID. */ - private static final long serialVersionUID = 4329272863520663978L; - - @Override - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { - - String specy = (String)value; - //String stringValue = specy.getName(); - - //JCheckBox checkBox = new JCheckBox(stringValue); - //checkBox.setSelected(isSelected); - return super.getListCellRendererComponent(list, specy, index, isSelected, cellHasFocus); - } -} Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyTypesListModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyTypesListModel.java 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyTypesListModel.java 2010-11-10 16:47:00 UTC (rev 202) @@ -1,91 +0,0 @@ -/* - * #%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 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.selection; - -import java.util.List; - -import javax.swing.AbstractListModel; - -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.services.ProjectService; -import fr.ifremer.coser.ui.util.CoserListModel; - -/** - * Affiche la liste des types d'especes définie dans le projet. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class SpecyTypesListModel extends AbstractListModel implements CoserListModel { - - /** serialVersionUID. */ - private static final long serialVersionUID = 441910182067909029L; - - protected SelectionDetailsView view; - - protected List<String> types; - - public SpecyTypesListModel(SelectionDetailsView view) { - super(); - this.view = view; - } - - protected List<String> getTypes() { - if (types == null) { - Project project = view.getContextValue(Project.class); - ProjectService service = view.getContextValue(ProjectService.class); - types = service.getProjectSpeciesTypes(project); - } - return types; - } - - /* - * @see javax.swing.ListModel#getSize() - */ - @Override - public int getSize() { - return getTypes().size(); - } - - /* - * @see javax.swing.ListModel#getElementAt(int) - */ - @Override - public Object getElementAt(int index) { - return getTypes().get(index); - } - - /* - * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) - */ - @Override - public int indexOf(Object element) { - return getTypes().indexOf(element); - } -} Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java 2010-11-10 16:47:00 UTC (rev 202) @@ -1,101 +0,0 @@ -/* - * #%L - * Coser :: UI - * - * $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 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 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-3.0.html>. - * #L% - */ - -package fr.ifremer.coser.ui.selection; - -import java.util.List; - -import javax.swing.AbstractListModel; -import javax.swing.ComboBoxModel; - -import fr.ifremer.coser.bean.Selection; -import fr.ifremer.coser.services.ProjectService; - -/** - * Model pour combo box contenant la liste des années définies dans le projet. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class YearComboBoxModel extends AbstractListModel implements ComboBoxModel { - - /** serialVersionUID. */ - private static final long serialVersionUID = 9172638630862188715L; - - protected SelectionDetailsView view; - - protected List<Integer> years; - - protected Object selectedItem; - - public YearComboBoxModel(SelectionDetailsView view) { - super(); - this.view = view; - } - - protected List<Integer> getYear() { - if (years == null) { - Selection selection = view.getContextValue(Selection.class); - ProjectService service = view.getContextValue(ProjectService.class); - years = service.getProjectYears(selection); - } - return years; - } - - /* - * @see javax.swing.ListModel#getSize() - */ - @Override - public int getSize() { - return getYear().size(); - } - - /* - * @see javax.swing.ListModel#getElementAt(int) - */ - @Override - public Object getElementAt(int index) { - return getYear().get(index); - } - - /* - * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object) - */ - @Override - public void setSelectedItem(Object anItem) { - selectedItem = anItem; - } - - /* - * @see javax.swing.ComboBoxModel#getSelectedItem() - */ - @Override - public Object getSelectedItem() { - return selectedItem; - } -} Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java 2010-11-10 16:47:00 UTC (rev 202) @@ -1,84 +0,0 @@ -/* - * #%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 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 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-3.0.html>. - * #L% - */ - -package fr.ifremer.coser.ui.selection; - -import java.util.List; - -import javax.swing.AbstractListModel; - -import fr.ifremer.coser.ui.util.CoserListModel; - -/** - * Model contenant la liste des noms de zone (utilisé dans le detail de selection). - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class ZoneListModel extends AbstractListModel implements CoserListModel { - - /** serialVersionUID. */ - private static final long serialVersionUID = -8155676616312843132L; - - protected List<String> zones; - - public List<String> getZones() { - return zones; - } - - public void setZones(List<String> zones) { - this.zones = zones; - fireContentsChanged(this, 0, zones.size()); - } - - /* - * @see javax.swing.ListModel#getSize() - */ - @Override - public int getSize() { - int size = 0; - if (zones != null) { - size = zones.size(); - } - return size; - } - - /* - * @see javax.swing.ListModel#getElementAt(int) - */ - @Override - public Object getElementAt(int index) { - return zones.get(index); - } - - /* - * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) - */ - @Override - public int indexOf(Object element) { - return zones.indexOf(element); - } -} Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListRenderer.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListRenderer.java 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListRenderer.java 2010-11-10 16:47:00 UTC (rev 202) @@ -1,56 +0,0 @@ -/* - * #%L - * Coser :: UI - * - * $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 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 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-3.0.html>. - * #L% - */ - -package fr.ifremer.coser.ui.selection; - -import java.awt.Component; - -import javax.swing.DefaultListCellRenderer; -import javax.swing.JList; - -/** - * Renderer de la liste des nom de zone. - * (pas forcement utile avec des String). - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class ZoneListRenderer extends DefaultListCellRenderer { - - /** serialVersionUID. */ - private static final long serialVersionUID = 4329272863520663978L; - - @Override - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { - - String zone = (String)value; - - return super.getListCellRendererComponent(list, zone, index, isSelected, cellHasFocus); - } -} Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java 2010-11-10 16:47:00 UTC (rev 202) @@ -0,0 +1,127 @@ +/* + * #%L + * Coser :: UI + * + * $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 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 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-3.0.html>. + * #L% + */ + +package fr.ifremer.coser.ui.selection.model; + +import java.util.ArrayList; +import java.util.List; + +import javax.swing.AbstractListModel; +import javax.swing.JList; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import org.nuiton.math.matrix.MatrixND; + +import fr.ifremer.coser.ui.util.CoserListModel; + +/** + * Occurence and density filered specy list model. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class OccurrenceDensitySpecyListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = -4769109927915812519L; + + protected List<String> species = new ArrayList<String>(); + + protected MatrixND occurrence = null; + + public List<String> getSpecies() { + return species; + } + + public void setSpecies(List<String> species) { + this.species = species; + fireContentsChanged(this, 0, species.size()); + } + + public void setOccurrence(MatrixND occurrence) { + this.occurrence = occurrence; + } + + public double getOccurrence(String specy) { + List<String> years = (List<String>)occurrence.getSemantic(1); + double result = occurrence.getValue(specy, years.get(0)); + return result; + } + + public double getDensity(String specy) { + return 6.0; + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int result = 0; + if (species != null) { + result = species.size(); + } + return result; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return species.get(index); + } + + + /* + * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) + */ + @Override + public int indexOf(Object o) { + return species.indexOf(o); + } + + /* + * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) + */ + @Override + public void valueChanged(ListSelectionEvent event) { + + if (!event.getValueIsAdjusting()) { + JList source = (JList)event.getSource(); + Object[] selectedValues = source.getSelectedValues(); + species.clear(); + for (Object selectedValue : selectedValues) { + String specy = (String)selectedValue; + species.add(specy); + } + fireContentsChanged(this, 0, species.size() - 1); + } + } +} Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpecyListModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListModel.java (from rev 198, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListTestModel.java) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListModel.java 2010-11-10 16:47:00 UTC (rev 202) @@ -0,0 +1,109 @@ +/* + * #%L + * Coser :: UI + * + * $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 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 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-3.0.html>. + * #L% + */ + +package fr.ifremer.coser.ui.selection.model; + +import java.util.ArrayList; +import java.util.List; + +import javax.swing.AbstractListModel; +import javax.swing.JList; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import fr.ifremer.coser.ui.util.CoserListModel; + +/** + * No filtered species model. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class SpecyListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = -4769109927915812519L; + + protected List<String> species = new ArrayList<String>(); + + public List<String> getSpecies() { + return species; + } + + public void setSpecies(List<String> species) { + this.species = species; + fireContentsChanged(this, 0, species.size()); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int result = 0; + if (species != null) { + result = species.size(); + } + return result; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return species.get(index); + } + + + /* + * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) + */ + @Override + public int indexOf(Object o) { + return species.indexOf(o); + } + + /* + * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) + */ + @Override + public void valueChanged(ListSelectionEvent event) { + + if (!event.getValueIsAdjusting()) { + JList source = (JList)event.getSource(); + Object[] selectedValues = source.getSelectedValues(); + species.clear(); + for (Object selectedValue : selectedValues) { + String specy = (String)selectedValue; + species.add(specy); + } + fireContentsChanged(this, 0, species.size() - 1); + } + } +} Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListTestModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListTestModel.java 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyListTestModel.java 2010-11-10 16:47:00 UTC (rev 202) @@ -1,112 +0,0 @@ -/* - * #%L - * Coser :: UI - * - * $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 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 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-3.0.html>. - * #L% - */ - -package fr.ifremer.coser.ui.selection.model; - -import java.util.ArrayList; -import java.util.List; - -import javax.swing.AbstractListModel; -import javax.swing.JList; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import fr.ifremer.coser.ui.util.CoserListModel; - -/** - * Test list model. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class SpecyListTestModel extends AbstractListModel implements ListSelectionListener, CoserListModel { - - /** serialVersionUID. */ - private static final long serialVersionUID = -4769109927915812519L; - - protected List<String> species = new ArrayList<String>(); - - public List<String> getSpecies() { - return species; - } - - public void setSpecies(List<String> species) { - this.species = species; - fireContentsChanged(this, 0, species.size()); - } - - /* - * @see javax.swing.ListModel#getSize() - */ - @Override - public int getSize() { - int result = 0; - if (species != null) { - result = species.size(); - } - return result; - } - - /* - * @see javax.swing.ListModel#getElementAt(int) - */ - @Override - public Object getElementAt(int index) { - return species.get(index); - } - - - /* - * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) - */ - @Override - public int indexOf(Object o) { - return species.indexOf(o); - } - - /* - * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) - */ - @Override - public void valueChanged(ListSelectionEvent event) { - - // il le fait surrement deux fois, mais - // sans ca, la mise à jour des 4 listes en meme tps ne fonctionne pas - - //if (event.getValueIsAdjusting()) { - JList source = (JList)event.getSource(); - Object[] selectedValues = source.getSelectedValues(); - species.clear(); - for (Object selectedValue : selectedValues) { - String specy = (String)selectedValue; - species.add(specy); - } - fireContentsChanged(this, 0, species.size() - 1); - //} - } -} Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyTypesListModel.java (from rev 198, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyTypesListModel.java) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyTypesListModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpecyTypesListModel.java 2010-11-10 16:47:00 UTC (rev 202) @@ -0,0 +1,92 @@ +/* + * #%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 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.selection.model; + +import java.util.List; + +import javax.swing.AbstractListModel; + +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.services.ProjectService; +import fr.ifremer.coser.ui.selection.SelectionDetailsView; +import fr.ifremer.coser.ui.util.CoserListModel; + +/** + * Affiche la liste des types d'especes définie dans le projet. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class SpecyTypesListModel extends AbstractListModel implements CoserListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 441910182067909029L; + + protected SelectionDetailsView view; + + protected List<String> types; + + public SpecyTypesListModel(SelectionDetailsView view) { + super(); + this.view = view; + } + + protected List<String> getTypes() { + if (types == null) { + Project project = view.getContextValue(Project.class); + ProjectService service = view.getContextValue(ProjectService.class); + types = service.getProjectSpeciesTypes(project); + } + return types; + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + return getTypes().size(); + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return getTypes().get(index); + } + + /* + * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) + */ + @Override + public int indexOf(Object element) { + return getTypes().indexOf(element); + } +} Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearComboBoxModel.java (from rev 106, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearComboBoxModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearComboBoxModel.java 2010-11-10 16:47:00 UTC (rev 202) @@ -0,0 +1,102 @@ +/* + * #%L + * Coser :: UI + * + * $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 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 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-3.0.html>. + * #L% + */ + +package fr.ifremer.coser.ui.selection.model; + +import java.util.List; + +import javax.swing.AbstractListModel; +import javax.swing.ComboBoxModel; + +import fr.ifremer.coser.bean.Selection; +import fr.ifremer.coser.services.ProjectService; +import fr.ifremer.coser.ui.selection.SelectionDetailsView; + +/** + * Model pour combo box contenant la liste des années définies dans le projet. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class YearComboBoxModel extends AbstractListModel implements ComboBoxModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 9172638630862188715L; + + protected SelectionDetailsView view; + + protected List<Integer> years; + + protected Object selectedItem; + + public YearComboBoxModel(SelectionDetailsView view) { + super(); + this.view = view; + } + + protected List<Integer> getYear() { + if (years == null) { + Selection selection = view.getContextValue(Selection.class); + ProjectService service = view.getContextValue(ProjectService.class); + years = service.getProjectYears(selection); + } + return years; + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + return getYear().size(); + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return getYear().get(index); + } + + /* + * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object) + */ + @Override + public void setSelectedItem(Object anItem) { + selectedItem = anItem; + } + + /* + * @see javax.swing.ComboBoxModel#getSelectedItem() + */ + @Override + public Object getSelectedItem() { + return selectedItem; + } +} Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/ZoneListModel.java (from rev 198, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/ZoneListModel.java) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/ZoneListModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/ZoneListModel.java 2010-11-10 16:47:00 UTC (rev 202) @@ -0,0 +1,84 @@ +/* + * #%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 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 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-3.0.html>. + * #L% + */ + +package fr.ifremer.coser.ui.selection.model; + +import java.util.List; + +import javax.swing.AbstractListModel; + +import fr.ifremer.coser.ui.util.CoserListModel; + +/** + * Model contenant la liste des noms de zone (utilisé dans le detail de selection). + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class ZoneListModel extends AbstractListModel implements CoserListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = -8155676616312843132L; + + protected List<String> zones; + + public List<String> getZones() { + return zones; + } + + public void setZones(List<String> zones) { + this.zones = zones; + fireContentsChanged(this, 0, zones.size()); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int size = 0; + if (zones != null) { + size = zones.size(); + } + return size; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return zones.get(index); + } + + /* + * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) + */ + @Override + public int indexOf(Object element) { + return zones.indexOf(element); + } +} Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties =================================================================== --- trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties 2010-11-10 16:47:00 UTC (rev 202) @@ -116,6 +116,7 @@ coser.ui.selection.invalidFusionName=Selection fusion name not found in referential \! coser.ui.selection.maturitySpecies=L4 \: Species with maturity coser.ui.selection.occurenceDensitySpecies=L2 \: Filtered species +coser.ui.selection.occurrencedensityrenderer=<html>%s<span style\='font-size\:85%%;color\:gray;'>(Occ\=%.2f, Dens\=%.2f)</span></html> coser.ui.selection.saveError=Save error coser.ui.selection.sizeAllYearSpecies=L3 \: Species with size all year coser.ui.selection.speciesMenuFusion=Merge Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties =================================================================== --- trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties 2010-11-10 14:06:17 UTC (rev 201) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties 2010-11-10 16:47:00 UTC (rev 202) @@ -116,6 +116,7 @@ coser.ui.selection.invalidFusionName=Le nom de fusion choisit n'est pas pr\u00E9sent de le r\u00E9f\u00E9rentiel \! coser.ui.selection.maturitySpecies=L4 \: Esp\u00E8ces avec maturit\u00E9 coser.ui.selection.occurenceDensitySpecies=L2 \: Esp\u00E8ces filtr\u00E9es +coser.ui.selection.occurrencedensityrenderer=<html>%s<span style\='font-size\:85%%;color\:gray;'>(Occ\=%.2f, Dens\=%.2f)</span></html> coser.ui.selection.saveError=Erreur de sauvegarde coser.ui.selection.sizeAllYearSpecies=L3 \: Esp\u00E8ces avec taille pour toutes les ann\u00E9es coser.ui.selection.speciesMenuFusion=Fusion