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 fba7db58a0f2951fdaaebf99377040ccc7206b56 Author: Kevin Morin <morin@codelutin.com> Date: Tue Jan 27 16:57:52 2015 +0100 refs #6540 --- tutti-ui-swing-updater/pom.xml | 13 ---- .../operation/catches/EditCatchesUIHandler.java | 72 ++++++++++++++++------ 2 files changed, 52 insertions(+), 33 deletions(-) diff --git a/tutti-ui-swing-updater/pom.xml b/tutti-ui-swing-updater/pom.xml index dae37b6..8519855 100644 --- a/tutti-ui-swing-updater/pom.xml +++ b/tutti-ui-swing-updater/pom.xml @@ -5,18 +5,6 @@ Copyright (C) 2013 - 2014 Ifremer %% This program is free software: you can redistribute it and/or modify -<<<<<<< HEAD it under the terms of the GNU Affero 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 Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses />. -======= 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. @@ -29,7 +17,6 @@ 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>. ->>>>>>> refs/heads/master #L% --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java index e539f7f..26c7ae6 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java @@ -49,8 +49,8 @@ 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.svg.GVTTreeBuilderAdapter; -import org.apache.batik.swing.svg.GVTTreeBuilderEvent; +import org.apache.batik.swing.gvt.GVTTreeRendererAdapter; +import org.apache.batik.swing.gvt.GVTTreeRendererEvent; import org.apache.batik.util.RunnableQueue; import org.apache.batik.util.XMLResourceDescriptor; import org.apache.commons.beanutils.BeanUtils; @@ -246,9 +246,10 @@ public class EditCatchesUIHandler extends AbstractTuttiTabContainerUIHandler<Edi canvas.setRecenterOnResize(true); - canvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() { - public void gvtBuildCompleted(GVTTreeBuilderEvent e) { - + canvas.addGVTTreeRendererListener(new GVTTreeRendererAdapter() { + @Override + public void gvtRenderingCompleted(GVTTreeRendererEvent gvtTreeRendererEvent) { + log.info("gvtRenderingCompleted"); TuttiConfiguration config = getConfig(); WeightUnit catchWeightUnit = WeightUnit.KG; WeightUnit speciesWeightUnit = config.getSpeciesWeightUnit(); @@ -306,9 +307,19 @@ public class EditCatchesUIHandler extends AbstractTuttiTabContainerUIHandler<Edi } })); - initSvgField(CatchBatch.PROPERTY_SPECIES_TOTAL_COMPUTED_WEIGHT, speciesWeightUnit); - initSvgField(CatchBatch.PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT, benthosWeightUnit); - initSvgField(CatchBatch.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT, model.getMarineLitterTotalComputedOrNotWeight(), marineLitterWeightUnit); + initSvgField(CatchBatch.PROPERTY_SPECIES_TOTAL_COMPUTED_WEIGHT, + speciesWeightUnit, + CatchBatch.PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT); + initSvgField(CatchBatch.PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT, + benthosWeightUnit, + CatchBatch.PROPERTY_SPECIES_TOTAL_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT); + initSvgField(CatchBatch.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT, + model.getMarineLitterTotalComputedOrNotWeight(), + marineLitterWeightUnit, + CatchBatch.PROPERTY_SPECIES_TOTAL_COMPUTED_WEIGHT, + CatchBatch.PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT); model.addPropertyChangeListener(new RatioPropertyChangeListener("ratioSpeciesSampleSortedOverSpeciesSortedWeightLabel", CatchBatch.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT, @@ -357,13 +368,14 @@ public class EditCatchesUIHandler extends AbstractTuttiTabContainerUIHandler<Edi }); } - protected void initSvgField(String property, WeightUnit weightUnit) { - initSvgField(property, null, weightUnit); + protected void initSvgField(String property, WeightUnit weightUnit, String... idsInGroup) { + initSvgField(property, null, weightUnit, idsInGroup); } protected void initSvgField(final String property, final ComputableData<Float> computableData, - final WeightUnit weightUnit) { + final WeightUnit weightUnit, + final String... idsInGroup) { if (log.isDebugEnabled()) { log.debug("init " + property + " field"); @@ -388,11 +400,21 @@ public class EditCatchesUIHandler extends AbstractTuttiTabContainerUIHandler<Edi labelElement.setTextContent(weightUnit.decorateLabel(t("tutti.editCatchBatch.field." + property))); bbox = labelTextElem.getBBox(); float labelX = bbox.getX(); - float width = Math.abs(x - labelX); + float width = Math.abs(x - labelX) + 10; + + SVGOMRectElement labelRectElement = (SVGOMRectElement) svgDocument.getElementById(property + "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)); - Element labelRectElement = svgDocument.getElementById(property + "LabelRect"); - labelRectElement.setAttribute("width", Float.toString(width + 10)); - 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)); + } + } } }); @@ -400,7 +422,7 @@ public class EditCatchesUIHandler extends AbstractTuttiTabContainerUIHandler<Edi if (computableData == null) { // computed data value - OnDataOrComputedDataValueChangedListener listener = new OnDataOrComputedDataValueChangedListener(property, weightUnit, true, canvas, svgDocument, colorComputedWeights); + OnDataOrComputedDataValueChangedListener listener = new OnDataOrComputedDataValueChangedListener(property, weightUnit, true, canvas, svgDocument, colorComputedWeights, idsInGroup); getModel().addPropertyChangeListener(property, listener); } else { @@ -410,7 +432,7 @@ public class EditCatchesUIHandler extends AbstractTuttiTabContainerUIHandler<Edi EventTarget target = (EventTarget) element; target.addEventListener("click", new OnValueClickListener(computableData, property, weightUnit), false); - OnDataOrComputedDataValueChangedListener listener = new OnDataOrComputedDataValueChangedListener(property, weightUnit, false, canvas, svgDocument, colorComputedWeights); + OnDataOrComputedDataValueChangedListener listener = new OnDataOrComputedDataValueChangedListener(property, weightUnit, false, canvas, svgDocument, colorComputedWeights, idsInGroup); computableData.addPropertyChangeListener(listener); } } @@ -987,18 +1009,21 @@ public class EditCatchesUIHandler extends AbstractTuttiTabContainerUIHandler<Edi private final WeightUnit weightUnit; private final boolean onlyReactOnComputedData; private final Color colorComputedWeights; + private final String[] idsInGroup; public OnDataOrComputedDataValueChangedListener(String property, WeightUnit weightUnit, boolean onlyReactOnComputedData, JSVGCanvas canvas, Document svgDocument, - Color colorComputedWeights) { + Color colorComputedWeights, + String... idsInGroup) { super(canvas, svgDocument); this.property = property; this.weightUnit = weightUnit; this.onlyReactOnComputedData = onlyReactOnComputedData; this.colorComputedWeights = colorComputedWeights; + this.idsInGroup = idsInGroup; } @Override @@ -1068,8 +1093,15 @@ public class EditCatchesUIHandler extends AbstractTuttiTabContainerUIHandler<Edi SVGRect bbox = textElem.getBBox(); if (bbox != null) { float width = bbox.getWidth() + 15; - Element rectElement = svgDocument.getElementById(property + "Rect"); - rectElement.setAttribute("width", Float.toString(width)); + SVGOMRectElement rectElement = (SVGOMRectElement) svgDocument.getElementById(property + "Rect"); + 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)); + } + } } } }); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.