Bug 9139 fixed: Could not export too big polylines in PS/EPS 62/13162/2
Calixte DENIZET [Fri, 15 Nov 2013 14:43:03 +0000 (15:43 +0100)]
Change-Id: I344ebd960a75183decbbc3442ce906d9b31d1959

scilab/CHANGES_5.5.X
scilab/modules/graphic_export/src/java/org/scilab/modules/graphic_export/Export.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/g2d/G2DCanvas.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/g2d/motor/Motor3D.java

index df57beb..56c7a8a 100644 (file)
@@ -59,6 +59,8 @@ Scilab Bug Fixes
 
 * Bug #9110 fixed - Examples and references to other functions added in the Statistics help pages.
 
+* Bug #9139 fixed - Big polylines could not be exported in PS/EPS.
+
 * Bug #9627 fixed - Arguments checking added in optimsimplex_* functions.
 
 * Bug #9697 fixed - Printed information for optim "qn" and "gc" with bounds and imp=1 fixed.
index 3110452..0e0e620 100644 (file)
@@ -228,6 +228,7 @@ public class Export {
                 exporter.dispose();
                 exporter = null;
                 visitorsToExp.remove(visitor);
+                canvas.destroy();
             }
         } else {
             DrawerVisitor visitor = DrawerVisitor.getVisitor(uid);
@@ -253,6 +254,7 @@ public class Export {
                 }
                 DrawerVisitor.changeVisitor(figure, null);
                 GraphicController.getController().unregister(visitor);
+                canvas.destroy();
             }
         }
 
@@ -792,6 +794,15 @@ public class Export {
                     }
 
                     @Override
+                    public boolean shouldBeClipped(Shape clip, Shape s) {
+                        if (clip == null || s == null) {
+                            return false;
+                        }
+
+                        return clip.getBounds2D().intersects(s.getBounds2D());
+                    }
+
+                    @Override
                     public int processShape(Shape s) throws IOException {
                         if (s instanceof Ellipse2D.Double) {
                             Ellipse2D.Double ell = (Ellipse2D.Double) s;
@@ -898,10 +909,21 @@ public class Export {
                         gen.writeln("/ReEncode { /MyEncoding exch def exch findfont dup length dict begin {def} forall /Encoding MyEncoding def currentdict end definefont } def");
                         gen.writeln("/Helvetica /HelveticaLatin1 ISOLatin1Encoding ReEncode");
                         gen.writeln("/Times /TimesLatin1 ISOLatin1Encoding ReEncode");
+
+                        // DP macro is used to draw an array as a polyline
                         gen.writeln("/DP {/Points exch def Points 0 get Points 1 get M 2 2 Points length 1 sub {/i exch def Points i get Points i 1 add get L}for} def");
                     }
 
                     @Override
+                    public boolean shouldBeClipped(Shape clip, Shape s) {
+                        if (clip == null || s == null) {
+                            return false;
+                        }
+
+                        return clip.getBounds2D().intersects(s.getBounds2D());
+                    }
+
+                    @Override
                     public void drawString(String s, float x, float y) {
                         if (s != null && !s.isEmpty()) {
                             CharsetEncoder encoder = Charset.forName("ISO-8859-1").newEncoder();
index dda89b4..a130a1d 100644 (file)
@@ -184,7 +184,6 @@ public final class G2DCanvas implements Canvas {
 
     @Override
     public void destroy() {
-        // TODO Auto-generated method stub
-
+        getMotor3D().clean();
     }
 }
index 3d2267b..31f530d 100644 (file)
@@ -139,6 +139,10 @@ public class Motor3D {
      */
     public void draw() {
         Scene.drawRoot(g2d);
+        clean();
+    }
+
+    public void clean() {
         Scene.clearAll();
         G2DTextureManager.clear();
     }