Attachment 'twikidraw-1.103-full.diff'

Download

   1 diff -urP --ignore-space-change orig/src/CH/ifa/draw/standard/CompositeFigure.java moin/src/CH/ifa/draw/standard/CompositeFigure.java
   2 --- orig/src/CH/ifa/draw/standard/CompositeFigure.java	2003-02-02 10:16:46.000000000 +0000
   3 +++ moin/src/CH/ifa/draw/standard/CompositeFigure.java	2005-11-27 18:33:04.000000000 +0000
   4 @@ -395,7 +395,7 @@
   5  	String areas = "";
   6          Enumeration k = fFigures.elements();
   7          while (k.hasMoreElements())
   8 -            areas += ((Storable) k.nextElement()).getMap();
   9 +            areas = ((Storable) k.nextElement()).getMap() + areas;
  10  	return areas;
  11      }
  12  
  13 diff -urP --ignore-space-change orig/src/CH/ifa/draw/twiki/TWikiFrame.java moin/src/CH/ifa/draw/twiki/TWikiFrame.java
  14 --- orig/src/CH/ifa/draw/twiki/TWikiFrame.java	2005-03-08 17:59:34.000000000 +0000
  15 +++ moin/src/CH/ifa/draw/twiki/TWikiFrame.java	2005-11-27 22:31:14.000000000 +0000
  16 @@ -20,6 +20,7 @@
  17  import CH.ifa.draw.applet.*;
  18  import CH.ifa.draw.contrib.*;
  19  //import SVG.wiki.*;
  20 +import com.keypoint.PngEncoderIndexed;
  21  
  22  import java.awt.*;
  23  import java.awt.event.*;
  24 @@ -37,8 +38,10 @@
  25      static private String UNTITLED_PARAMETER   = "untitled";
  26      static private String DRAWPATH_PARAMETER   = "drawpath";
  27      static private String GIFPATH_PARAMETER    = "gifpath";
  28 +    static private String PNGPATH_PARAMETER    = "pngpath";
  29      static private String SVGPATH_PARAMETER    = "svgpath";
  30      static private String SAVEPATH_PARAMETER   = "savepath";
  31 +    static private String BASENAME_PARAMETER   = "basename";
  32      static private String HELPPATH_PARAMETER   = "helppath";
  33      static private String BORDERSIZE_PARAMETER = "bordersize";
  34      
  35 @@ -361,8 +364,8 @@
  36      
  37      public boolean doSaveDrawing() {
  38          Application app = getApplication();
  39 -        boolean savedDraw, savedSvg, savedGif, savedMap;
  40 -        savedDraw = savedSvg = savedGif = savedMap = false;
  41 +        boolean savedDraw, savedSvg, savedGif, savedPng, savedMap;
  42 +        savedDraw = savedSvg = savedGif = savedPng = savedMap = false;
  43          
  44          // set wait cursor
  45          setCursor(new Cursor(Cursor.WAIT_CURSOR));
  46 @@ -387,13 +390,18 @@
  47              if (savePath == null)
  48                  savePath = "";
  49              
  50 +            // gets base filename
  51 +            String baseName = app.getParameter(BASENAME_PARAMETER);
  52 +            if (baseName == null)
  53 +                baseName = "SET_BASENAME_PARAM";
  54 +
  55              // submit POST command to the server three times:
  56 -            // *.draw, *.map and *.gif
  57 +            // *.draw, *.map, *.png and *.gif
  58              // first upload *.draw file
  59 -            showStatus("Saving .draw file " + drawingPath);
  60 +            showStatus("Saving " + baseName + ".draw");
  61              if (bPostEnabled)
  62                  savedDraw = app.post(
  63 -                                     savePath, "", "text/plain", drawingPath,
  64 +                                     savePath, baseName + ".draw", "text/plain", drawingPath,
  65                                       out.toString(), "TWiki Draw draw file");
  66              
  67              // calculate the minimum size of the gif image
  68 @@ -423,7 +431,7 @@
  69              String map = drawing().getMap();
  70              if (map.length() > 0) {
  71                  String mapPath = drawingPath.substring(0, drawingPath.length() - 5) + ".map";
  72 -                showStatus("Saving .map file " + mapPath);
  73 +                showStatus("Saving " + baseName + ".map");
  74                  // enclose the map and add editable border. Note that the
  75                  // edit border is added LAST so the earlier AREAs take
  76                  // precedence.
  77 @@ -452,12 +460,12 @@
  78                      
  79                      "</map>";
  80                  savedMap = app.post(
  81 -                                    savePath, "", "text/plain", mapPath,
  82 +                                    savePath, baseName + ".map", "text/plain", mapPath + ".map",
  83                                      map, "TWiki Draw map file");
  84              } else {
  85                  // erase any previous map file
  86                  String mapPath = drawingPath.substring(0, drawingPath.length() - 5);
  87 -                savedMap = app.post( savePath, "", "text/plain", mapPath + ".map", "", "" );
  88 +                savedMap = app.post( savePath, baseName + ".map", "text/plain", mapPath + ".map", "", "" );
  89              }
  90              
  91              // get pathname of the SVG file
  92 @@ -477,24 +485,38 @@
  93              // gets pathname of the GIF image
  94              String gifPath = getApplication().getParameter(GIFPATH_PARAMETER);
  95              if (gifPath == null || gifPath.length() == 0)
  96 -                gifPath = "untitled.gif";
  97 -            
  98 -            // then create *.gif image and upload file
  99 -            showStatus("Saving .gif file " + gifPath);
 100 +                gifPath = null;
 101              
 102 -            // clear the selection so it doesn't appear
 103 -            view().clearSelection();
 104 +            // gets pathname of the PNG image
 105 +            String pngPath = getApplication().getParameter(PNGPATH_PARAMETER);
 106 +            if (pngPath == null || pngPath.length() == 0) 
 107 +                pngPath = null;
 108 +
 109 +            if (gifPath != null || pngPath != null) {
 110 +                final Image oImgBuffer = createImage(d, iBorder);
 111 +            
 112 +                if (bPostEnabled && pngPath != null)
 113 +                {
 114 +                    // then create *.png image and upload file
 115 +                    showStatus("Saving " + baseName + ".png");
 116 +                    final char[] aChar = convertToPng(oImgBuffer);
 117 +                    // upload *.png file
 118 +                    savedPng = app.post(savePath, baseName + ".png", "image/png",
 119 +                                        pngPath, String.valueOf(aChar, 0, aChar.length),
 120 +                                        "TWiki Draw PNG file");
 121 +                }
 122              
 123 -            final Image oImgBuffer =
 124 -                this.view().createImage(d.width + iBorder, d.height + iBorder);
 125 +                if (bPostEnabled && gifPath != null)
 126 +                {
 127 +                    // then create *.gif image and upload file
 128 +                    showStatus("Saving " + baseName + ".gif");
 129              final char[] aChar = convertToGif(oImgBuffer);
 130 -            
 131              // upload *.gif file
 132 -            if (bPostEnabled)
 133 -                savedGif = app.post(
 134 -                                    savePath, "", "image/gif",
 135 +                    savedGif = app.post(savePath, baseName + ".gif", "image/gif",
 136                                      gifPath, String.valueOf(aChar, 0, aChar.length),
 137                                      "TWiki Draw GIF file");
 138 +                }
 139 +            }
 140          } catch (MalformedURLException e) {
 141              this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
 142              showStatus("Bad Wiki servlet URL: "+e.getMessage());
 143 @@ -506,7 +528,8 @@
 144          this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
 145          showStatus("Saved .draw " + (savedDraw ? "OK" : "Failed") +
 146                     " .map " + (savedMap ? "OK" : "Failed") +
 147 -                   " .gif " + (savedGif ? "OK" : "Failed"));
 148 +                   " .gif " + (savedGif ? "OK" : "Failed") +
 149 +                   " .png " + (savedPng ? "OK" : "Failed"));
 150          return savedDraw;
 151      }
 152      
 153 @@ -523,12 +546,11 @@
 154      	System.err.println("TWikiDraw:" + msg);
 155      }
 156      
 157 -    /**
 158 -     * convert Image to GIF-encoded data, reducing the number of colors
 159 -     * if needed. Added by Bertrand Delacretaz
 160 -     */
 161 -    private char [] convertToGif(Image oImgBuffer) throws IOException {
 162 -        debug("converting data to GIF...");
 163 +    private Image createImage(Dimension d, int iBorder) {
 164 +        // clear the selection so it doesn't appear
 165 +        view().clearSelection();
 166 +        final Image oImgBuffer =
 167 +           this.view().createImage(d.width + iBorder, d.height + iBorder);
 168          Graphics oGrf = oImgBuffer.getGraphics();
 169          this.view().enableGuides(false);
 170          this.view().drawAll(oGrf);
 171 @@ -539,8 +561,16 @@
 172          //tf.setImage(oImgBuffer);
 173          //tf.show();
 174  		
 175 -        ByteArrayOutputStream oOut = null;
 176 +        return oImgBuffer;
 177 +    }
 178  		
 179 +    /**
 180 +     * convert Image to GIF-encoded data, reducing the number of colors
 181 +     * if needed. Added by Bertrand Delacretaz
 182 +     */
 183 +    private char [] convertToGif(Image oImgBuffer) throws IOException {
 184 +        debug("converting data to GIF...");
 185 +        ByteArrayOutputStream oOut = null;
 186          try {
 187              oOut = new ByteArrayOutputStream();
 188              new GifEncoder(oImgBuffer,oOut).encode();
 189 @@ -563,4 +593,21 @@
 190          debug("conversion to GIF successful.");
 191          return aChar;
 192      }
 193 +
 194 +    /**
 195 +     * convert Image to PNG-encoded data
 196 +     * Added by OliverGraf
 197 +     */
 198 +    private char [] convertToPng(Image oImgBuffer) throws IOException {
 199 +        debug("converting data to PNG...");
 200 +        PngEncoderIndexed oEncode = new PngEncoderIndexed(oImgBuffer);
 201 +        byte[] aByte = oEncode.pngEncode();
 202 +        int size = aByte.length;
 203 +        char[] aChar = new char[size];
 204 +        for(int i = 0; i < size; i++) {
 205 +            aChar[i] = (char)aByte[i];
 206 +        }
 207 +        debug("conversion to PNG successful."); 
 208 +        return aChar;
 209 +    }
 210  }
 211 diff -urP --ignore-space-change orig/src/CH/ifa/draw/util/StorableOutput.java moin/src/CH/ifa/draw/util/StorableOutput.java
 212 --- orig/src/CH/ifa/draw/util/StorableOutput.java	2004-11-22 16:01:38.000000000 +0000
 213 +++ moin/src/CH/ifa/draw/util/StorableOutput.java	2005-11-27 22:32:04.000000000 +0000
 214 @@ -101,11 +101,11 @@
 215              char c = s.charAt(i);
 216              switch(c) {
 217                  // RobWalker 17 Jul 2003 - suppress \r
 218 -            case '\r': break;
 219 +            case '\r': fStream.print('\\'); fStream.print('r'); break;
 220              case '\n': fStream.print('\\'); fStream.print('n'); break;
 221              case '"' : fStream.print('\\'); fStream.print('"'); break;
 222              case '\\': fStream.print('\\'); fStream.print('\\'); break;
 223 -            case '\t': fStream.print('\\'); fStream.print('\t'); break;
 224 +            case '\t': fStream.print('\\'); fStream.print('t'); break;
 225              default:
 226                  if ((c >= 0x0001) && (c <= 0x007F)) {
 227                      fStream.print(c);

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2011-01-19 16:58:45, 10.0 KB) [[attachment:TO.tdraw]]
  • [get | view] (2005-11-28 21:54:52, 173.7 KB) [[attachment:TWikiDrawPlugin-1.103-OliverGraf-source.zip]]
  • [get | view] (2005-11-28 21:58:04, 174.0 KB) [[attachment:TWikiDrawPlugin-1.103-utf8-source.zip]]
  • [get | view] (2005-12-27 01:48:17, 170.3 KB) [[attachment:TWikiDrawPlugin-OliverGraf-SourceTree.zip]]
  • [get | view] (2009-09-19 19:46:07, 10.0 KB) [[attachment:anotherTest.tdraw]]
  • [get | view] (2004-02-07 18:31:10, 0.8 KB) [[attachment:mapname.diff]]
  • [get | view] (2012-10-22 07:10:47, 30.0 KB) [[attachment:meintest.tdraw]]
  • [get | view] (2010-09-20 14:11:48, 10.0 KB) [[attachment:mytest.tdraw]]
  • [get | view] (2010-12-28 18:33:16, 10.0 KB) [[attachment:new.tdraw]]
  • [get | view] (2005-09-12 16:36:38, 181.8 KB) [[attachment:newline_fix_twikidraw-sources.zip]]
  • [get | view] (2005-09-12 16:36:24, 205.5 KB) [[attachment:newline_fix_twikidraw.jar]]
  • [get | view] (2005-11-28 21:55:38, 185.3 KB) [[attachment:twikidraw-1.103-OliverGraf.jar]]
  • [get | view] (2005-11-28 21:56:32, 10.3 KB) [[attachment:twikidraw-1.103-full.diff]]
  • [get | view] (2005-11-28 21:58:29, 19.5 KB) [[attachment:twikidraw-1.103-utf8.diff]]
  • [get | view] (2005-11-28 21:57:38, 185.6 KB) [[attachment:twikidraw-1.103-utf8.jar]]
  • [get | view] (2004-02-07 20:44:17, 11.0 KB) [[attachment:twikidraw-full.diff]]
  • [get | view] (2004-02-07 20:44:26, 10.0 KB) [[attachment:twikidraw-png.zip]]
  • [get | view] (2004-02-07 20:44:47, 174.8 KB) [[attachment:twikidraw-sources.zip]]
  • [get | view] (2004-02-07 20:45:08, 184.3 KB) [[attachment:twikidraw.jar]]
  • [get | view] (2009-02-26 06:31:19, 1.1 KB) [[attachment:twikidrawbuild.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.