From acb0dfa6b7c383138fe773dae278c4380acb8098 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20DAVID?= Date: Fri, 21 Mar 2014 16:54:42 +0100 Subject: [PATCH] Xcos: delay the updateLabel operation after loading This operation recursed on all child diagrams whereas the first level (root diagram and first child) is sufficient while loading the diagram. Change-Id: I7d3d5940686adce244379c16567fc9e1ff312317 --- .../modules/xcos/io/scicos/DiagramElement.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/DiagramElement.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/DiagramElement.java index 763780e..e8ed295 100644 --- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/DiagramElement.java +++ b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/DiagramElement.java @@ -162,7 +162,7 @@ public final class DiagramElement extends AbstractElement { } // Fill the diag - decodeDiagram(diag); + decodeDiagram(diag, validate); diag.getModel().endUpdate(); diag = afterDecode(element, diag); @@ -198,10 +198,11 @@ public final class DiagramElement extends AbstractElement { * * @param diag * the current diagram + * @param validate if true, enable graphic updates ; false disable them * @throws ScicosFormatException * on decoding error */ - private void decodeDiagram(XcosDiagram diag) throws ScicosFormatException { + private void decodeDiagram(XcosDiagram diag, boolean validate) throws ScicosFormatException { // Fill the local parameters // NOTE: the title field is checked on the ScicosParametersElement final String title = ((ScilabString) ((ScilabTList) base.get(1)).get(2)).getData()[0][0]; @@ -214,7 +215,7 @@ public final class DiagramElement extends AbstractElement { // Decode the objs attributes decodeObjs(diag); // Update the objs properties if applicable - updateObjs(diag); + updateObjs(diag, validate); } /** @@ -290,8 +291,9 @@ public final class DiagramElement extends AbstractElement { * * @param diag * the diagram to update + * @param validate perform graphic updates, or not */ - private void updateObjs(final XcosDiagram diag) { + private void updateObjs(final XcosDiagram diag, boolean validate) { final mxGraphModel model = (mxGraphModel) diag.getModel(); final double minY = -minimalYaxisValue + V_MARGIN; @@ -299,7 +301,9 @@ public final class DiagramElement extends AbstractElement { for (final Object cell : model.getCells().values()) { updateMinimalSize(cell, model); translate(cell, model, minX, minY); - updateLabels(cell, model); + if (validate) { + updateLabels(cell, model); + } } } -- 1.7.9.5