branch feature/8117 created (now 4c8e90b)
This is an automated email from the git hooks/post-receive script. New change to branch feature/8117 in repository tutti. See http://git.codelutin.com/tutti.git at 4c8e90b mettre l'axe des y du graph poids moyens en gramme et préciser l'unité sur l'axe des x (fixes #8117) This branch includes the following new commits: new 4c8e90b mettre l'axe des y du graph poids moyens en gramme et préciser l'unité sur l'axe des x (fixes #8117) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 4c8e90b43964e0a2935d0def7a29ffd656a2b92c Author: Kevin Morin <morin@codelutin.com> Date: Mon Mar 14 17:07:20 2016 +0100 mettre l'axe des y du graph poids moyens en gramme et préciser l'unité sur l'axe des x (fixes #8117) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/8117 in repository tutti. See http://git.codelutin.com/tutti.git commit 4c8e90b43964e0a2935d0def7a29ffd656a2b92c Author: Kevin Morin <morin@codelutin.com> Date: Mon Mar 14 17:07:20 2016 +0100 mettre l'axe des y du graph poids moyens en gramme et préciser l'unité sur l'axe des x (fixes #8117) --- .../java/fr/ifremer/tutti/type/WeightUnit.java | 6 +++++ .../frequency/SpeciesFrequencyTableModel.java | 13 ++++++++--- .../frequency/SpeciesFrequencyUIHandler.java | 27 ++++++++++++++++------ .../species/frequency/SpeciesFrequencyUIModel.java | 6 ++++- 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/type/WeightUnit.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/type/WeightUnit.java index c493375..f56b5cb 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/type/WeightUnit.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/type/WeightUnit.java @@ -24,6 +24,7 @@ package fr.ifremer.tutti.type; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; +import java.util.Objects; import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; @@ -129,6 +130,11 @@ public enum WeightUnit { */ public abstract Float toEntity(Float weight); + public Float convertWeight(Float weight, WeightUnit weightUnit) { + Objects.requireNonNull(weightUnit); + return fromEntity(weightUnit.toEntity(weight)); + } + public String decorateLabel(String label) { return String.format("%s (%s)", label, getShortLabel()); } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java index 3fdaecc..c6d9b67 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java @@ -71,6 +71,8 @@ public class SpeciesFrequencyTableModel extends AbstractApplicationTableModel<Sp */ protected final WeightUnit weightUnit; + protected final WeightUnit individualObservationWeightUnit; + protected transient PropertyChangeListener onLengthStepChangedListener; protected transient PropertyChangeListener onWeightChangedListener; @@ -82,10 +84,12 @@ public class SpeciesFrequencyTableModel extends AbstractApplicationTableModel<Sp protected final XYSeries averageWeightsSeries; public SpeciesFrequencyTableModel(WeightUnit weightUnit, + WeightUnit individualObservationWeightUnit, TableColumnModelExt columnModel, SpeciesFrequencyUIModel uiModel) { super(columnModel, true, true); this.weightUnit = weightUnit; + this.individualObservationWeightUnit = individualObservationWeightUnit; this.uiModel = uiModel; this.modelCache = uiModel.cache; this.frequenciesSeries = uiModel.frequenciesDataset.getSeries(0); @@ -266,7 +270,8 @@ public class SpeciesFrequencyTableModel extends AbstractApplicationTableModel<Sp if (row.withNumber()) { frequenciesSeries.addOrUpdate(newValue, row.getNumber()); - averageWeightsSeries.addOrUpdate(newValue, row.computeAverageWeight()); + Float weight = individualObservationWeightUnit.convertWeight(row.computeAverageWeight(), weightUnit); + averageWeightsSeries.addOrUpdate(newValue, weight); } @@ -316,7 +321,8 @@ public class SpeciesFrequencyTableModel extends AbstractApplicationTableModel<Sp } else { frequenciesSeries.addOrUpdate(lengthStep, row.getNumber()); - averageWeightsSeries.addOrUpdate(lengthStep, row.computeAverageWeight()); + Float weight = individualObservationWeightUnit.convertWeight(row.computeAverageWeight(), weightUnit); + averageWeightsSeries.addOrUpdate(lengthStep, weight); } @@ -357,7 +363,8 @@ public class SpeciesFrequencyTableModel extends AbstractApplicationTableModel<Sp } else { - averageWeightsSeries.addOrUpdate(lengthStep, row.computeAverageWeight()); + Float weight = individualObservationWeightUnit.convertWeight(row.computeAverageWeight(), weightUnit); + averageWeightsSeries.addOrUpdate(lengthStep, weight); } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java index 393c4e9..c240595 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java @@ -382,7 +382,10 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci List<Caracteristic> defaultCaracteristic = getDataContext().getDefaultIndividualObservationCaracteristics(); - SpeciesFrequencyUIModel model = new SpeciesFrequencyUIModel(weightUnit, sampleCategoryModel, defaultCaracteristic); + SpeciesFrequencyUIModel model = new SpeciesFrequencyUIModel(weightUnit, + getConfig().getIndividualObservationWeightUnit(), + sampleCategoryModel, + defaultCaracteristic); this.ui.setContextValue(model); @@ -457,8 +460,10 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci float step1 = getStep(newValue); model.setStep(step1); model.setDataSetIntervalWidth(step1); + frequenciesChart.getXYPlot().getDomainAxis().setStandardTickUnits(new TuttiNumberTickUnitSource(step1 == 1f)); averageWeightsChart.getXYPlot().getDomainAxis().setStandardTickUnits(new TuttiNumberTickUnitSource(step1 == 1f)); + if (CollectionUtils.isNotEmpty(getModel().getRows())) { for (SpeciesFrequencyRowModel rowModel : getModel().getRows()) { rowModel.setLengthStepCaracteristic(newValue); @@ -490,12 +495,16 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci getUI().getRafaleStepLabel().setToolTipText(getLabelWithUnit(t("tutti.editSpeciesFrequencies.field.rafaleStep.tip"), unit)); TableColumnExt column = (TableColumnExt) getUI().getTable().getColumn(SpeciesFrequencyTableModel.LENGTH_STEP); - column.setHeaderValue(getLabelWithUnit(t("tutti.editSpeciesFrequencies.table.header.lengthStep"), unit)); - column.setToolTipText(getLabelWithUnit(t("tutti.editSpeciesFrequencies.table.header.lengthStep"), unit)); + String lengthStepLabelWithUnit = getLabelWithUnit(t("tutti.editSpeciesFrequencies.table.header.lengthStep"), unit); + column.setHeaderValue(lengthStepLabelWithUnit); + column.setToolTipText(lengthStepLabelWithUnit); column = (TableColumnExt) getUI().getObsTable().getColumn(IndividualObservationBatchTableModel.SIZE); column.setHeaderValue(getLabelWithUnit(t("tutti.editIndividualObservationBatch.table.header.size"), unit)); column.setToolTipText(getLabelWithUnit(t("tutti.editIndividualObservationBatch.table.header.size"), unit)); + + frequenciesChart.getXYPlot().getDomainAxis().setLabel(lengthStepLabelWithUnit); + averageWeightsChart.getXYPlot().getDomainAxis().setLabel(lengthStepLabelWithUnit); }); // when configuration mode change, let's focus the best component (see http://forge.codelutin.com/issues/4035) @@ -965,7 +974,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci SpeciesFrequencyRowModel row = getRowForLengthstep(lengthStep); // conversion de poids - weight = weightUnit.fromEntity(getConfig().getIndividualObservationWeightUnit().toEntity(weight)); + weight = weightUnit.convertWeight(weight, getConfig().getIndividualObservationWeightUnit()); row.addToWeight(weight); if (Weights.isNullOrZero(row.getWeight())) { @@ -1021,7 +1030,10 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci } // create table model - SpeciesFrequencyTableModel tableModel = new SpeciesFrequencyTableModel(weightUnit, columnModel, getModel()); + SpeciesFrequencyTableModel tableModel = new SpeciesFrequencyTableModel(weightUnit, + getConfig().getIndividualObservationWeightUnit(), + columnModel, + getModel()); table.setModel(tableModel); table.setColumnModel(columnModel); @@ -1123,7 +1135,8 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci protected void initAverageWeightsHistogram() { averageWeightsChart = ChartFactory.createXYLineChart(null, t("tutti.editSpeciesFrequencies.table.header.lengthStep"), - weightUnit.decorateLabel(t("tutti.editSpeciesFrequencies.averageWeight.label")), + getConfig().getIndividualObservationWeightUnit() + .decorateLabel(t("tutti.editSpeciesFrequencies.averageWeight.label")), getModel().averageWeightsDataset); averageWeightsChart.clearSubtitles(); @@ -1569,7 +1582,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci Float weight = obsRow.getWeight(); if (CopyIndividualObservationMode.ALL == copyMode && weight != null) { // conversion de poids - weight = weightUnit.fromEntity(individualObservationWeightUnit.toEntity(weight)); + weight = weightUnit.convertWeight(weight, individualObservationWeightUnit); row.addToWeight(weight); } } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java index 3ddc475..e35ede7 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java @@ -232,6 +232,8 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa */ protected final WeightUnit weightUnit; + protected final WeightUnit individualObservationWeightUnit; + /** * To store all caches used by the screen * @@ -292,10 +294,12 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa protected boolean rowComputationInProgress; public SpeciesFrequencyUIModel(WeightUnit weightUnit, + WeightUnit individualObservationWeightUnit, SampleCategoryModel sampleCategoryModel, List<Caracteristic> defaultCaracteristic) { super(SpeciesBatchRowModel.class, null, null); this.weightUnit = weightUnit; + this.individualObservationWeightUnit = individualObservationWeightUnit; this.sampleCategoryModel = sampleCategoryModel; this.totalComputedOrNotWeight.addPropagateListener(PROPERTY_TOTAL_WEIGHT, this); setEmptyRows(Sets.<SpeciesFrequencyRowModel>newHashSet()); @@ -343,7 +347,7 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa frequenciesSeries.addOrUpdate(lengthStep, number); - Float averageWeight = row.computeAverageWeight(); + Float averageWeight = individualObservationWeightUnit.convertWeight(row.computeAverageWeight(), weightUnit); if (averageWeight != null) { averageWeightsSeries.addOrUpdate(lengthStep, averageWeight); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm