branch develop updated (59d71e5 -> afa891c)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository tutti. See http://git.codelutin.com/tutti.git from 59d71e5 fixes #6629 new d6462e1 refs #6471 new 8ff602d ajout d'une couleur dans la configuration pour les macro-decehts dans l'écran de résumé des captures new afa891c fixes #6630 (ajout d'une nouvelle couleur pour les macro-déchets + changement des libellés fixes #6636 Report des actions et suppression de l'ancien code The 3 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 afa891ceacc67b4d11e13f18828b75ce65ed8bb9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Feb 10 16:00:57 2015 +0100 fixes #6630 (ajout d'une nouvelle couleur pour les macro-déchets + changement des libellés fixes #6636 Report des actions et suppression de l'ancien code commit 8ff602d1c6e4cc2ea7a9619f041e2c4eeb6bda56 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Feb 10 16:00:21 2015 +0100 ajout d'une couleur dans la configuration pour les macro-decehts dans l'écran de résumé des captures commit d6462e12c3d27f69860010c5b37f9e007665d3b5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Feb 10 14:30:05 2015 +0100 refs #6471 Summary of changes: .../java/fr/ifremer/tutti/TuttiConfiguration.java | 4 + .../fr/ifremer/tutti/TuttiConfigurationOption.java | 13 +- .../i18n/tutti-persistence_en_GB.properties | 1 + .../i18n/tutti-persistence_fr_FR.properties | 9 +- .../service/bigfin/csv/BigfinDataRowModel.java | 2 + .../swing/content/config/TuttiConfigUIHandler.java | 3 + .../operation/catches/EditCatchesSvgHandler.java | 735 +++++++++++++++++++++ .../resources/i18n/tutti-ui-swing_fr_FR.properties | 11 +- 8 files changed, 766 insertions(+), 12 deletions(-) create mode 100644 tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesSvgHandler.java -- 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 develop in repository tutti. See http://git.codelutin.com/tutti.git commit d6462e12c3d27f69860010c5b37f9e007665d3b5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Feb 10 14:30:05 2015 +0100 refs #6471 --- .../java/fr/ifremer/tutti/service/bigfin/csv/BigfinDataRowModel.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/csv/BigfinDataRowModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/csv/BigfinDataRowModel.java index 6c378ef..a11c2a7 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/csv/BigfinDataRowModel.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/csv/BigfinDataRowModel.java @@ -67,6 +67,8 @@ public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<Bi newIgnoredColumn("GPS Y"); + newIgnoredColumn("SP CODE"); + // code espèce = code campagne (saisie libre donc risque fort de mauvaise saisie) newMandatoryColumn("SPEC", BigfinDataRow.PROPERTY_SPECIES_OR_SPECIES_BATCH, new SpeciesOrSpeciesBatchValueParser(speciesBySurveyCode, speciesBatchesById)); -- 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 develop in repository tutti. See http://git.codelutin.com/tutti.git commit 8ff602d1c6e4cc2ea7a9619f041e2c4eeb6bda56 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Feb 10 16:00:21 2015 +0100 ajout d'une couleur dans la configuration pour les macro-decehts dans l'écran de résumé des captures --- .../src/main/java/fr/ifremer/tutti/TuttiConfiguration.java | 4 ++++ .../java/fr/ifremer/tutti/TuttiConfigurationOption.java | 13 ++++++++++--- .../main/resources/i18n/tutti-persistence_en_GB.properties | 1 + .../main/resources/i18n/tutti-persistence_fr_FR.properties | 9 +++++---- .../tutti/ui/swing/content/config/TuttiConfigUIHandler.java | 3 +++ .../src/main/resources/i18n/tutti-ui-swing_fr_FR.properties | 11 ++++++----- 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java index 11cdffa..247be13 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java @@ -612,6 +612,10 @@ public class TuttiConfiguration extends ApplicationConfiguration { return applicationConfig.getOptionAsColor(TuttiConfigurationOption.COLOR_BENTHOS.getKey()); } + public Color getColorMarineLitter() { + return applicationConfig.getOptionAsColor(TuttiConfigurationOption.COLOR_MARINE_LITTER.getKey()); + } + @Override public KeyStroke getShortcutClosePopup() { return applicationConfig.getOptionAsKeyStroke(TuttiConfigurationOption.SHORTCUT_CLOSE_POPUP.getKey()); diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java index c83c413..bb57280 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java @@ -456,7 +456,7 @@ public enum TuttiConfigurationOption implements ConfigOptionDef { COLOR_CATCH( "tutti.ui.color.catch", n("tutti.config.option.ui.color.catch.description"), - Color.decode("#888888").toString(), + new Color(136,136,136).toString(), Color.class, false ), @@ -464,7 +464,7 @@ public enum TuttiConfigurationOption implements ConfigOptionDef { COLOR_SPECIES( "tutti.ui.color.species", n("tutti.config.option.ui.color.species.description"), - Color.decode("#006BBA").toString(), + new Color(0, 107, 186).toString(), Color.class, false ), @@ -472,7 +472,14 @@ public enum TuttiConfigurationOption implements ConfigOptionDef { COLOR_BENTHOS( "tutti.ui.color.benthos", n("tutti.config.option.ui.color.benthos.description"), - Color.decode("#FF7F2A").toString(), + new Color(255, 127, 42).toString(), + Color.class, + false + ), + COLOR_MARINE_LITTER( + "tutti.ui.color.marineLitter", + n("tutti.config.option.ui.color.marineLitter.description"), + new Color(255, 229, 23).toString(), Color.class, false ), diff --git a/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties b/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties index 3bc4920..71533a6 100644 --- a/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties +++ b/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties @@ -55,6 +55,7 @@ tutti.config.option.ui.color.blockingLayer.description= tutti.config.option.ui.color.catch.description= tutti.config.option.ui.color.cellWithValue.description= tutti.config.option.ui.color.computedWeights.description= +tutti.config.option.ui.color.marineLitter.description= tutti.config.option.ui.color.rowInvalid.description= tutti.config.option.ui.color.rowReadOnly.description= tutti.config.option.ui.color.rowToConfirm.description= diff --git a/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties b/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties index 22da3f4..ecd60d9 100644 --- a/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties +++ b/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties @@ -3,7 +3,7 @@ application.common.unit.g=Gramme application.common.unit.kg=Kilogramme application.common.unit.short.g=g application.common.unit.short.kg=kg -tutti.config= +tutti.config=Configuration d'Allegro Campagne tutti.config.option.basedir.description=Répertoire principale tutti.config.option.cruiseId.description=Identifiant de la dernière campagne utilisée tutti.config.option.csv.separator.description=Caractère séparateur pour les import / export de fichier au format csv. @@ -46,16 +46,17 @@ tutti.config.option.tremieCarousselVessel.description=Navire ayant un carrousel tutti.config.option.ui.adminPassword.description=MD5 du mot de passe des zones sensibles tutti.config.option.ui.autoPopupNumberEditor.description=Toujours afficher le pavé numérique lors de l'édition d'un nombre tutti.config.option.ui.color.alternateRow.description=Couleur de fond des lignes paires (non sélectionnée) dans un tableau -tutti.config.option.ui.color.benthos.description= +tutti.config.option.ui.color.benthos.description=Couleur pour représenter le benthos dans l'écran de résumé des captures tutti.config.option.ui.color.blockingLayer.description=Couleur utilisée pour bloquer l'interface lors d'une action longue -tutti.config.option.ui.color.catch.description= +tutti.config.option.ui.color.catch.description=Couleur pour représenter les captures dans l'écran de résumé des captures tutti.config.option.ui.color.cellWithValue.description=Couleur d'une cellule avec des données tutti.config.option.ui.color.computedWeights.description=Couleur des données calculées +tutti.config.option.ui.color.marineLitter.description=Couleur pour représenter les macro-déchets dans l'écran de résumé des captures tutti.config.option.ui.color.rowInvalid.description=Ligne invalide tutti.config.option.ui.color.rowReadOnly.description=Cellule non éditable tutti.config.option.ui.color.rowToConfirm.description=Ligne à confirmer tutti.config.option.ui.color.selectedRow.description=Couleur de fond d'une ligne sélectionnée dans un tableau -tutti.config.option.ui.color.species.description= +tutti.config.option.ui.color.species.description=Couleur pour représenter les espèces dans l'écran de résumé des captures tutti.config.option.ui.config.file.description=Chemin du fichier de configuration des interfaces graphiques tutti.config.option.ui.coordinateEditorType.description=Type de l'éditeur de coordonnées tutti.config.option.ui.dateFormat.description=Format de dates diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java index 066cc62..f0a1e28 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java @@ -196,6 +196,9 @@ public class TuttiConfigUIHandler extends AbstractTuttiUIHandler<TuttiUIContext, .addOption(TuttiConfigurationOption.COLOR_BENTHOS) .setOptionShortLabel(t("tutti.config.option.ui.color.benthos.shortLabel")) + .addOption(TuttiConfigurationOption.COLOR_MARINE_LITTER) + .setOptionShortLabel(t("tutti.config.option.ui.color.marineLitter.shortLabel")) + .addOption(TuttiConfigurationOption.DATE_FORMAT) .setOptionShortLabel(t("tutti.config.option.ui.dateFormat.shortLabel")) diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties index 23f1677..ef484ec 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties @@ -130,16 +130,17 @@ tutti.config.option.site.url.shortLabel=URL du site technique tutti.config.option.tmp.directory.shortLabel=Répertoire temporaire tutti.config.option.tremieCarousselVessel.shortLabel=Navire ayant un carrousel et une trémie tutti.config.option.ui.color.alternateRow.shortLabel=Couleur alternée -tutti.config.option.ui.color.benthos.shortLabel=Couleur des libellés de benthos +tutti.config.option.ui.color.benthos.shortLabel=Couleur des libellés de benthos (Écran Capture > Résumé) +tutti.config.option.ui.color.marineLitter.shortLabel=Couleur des libellés de macro-déchets (Écran Capture > Résumé) tutti.config.option.ui.color.blockingLayer.shortLabel=Couleur d'attente -tutti.config.option.ui.color.catch.shortLabel=Couleur des libellés de capture +tutti.config.option.ui.color.catch.shortLabel=Couleur des libellés de capture (Écran Capture > Résumé) tutti.config.option.ui.color.cellWithValue.shortLabel=Couleur cellule avec donnée tutti.config.option.ui.color.computedWeights.shortLabel=Couleur de valeur calculée tutti.config.option.ui.color.rowInvalid.shortLabel=Couleur d'une ligne invalide tutti.config.option.ui.color.rowReadOnly.shortLabel=Couleur d'une cellule en lecture seule tutti.config.option.ui.color.rowToConfirm.shortLabel=Couleur d'une espèce à confirmer tutti.config.option.ui.color.selectedRow.shortLabel=Couleur d'une ligne sélectionnée -tutti.config.option.ui.color.species.shortLabel=Couleur des libellés d'espèces +tutti.config.option.ui.color.species.shortLabel=Couleur des libellés d'espèces (Écran Capture > Résumé) tutti.config.option.ui.config.file.shortLabel=Chemin du fichier de confirmation tutti.config.option.ui.coordinateEditorType.shortLabel=Formateur de coordonnées tutti.config.option.ui.dateFormat.shortLabel=Format des dates @@ -591,7 +592,7 @@ tutti.editCatchBatch.action.saveCatchBatch.mnemonic=S tutti.editCatchBatch.action.saveCatchBatch.tip=Enregistrer la capture tutti.editCatchBatch.askCancelEditBeforeLeaving.cancelEditCatchBatch=La capture n'est pas valide et ne peut pas être enregistrée tutti.editCatchBatch.askSaveBeforeLeaving.saveCatchBatch=Des modifications sur la capture n'ont pas été enregistrées -tutti.editCatchBatch.field.benthosDistinctSortedSpeciesCount=Nombre d'espèces \: +tutti.editCatchBatch.field.benthosDistinctSortedSpeciesCount=Nombre de taxons \: tutti.editCatchBatch.field.benthosTotalComputedWeight=Total Benthos tutti.editCatchBatch.field.benthosTotalSampleSortedComputedWeight=Vrac observé tutti.editCatchBatch.field.benthosTotalSampleSortedWeight=Poids VRAC trié @@ -620,7 +621,7 @@ tutti.editCatchBatch.field.catchTotalWeight=CAPTURE TOTALE tutti.editCatchBatch.field.catchTotalWeight.tip=Poids total de la capture (sauf macro déchets et captures accidentelles) tutti.editCatchBatch.field.marineLitterTotalWeight=Total macrodéchets tutti.editCatchBatch.field.marineLitterTotalWeight.tip=Poids total des macro déchets dans la capture -tutti.editCatchBatch.field.speciesDistinctSortedSpeciesCount=Nombre d'espèces \: +tutti.editCatchBatch.field.speciesDistinctSortedSpeciesCount=Nombre de taxons \: tutti.editCatchBatch.field.speciesOrBenthosTotalWeight.not.computed=poids non calculable dans ce contexte tutti.editCatchBatch.field.speciesTotalComputedWeight=Total Espèces tutti.editCatchBatch.field.speciesTotalSampleSortedComputedWeight=Vrac observé -- 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 develop in repository tutti. See http://git.codelutin.com/tutti.git commit afa891ceacc67b4d11e13f18828b75ce65ed8bb9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Feb 10 16:00:57 2015 +0100 fixes #6630 (ajout d'une nouvelle couleur pour les macro-déchets + changement des libellés fixes #6636 Report des actions et suppression de l'ancien code --- .../operation/catches/EditCatchesSvgHandler.java | 735 +++++++++++++++++++++ 1 file changed, 735 insertions(+) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesSvgHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesSvgHandler.java new file mode 100644 index 0000000..e31ce1f --- /dev/null +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesSvgHandler.java @@ -0,0 +1,735 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches; + +import com.google.common.base.Function; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import com.google.common.collect.Sets; +import fr.ifremer.tutti.TuttiConfiguration; +import fr.ifremer.tutti.persistence.entities.data.CatchBatch; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.type.WeightUnit; +import fr.ifremer.tutti.ui.swing.TuttiUIContext; +import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; +import fr.ifremer.tutti.ui.swing.util.catches.EnterWeightUI; +import fr.ifremer.tutti.ui.swing.util.computable.ComputableData; +import fr.ifremer.tutti.util.Numbers; +import fr.ifremer.tutti.util.Weights; +import jaxx.runtime.JAXXUtil; +import org.apache.batik.dom.svg.SAXSVGDocumentFactory; +import org.apache.batik.dom.svg.SVGOMRectElement; +import org.apache.batik.dom.svg.SVGOMTextElement; +import org.apache.batik.swing.JSVGCanvas; +import org.apache.batik.swing.gvt.GVTTreeRendererAdapter; +import org.apache.batik.swing.gvt.GVTTreeRendererEvent; +import org.apache.batik.swing.svg.SVGUserAgentAdapter; +import org.apache.batik.util.XMLResourceDescriptor; +import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.Resource; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.css.CSSStyleDeclaration; +import org.w3c.dom.events.EventListener; +import org.w3c.dom.events.EventTarget; +import org.w3c.dom.svg.SVGRect; +import org.w3c.dom.svg.SVGStylable; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.IOException; +import java.net.URL; +import java.util.Objects; +import java.util.Set; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +/** + * Created on 2/10/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 3.13 + */ +public class EditCatchesSvgHandler { + + /** Logger. */ + private static final Log log = LogFactory.getLog(EditCatchesSvgHandler.class); + + protected Multimap<String, PropertyChangeListener> svgRelatedPropertyChangeListeners = HashMultimap.create(); + + protected JSVGCanvas canvas; + + protected Document svgDocument; + + protected final TuttiUIContext context; + + protected final EditCatchesUI ui; + + protected final EditCatchesUIModel model; + + protected final SVGUserAgentAdapter ua = new SVGUserAgentAdapter() { + @Override + public void displayError(String message) { + if (log.isErrorEnabled()) { + log.error("Canvas error: " + message); + } + } + + @Override + public void displayError(Exception ex) { + if (log.isErrorEnabled()) { + log.error("Canvas error", ex); + } + } + }; + + public EditCatchesSvgHandler(TuttiUIContext context, EditCatchesUI ui, EditCatchesUIModel model) { + this.context = context; + this.ui = ui; + this.model = model; + } + + + { + n("tutti.editCatchBatch.field.speciesDistinctSortedSpeciesCount"); + n("tutti.editCatchBatch.field.benthosDistinctSortedSpeciesCount"); + + } + + + public void clearSVG() { + for (String property : svgRelatedPropertyChangeListeners.keySet()) { + for (PropertyChangeListener listener : svgRelatedPropertyChangeListeners.get(property)) { + if (property != null) { + model.removePropertyChangeListener(property, listener); + } else { + model.removePropertyChangeListener(listener); + } + } + } + svgRelatedPropertyChangeListeners.clear(); + + if (canvas != null) { + canvas.dispose(); + ui.getSvgCanvasPanel().remove(canvas); + } + } + + public void initResumeSvg() { + try { + String parser = XMLResourceDescriptor.getXMLParserClassName(); + SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); + URL url = Resource.getURL("EcranResume.svg"); + svgDocument = f.createDocument(url.toString()); + + // redefine user agent to avoid displaying errors about css + canvas = new JSVGCanvas(ua, true, true); + canvas.setBackground(Color.decode("#d6d9df")); + canvas.setSize(new Dimension(1, 1)); + canvas.setMySize(new Dimension(1, 1)); + + canvas.setRecenterOnResize(true); + + final TuttiConfiguration config = context.getConfig(); + + final Color catchColor = config.getColorCatch(); + final Color speciesColor = config.getColorSpecies(); + final Color benthosColor = config.getColorBenthos(); + + canvas.addGVTTreeRendererListener(new GVTTreeRendererAdapter() { + @Override + public void gvtRenderingCompleted(GVTTreeRendererEvent gvtTreeRendererEvent) { + if (log.isDebugEnabled()) { + log.debug("gvtRenderingCompleted"); + } + WeightUnit catchWeightUnit = WeightUnit.KG; + WeightUnit speciesWeightUnit = config.getSpeciesWeightUnit(); + WeightUnit benthosWeightUnit = config.getBenthosWeightUnit(); + WeightUnit marineLitterWeightUnit = config.getMarineLitterWeightUnit(); + + initSvgField(CatchBatch.PROPERTY_CATCH_TOTAL_WEIGHT, + CatchBatch.PROPERTY_CATCH_TOTAL_COMPUTED_WEIGHT, + model.getCatchTotalComputedOrNotWeight(), + catchWeightUnit, + catchColor); + + initSvgField(CatchBatch.PROPERTY_CATCH_TOTAL_SORTED_COMPUTED_WEIGHT, catchWeightUnit, catchColor); + initSvgField(CatchBatch.PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT, + CatchBatch.PROPERTY_CATCH_TOTAL_REJECTED_COMPUTED_WEIGHT, + model.getCatchTotalRejectedComputedOrNotWeight(), + catchWeightUnit, + catchColor); + initSvgField(CatchBatch.PROPERTY_CATCH_TOTAL_SORTED_SORTED_COMPUTED_WEIGHT, catchWeightUnit, catchColor); + + initSvgField(CatchBatch.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT, + CatchBatch.PROPERTY_SPECIES_TOTAL_SORTED_COMPUTED_WEIGHT, + model.getSpeciesTotalSortedComputedOrNotWeight(), + speciesWeightUnit, + speciesColor); + initSvgField(CatchBatch.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT, speciesWeightUnit, speciesColor); + + initSvgField(CatchBatch.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT, + CatchBatch.PROPERTY_BENTHOS_TOTAL_SORTED_COMPUTED_WEIGHT, + model.getBenthosTotalSortedComputedOrNotWeight(), + benthosWeightUnit, + benthosColor); + initSvgField(CatchBatch.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT, benthosWeightUnit, benthosColor); + + initSvgField(CatchBatch.PROPERTY_CATCH_TOTAL_UNSORTED_COMPUTED_WEIGHT, catchWeightUnit, catchColor); + initSvgField(CatchBatch.PROPERTY_SPECIES_TOTAL_UNSORTED_COMPUTED_WEIGHT, speciesWeightUnit, speciesColor); + initSvgField(CatchBatch.PROPERTY_BENTHOS_TOTAL_UNSORTED_COMPUTED_WEIGHT, benthosWeightUnit, benthosColor); + + addSvgRelatedPropertyChangeListener(null, new ChangeElementBackgroundColorPropertyChangeListener( + CatchBatch.PROPERTY_SPECIES_TOTAL_UNSORTED_COMPUTED_WEIGHT, + Sets.newHashSet(CatchBatch.PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT, + CatchBatch.PROPERTY_CATCH_TOTAL_REJECTED_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT, + CatchBatch.PROPERTY_SPECIES_TOTAL_SORTED_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT), + new Function<EditCatchesUIModel, Color>() { + @Override + public Color apply(EditCatchesUIModel model) { + boolean warning = model.isSpeciesTotalUnsortedComputedWeightInWarning(); + return warning ? Color.ORANGE : speciesColor; + } + })); + + addSvgRelatedPropertyChangeListener(null, new ChangeElementBackgroundColorPropertyChangeListener( + CatchBatch.PROPERTY_BENTHOS_TOTAL_UNSORTED_COMPUTED_WEIGHT, + Sets.newHashSet(CatchBatch.PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT, + CatchBatch.PROPERTY_CATCH_TOTAL_REJECTED_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT, + CatchBatch.PROPERTY_BENTHOS_TOTAL_SORTED_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT), + new Function<EditCatchesUIModel, Color>() { + @Override + public Color apply(EditCatchesUIModel model) { + boolean warning = model.isBenthosTotalUnsortedComputedWeightInWarning(); + return warning ? Color.ORANGE : benthosColor; + } + })); + + initSvgField(CatchBatch.PROPERTY_SPECIES_TOTAL_COMPUTED_WEIGHT, + speciesWeightUnit, + speciesColor, + CatchBatch.PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT); + initSvgField(CatchBatch.PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT, + benthosWeightUnit, + benthosColor, + CatchBatch.PROPERTY_SPECIES_TOTAL_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT); + initSvgField(CatchBatch.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT, + CatchBatch.PROPERTY_MARINE_LITTER_TOTAL_COMPUTED_WEIGHT, + model.getMarineLitterTotalComputedOrNotWeight(), + marineLitterWeightUnit, + catchColor, + CatchBatch.PROPERTY_SPECIES_TOTAL_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT); + + addSvgRelatedPropertyChangeListener(null, new RatioPropertyChangeListener("ratioSpeciesSampleSortedOverSpeciesSortedWeightLabel", + CatchBatch.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT, + CatchBatch.PROPERTY_SPECIES_TOTAL_SORTED_COMPUTED_WEIGHT)); + addSvgRelatedPropertyChangeListener(null, new RatioPropertyChangeListener("ratioBenthosSampleSortedOverBenthosSortedWeightLabel", + CatchBatch.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT, + CatchBatch.PROPERTY_BENTHOS_TOTAL_SORTED_COMPUTED_WEIGHT)); + addSvgRelatedPropertyChangeListener(null, new RatioPropertyChangeListener("ratioSortedSortedOverSortedWeightLabel", + CatchBatch.PROPERTY_CATCH_TOTAL_SORTED_SORTED_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_CATCH_TOTAL_SORTED_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_CATCH_TOTAL_SORTED_COMPUTED_WEIGHT)); + + initSpeciesCount(CatchBatch.PROPERTY_SPECIES_DISTINCT_SORTED_SPECIES_COUNT); + initSpeciesCount(CatchBatch.PROPERTY_BENTHOS_DISTINCT_SORTED_SPECIES_COUNT); + + initTremieCarrouselField(CatchBatch.PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT, catchWeightUnit); + initTremieCarrouselField(CatchBatch.PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT, catchWeightUnit); + + ui.getSvgCanvasPanel().add(canvas, BorderLayout.CENTER); + } + }); + + canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC); + canvas.setDocument(svgDocument); + + } catch (IOException err) { + if (log.isErrorEnabled()) { + log.error("error while initializing the resume background", err); + } + context.getErrorHelper().showErrorDialog(t("tutti.editCatchBatch.svgLoading.error"), err); + } + } + + protected void initSvgField(String computedProperty, WeightUnit weightUnit, Color bgColor, String... idsInGroup) { + initSvgField(null, computedProperty, null, weightUnit, bgColor, idsInGroup); + } + + protected void initSvgField(String property, + String computedProperty, + final ComputableData<Float> computableData, + final WeightUnit weightUnit, + final Color bgColor, + final String... idsInGroup) { + + if (log.isDebugEnabled()) { + log.debug("init " + property + " field"); + } + + final String notNullProperty = property != null ? property : computedProperty; + + OnDataOrComputedDataValueChangedListener listener = new OnDataOrComputedDataValueChangedListener(notNullProperty, computableData, weightUnit, idsInGroup); + if (property != null) { + addSvgRelatedPropertyChangeListener(property, listener); + } + if (computedProperty != null) { + addSvgRelatedPropertyChangeListener(computedProperty, listener); + } + + if (computableData != null) { + // data or computed data value + Element element = svgDocument.getElementById(property); + EventTarget target = (EventTarget) element; + target.addEventListener("click", new OnValueClickListener(computableData, property, weightUnit), false); + } + + updateOnCanvas(new Runnable() { + @Override + public void run() { + + SVGOMRectElement rectElement = (SVGOMRectElement) svgDocument.getElementById(notNullProperty + "Rect"); + SVGRect bbox = rectElement.getBBox(); + Float x = bbox.getX(); + + SVGOMTextElement labelElement = (SVGOMTextElement) svgDocument.getElementById(notNullProperty + "Label"); + CSSStyleDeclaration style = labelElement.getStyle(); + if (computableData == null) { + style.setProperty("font-style", "italic", null); + } + int colorBrightness = TuttiUIUtil.getColorBrightness(bgColor); + String textColor = colorBrightness > 150 ? "#000000" : "#FFFFFF"; + style.setProperty("fill", textColor, null); + + labelElement.setTextContent(weightUnit.decorateLabel(t("tutti.editCatchBatch.field." + notNullProperty))); + bbox = labelElement.getBBox(); + float labelX = bbox.getX(); + float width = Math.abs(x - labelX) + 10; + + SVGOMRectElement labelRectElement = (SVGOMRectElement) svgDocument.getElementById(notNullProperty + "LabelRect"); + float actualWidth = Math.abs(labelRectElement.getBBox().getX() - labelX) + 10; + + if (actualWidth < width) { + labelRectElement.setAttribute("width", Float.toString(width)); + labelRectElement.setAttribute("x", String.valueOf(labelX - 10)); + + for (String id : idsInGroup) { + Element el = svgDocument.getElementById(id + "LabelRect"); + el.setAttribute("width", Float.toString(width)); + el.setAttribute("x", String.valueOf(labelX - 10)); + } + } + + style = labelRectElement.getStyle(); + String hexaColor = "#" + Integer.toHexString(bgColor.getRGB()).substring(2); + style.setProperty("fill", hexaColor, null); + + Float value; + boolean computed; + if (computableData == null) { + computed = true; + value = getModelPropertyValue(notNullProperty); + + } else if (computableData.getData() == null) { + computed = true; + value = computableData.getComputedData(); + + } else { + computed = false; + value = computableData.getData(); + } + + updateValue(notNullProperty, value, weightUnit, computed, idsInGroup); + } + }); + + } + + protected void updateOnCanvas(Runnable runnable) { + try { + canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(runnable); + } catch (IllegalStateException e) { + if (log.isErrorEnabled()) { + log.error("error while updating canvas, reload it"); + } + clearSVG(); + initResumeSvg(); + } + } + + protected void addSvgRelatedPropertyChangeListener(String property, PropertyChangeListener listener) { + svgRelatedPropertyChangeListeners.put(property, listener); + if (property != null) { + model.addPropertyChangeListener(property, listener); + } else { + model.addPropertyChangeListener(listener); + } + } + + protected void updateValue(final String property, + final Float value, + final WeightUnit weightUnit, + final boolean computed, + final String... idsInGroup) { + + updateOnCanvas(new Runnable() { + public void run() { + if (log.isDebugEnabled()) { + log.debug("update " + property + " field"); + } + + SVGOMTextElement valueElement = (SVGOMTextElement) svgDocument.getElementById(property + "Value"); + if (valueElement == null) { + return; + } + + //TODO i18n ? + String textContent; + if (value != null) { + textContent = Weights.getWeightStringValue(value) + " " + weightUnit.getShortLabel(); + } else { + textContent = null; + } + valueElement.setTextContent(textContent); + + CSSStyleDeclaration style = valueElement.getStyle(); + + Color colorComputedWeights = context.getConfig().getColorComputedWeights(); + String computedColor = "#" + Integer.toHexString(colorComputedWeights.getRGB()).substring(2); + style.setProperty("fill", computed ? computedColor : "#000000", null); + style.setProperty("font-style", computed ? "italic" : "normal", null); + + SVGRect bbox = valueElement.getBBox(); + SVGOMRectElement rectElement = (SVGOMRectElement) svgDocument.getElementById(property + "Rect"); + if (bbox != null && rectElement != null) { + float width = bbox.getWidth() + 15; + float actualWidth = rectElement.getBBox().getWidth(); + if (actualWidth < width) { + rectElement.setAttribute("width", Float.toString(width)); + for (String id : idsInGroup) { + Element el = svgDocument.getElementById(id + "Rect"); + el.setAttribute("width", Float.toString(width)); + } + } + } + } + }); + + } + + protected Float getModelPropertyValue(String property) { + Float value; + try { + String sValue = BeanUtils.getProperty(model, property); + if (sValue != null) { + value = Float.parseFloat(sValue); + } else { + value = null; + } + + } catch (ReflectiveOperationException e) { + if (log.isErrorEnabled()) { + log.error("error on reading model's property " + property, e); + } + value = null; + } + return value; + } + + protected void initSpeciesCount(final String property) { + + if (log.isDebugEnabled()) { + log.debug("init " + property + " field"); + } + + updateOnCanvas(new Runnable() { + @Override + public void run() { + Element labelElement = svgDocument.getElementById(property + "Label"); + labelElement.setTextContent(t("tutti.editCatchBatch.field." + property)); + + Element valueElement = svgDocument.getElementById(property + "Value"); + Integer value; + try { + String sValue = BeanUtils.getProperty(model, property); + if (sValue != null) { + value = Integer.parseInt(sValue); + } else { + value = null; + } + + } catch (ReflectiveOperationException e) { + if (log.isErrorEnabled()) { + log.error("error on reading model's property " + property, e); + } + value = null; + } + valueElement.setTextContent(JAXXUtil.getStringValue(value)); + } + }); + + addSvgRelatedPropertyChangeListener(property, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Integer value = (Integer) evt.getNewValue(); + Element labelElement = svgDocument.getElementById(property + "Value"); + labelElement.setTextContent(JAXXUtil.getStringValue(value)); + } + }); + } + + protected void initTremieCarrouselField(final String property, final WeightUnit weightUnit) { + if (log.isDebugEnabled()) { + log.debug("init " + property + " field"); + } + + updateOnCanvas(new Runnable() { + @Override + public void run() { + Element labelElement = svgDocument.getElementById(property + "Label"); + labelElement.setTextContent(weightUnit.decorateLabel(t("tutti.editCatchBatch.field." + property))); + } + }); + + addSvgRelatedPropertyChangeListener(property, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Float value = (Float) evt.getNewValue(); + updateValue(property, value, weightUnit, true); + } + }); + + Float value = getModelPropertyValue(property); + updateValue(property, value, weightUnit, true); + + addSvgRelatedPropertyChangeListener(EditCatchesUIModel.PROPERTY_FISHING_OPERATION, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + updateTremieCarrouselVisibility(property); + } + }); + updateTremieCarrouselVisibility(property); + } + + + protected void updateTremieCarrouselVisibility(String property) { + FishingOperation fishingOperation = model.getFishingOperation(); + if (fishingOperation != null) { + boolean tremieCarrouselFieldsVisisble = fishingOperation.getVessel() != null + && fishingOperation.getVessel().getId().equals(context.getConfig().getTremieCarousselVesselId()); + + Element labelElement = svgDocument.getElementById(property + "Label"); + labelElement.setAttribute("visibility", tremieCarrouselFieldsVisisble ? "visible" : "hidden"); + + Element valueElement = svgDocument.getElementById(property + "Value"); + valueElement.setAttribute("visibility", tremieCarrouselFieldsVisisble ? "visible" : "hidden"); + } + } + + private class OnValueClickListener implements EventListener { + + private final ComputableData<Float> computableData; + + private final String property; + + private final WeightUnit weightUnit; + + public OnValueClickListener(ComputableData<Float> computableData, String property, WeightUnit weightUnit) { + this.computableData = computableData; + this.property = property; + this.weightUnit = weightUnit; + } + + public void handleEvent(org.w3c.dom.events.Event evt) { + log.info("element clicked"); + EnterWeightUI dialog = new EnterWeightUI(context); + Float originalWeight = computableData.getData(); + Float weight = dialog.openAndGetWeightValue(t("tutti.editCatchBatch.field." + property), + originalWeight, + weightUnit); + + if (!Objects.equals(originalWeight, weight)) { + + computableData.setData(weight); + } + } + } + + private class OnDataOrComputedDataValueChangedListener implements PropertyChangeListener { + + private final String property; + + private final ComputableData<Float> computableData; + + private final WeightUnit weightUnit; + + private final String[] idsInGroup; + + public OnDataOrComputedDataValueChangedListener(String property, + ComputableData<Float> computableData, + WeightUnit weightUnit, + String... idsInGroup) { + this.property = property; + this.computableData = computableData; + this.weightUnit = weightUnit; + this.idsInGroup = idsInGroup; + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + boolean computedData; + Float newValue; + + if (computableData == null) { + computedData = true; + newValue = (Float) evt.getNewValue(); + + } else { + if (computableData.getData() == null) { + computedData = true; + newValue = computableData.getComputedData(); + + } else { + computedData = false; + newValue = computableData.getData(); + } + } + updateValue(property, newValue, weightUnit, computedData, idsInGroup); + } + + } + + private class ChangeElementBackgroundColorPropertyChangeListener implements PropertyChangeListener { + + private final String elementId; + + private Set<String> propertiesToListen; + + private Function<EditCatchesUIModel, Color> colorFunction; + + public ChangeElementBackgroundColorPropertyChangeListener(String elementId, + Set<String> propertiesToListen, + Function<EditCatchesUIModel, Color> colorFunction) { + this.elementId = elementId; + this.propertiesToListen = propertiesToListen; + this.colorFunction = colorFunction; + + updateColor(); + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (propertiesToListen.contains(evt.getPropertyName())) { + updateColor(); + } + } + + protected void updateColor() { + updateOnCanvas(new Runnable() { + public void run() { + if (log.isDebugEnabled()) { + log.debug("update " + elementId + " field"); + } + + Element rectElement = svgDocument.getElementById(elementId + "LabelRect"); + SVGStylable field = (SVGStylable) rectElement; + CSSStyleDeclaration style = field.getStyle(); + + final Color background = colorFunction.apply(model); + String color = "#" + Integer.toHexString(background.getRGB()).substring(2); + style.setProperty("fill", color, null); + } + }); + } + } + + private class RatioPropertyChangeListener implements PropertyChangeListener { + + private final String elementId; + + private final String numeratorProperty; + + private final String denominatorProperty; + + private final String denominatorComputedProperty; + + private Integer ratio = null; + + public RatioPropertyChangeListener(String elementId, + String numeratorProperty, + String denominatorProperty, + String denominatorComputedProperty) { + this.elementId = elementId; + this.numeratorProperty = numeratorProperty; + this.denominatorProperty = denominatorProperty; + this.denominatorComputedProperty = denominatorComputedProperty; + + updateRatioText(); + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + String propertyName = evt.getPropertyName(); + + if (propertyName.equals(numeratorProperty) || propertyName.equals(denominatorProperty)) { + updateRatioText(); + } + } + + protected void updateRatioText() { + + try { + String numerator = BeanUtils.getProperty(model, numeratorProperty); + String denominator = BeanUtils.getProperty(model, denominatorProperty); + if (denominator == null) { + denominator = BeanUtils.getProperty(model, denominatorComputedProperty); + } + + if (numerator != null && denominator != null) { + Float numeratorValue = Float.valueOf(numerator); + Float denominatorValue = Float.valueOf(denominator); + + if (denominatorValue != 0) { + ratio = Numbers.roundToInt(100f * numeratorValue / denominatorValue); + } + } + + } catch (ReflectiveOperationException e) { + if (log.isErrorEnabled()) { + log.error("Error while computing the ration", e); + } + } + + updateOnCanvas(new Runnable() { + public void run() { + if (log.isDebugEnabled()) { + log.debug("update " + elementId + " field"); + } + + Element ratioElement = svgDocument.getElementById(elementId); + String textContent; + if (ratio != null) { + textContent = ratio + "%"; + } else { + textContent = null; + } + ratioElement.setTextContent(textContent); + } + }); + } + } + +} -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm