diff -urP --ignore-space-change orig/src/CH/ifa/draw/contrib/PolygonFigure.java moin/src/CH/ifa/draw/contrib/PolygonFigure.java
--- orig/src/CH/ifa/draw/contrib/PolygonFigure.java	2004-02-07 21:22:50.000000000 +0100
+++ moin/src/CH/ifa/draw/contrib/PolygonFigure.java	2004-02-07 21:22:58.000000000 +0100
@@ -322,8 +322,8 @@
 		coords += ",";
 	    coords += fPoly.xpoints[i] + "," + fPoly.ypoints[i];
 	}
-	return "<AREA SHAPE=\"POLY\" COORDS=\"" + coords +
-            "\" HREF=\"" + sense + "\">\n";
+	return "<area shape=\"poly\" coords=\"" +
+	    coords + "\" />\n";
     }
     
     public void write(StorableOutput dw) {
diff -urP --ignore-space-change orig/src/CH/ifa/draw/figures/EllipseFigure.java moin/src/CH/ifa/draw/figures/EllipseFigure.java
--- orig/src/CH/ifa/draw/figures/EllipseFigure.java	2004-02-07 21:22:50.000000000 +0100
+++ moin/src/CH/ifa/draw/figures/EllipseFigure.java	2004-02-07 21:22:58.000000000 +0100
@@ -106,9 +106,9 @@
 		coords += x + "," + y;
 		ang += Math.PI / 3;
 	    }
-	    return "<AREA SHAPE=\"POLY\" COORDS=\"" + coords +
-		"\" HREF=\"" +
-		sense + "\">\n";
+	    return "<area shape=\"poly\" coords=\"" + coords +
+		"\" href=\"" +
+		sense + "\" />\n";
 	}
 	return "";
     }
diff -urP --ignore-space-change orig/src/CH/ifa/draw/figures/PolyLineFigure.java moin/src/CH/ifa/draw/figures/PolyLineFigure.java
--- orig/src/CH/ifa/draw/figures/PolyLineFigure.java	2004-02-07 21:22:50.000000000 +0100
+++ moin/src/CH/ifa/draw/figures/PolyLineFigure.java	2004-02-07 21:22:58.000000000 +0100
@@ -339,9 +339,9 @@
 	    backwards = (p2.x - x) + "," + (p2.y - y) + "," +
 		(p1.x - x) + "," + (p1.y - y) + backwards;
         }
-	return "<AREA SHAPE=\"POLY\" COORDS=\"" +
-	    forwards + "," + backwards + "\" HREF=\"" +
-	    sensitive + "\">\n";
+	return "<area shape=\"poly\" coords=\"" +
+	    forwards + "," + backwards + "\" href=\"" +
+	    sensitive + "\" />\n";
     }
 
     public void read(StorableInput dr) throws IOException {
diff -urP --ignore-space-change orig/src/CH/ifa/draw/figures/RectangleFigure.java moin/src/CH/ifa/draw/figures/RectangleFigure.java
--- orig/src/CH/ifa/draw/figures/RectangleFigure.java	2004-02-07 21:22:50.000000000 +0100
+++ moin/src/CH/ifa/draw/figures/RectangleFigure.java	2004-02-07 21:22:58.000000000 +0100
@@ -85,11 +85,11 @@
 		sense = URLDecoder.decode(sense);
 	    } catch (Exception e) {}
 	    Rectangle box = displayBox();
-	    return "<AREA SHAPE=\"RECT\" COORDS=\"" +
+	    return "<area shape=\"rect\" coords=\"" +
 		box.x + "," + box.y + "," +
 		(box.x + box.width) + "," +
 		(box.y + box.height) +
-		"\" HREF=\"" + sense + "\">\n";
+		"\" href=\"" + sense + "\" />\n";
 	}
 	return "";
     }
diff -urP --ignore-space-change orig/src/CH/ifa/draw/figures/RoundRectangleFigure.java moin/src/CH/ifa/draw/figures/RoundRectangleFigure.java
--- orig/src/CH/ifa/draw/figures/RoundRectangleFigure.java	2004-02-07 21:22:50.000000000 +0100
+++ moin/src/CH/ifa/draw/figures/RoundRectangleFigure.java	2004-02-07 21:22:58.000000000 +0100
@@ -119,12 +119,12 @@
 		sense = URLDecoder.decode(sense);
 	    } catch (Exception e) {}
 	    Rectangle box = displayBox();
-	    return "<AREA SHAPE=\"RECT\" COORDS=\"" +
+	    return "<area shape=\"rect\" coords=\"" +
 		       box.x + "," + box.y + "," +
 		       (box.x + box.width) + "," +
 		       (box.y + box.height) +
-		       "\" HREF=\"" +
-		       sense + "\">\n";
+		       "\" href=\"" +
+		       sense + "\" />\n";
 	}
 	return "";
     }
diff -urP --ignore-space-change orig/src/CH/ifa/draw/standard/CompositeFigure.java moin/src/CH/ifa/draw/standard/CompositeFigure.java
--- orig/src/CH/ifa/draw/standard/CompositeFigure.java	2004-02-07 21:22:50.000000000 +0100
+++ moin/src/CH/ifa/draw/standard/CompositeFigure.java	2004-02-07 21:22:58.000000000 +0100
@@ -395,7 +395,7 @@
 	String areas = "";
         Enumeration k = fFigures.elements();
         while (k.hasMoreElements())
-            areas += ((Storable) k.nextElement()).getMap();
+            areas = ((Storable) k.nextElement()).getMap() + areas;
 	return areas;
     }
 
diff -urP --ignore-space-change orig/src/CH/ifa/draw/twiki/TWikiFrame.java moin/src/CH/ifa/draw/twiki/TWikiFrame.java
--- orig/src/CH/ifa/draw/twiki/TWikiFrame.java	2004-02-07 21:22:50.000000000 +0100
+++ moin/src/CH/ifa/draw/twiki/TWikiFrame.java	2004-02-07 21:22:58.000000000 +0100
@@ -26,6 +26,8 @@
 import java.net.*;
 import java.lang.reflect.*;
 
+import com.keypoint.PngEncoderIndexed;
+
 public class TWikiFrame extends DrawFrame {
 
     /**
@@ -34,8 +36,10 @@
     static private String UNTITLED_PARAMETER   = "untitled";
     static private String DRAWPATH_PARAMETER   = "drawpath";
     static private String GIFPATH_PARAMETER    = "gifpath";
+    static private String PNGPATH_PARAMETER    = "pngpath";
     static private String SVGPATH_PARAMETER    = "svgpath";
     static private String SAVEPATH_PARAMETER   = "savepath";
+    static private String BASENAME_PARAMETER   = "basename";
     static private String HELPPATH_PARAMETER   = "helppath";
     static private String BORDERSIZE_PARAMETER = "bordersize";
 
@@ -333,8 +337,8 @@
 
     public boolean doSaveDrawing() {
 	TWikiDraw app = (TWikiDraw)getApplication();
-	boolean savedDraw, savedSvg, savedGif, savedMap;
-	savedDraw = savedSvg = savedGif = savedMap = false;
+		boolean savedDraw, savedSvg, savedGif, savedPng, savedMap;
+		savedDraw = savedSvg = savedGif = savedPng = savedMap = false;
 
 	// set wait cursor
 	setCursor(new Cursor(Cursor.WAIT_CURSOR));
@@ -359,12 +363,16 @@
 	    if (savePath == null)
 		savePath = "";
 
+			// gets base filename
+			String baseName = app.getParameter(BASENAME_PARAMETER);
+			if (baseName == null)
+				baseName = "SET_BASENAME_PARAM";
+			
             // submit POST command to the server three times:
 	    // *.draw, *.map and *.gif
             // first upload *.draw file
-            showStatus("Saving " + drawingPath);
-	    savedDraw = app.post(
-		savePath, "", "text/plain", drawingPath,
+			showStatus("Saving " + baseName + ".draw");
+			savedDraw = app.post(savePath, baseName + ".draw", "text/plain", drawingPath,
 		out.toString(), "TWikiDraw draw file");
 
 	    // calculate the minimum size of the gif image
@@ -394,32 +402,31 @@
 	    String map = drawing().getMap();
 	    if (map.length() > 0) {
 		String mapPath = drawingPath.substring(0, drawingPath.length() - 5);
-		showStatus("Saving " + mapPath);
+				showStatus("Saving " + baseName + ".map");
 		// enclose the map and add editable border. Note that the
 		// edit border is add LAST so the earlier AREAs take
 		// precedence.
-		map = "<MAP NAME=\"%MAPNAME%\">\n" + map +
-		    "<AREA SHAPE=\"RECT\" COORDS=\"" +
-		    "0,0," + (d.width+iBorder) + "," + (iBorder/2) +
-		    "\" HREF=\"%TWIKIDRAW%\">\n" +
-		    "<AREA SHAPE=\"RECT\" COORDS=\"" +
-		    "0,0," + iBorder/2 + "," + (d.height+iBorder) +
-		    "\" HREF=\"%TWIKIDRAW%\">\n" +
-		    "<AREA SHAPE=\"RECT\" COORDS=\"" +
-		    (d.width+iBorder/2) + ",0," + (d.width+iBorder) + "," + (d.height+iBorder) +
-		    "\" HREF=\"%TWIKIDRAW%\">\n" +
-		    "<AREA SHAPE=\"RECT\" COORDS=\"" +
-		    "0," + (d.height+iBorder/2) + "," +
-		    (d.width+iBorder) + "," + (d.height+iBorder) +
-		    "\" HREF=\"%TWIKIDRAW%\">\n" +
-		    "</MAP>";
-		savedMap = app.post(
-		    savePath, "", "text/plain", mapPath + ".map",
+				map = "<map name=\"%MAPNAME%\">\n" + map +
+					"<area shape=\"rect\" coords=\"" +
+					"0,0," + (d.width + iBorder) + "," + (iBorder/2) +
+					"\" href=\"%TWIKIDRAW%\" />\n" +
+					"<area shape=\"rect\" coords=\"" +
+					"0,0," + (iBorder/2) + "," + (d.height + iBorder) +
+					"\" href=\"%TWIKIDRAW%\" />\n" +
+					"<area shape=\"rect\" coords=\"" +
+					(d.width + iBorder/2) + ",0," + (d.width + iBorder) + "," + (d.height + iBorder) +
+					"\" href=\"%TWIKIDRAW%\" />\n" +
+					"<area shape=\"rect\" coords=\"" +
+					"0," + (d.height + iBorder/2) + "," +
+					(d.width + iBorder) + "," + (d.height + iBorder) +
+					"\" href=\"%TWIKIDRAW%\" />\n" +
+					"</map>";
+				savedMap = app.post(savePath, baseName + ".map", "text/plain", mapPath + ".map",
 		    map, "TWikiDraw map file");
 	    } else {
 		// erase any previous map file
 		String mapPath = drawingPath.substring(0, drawingPath.length() - 5);
-		savedMap = app.post( savePath, "", "text/plain", mapPath + ".map", "", "" );
+				savedMap = app.post( savePath, baseName + ".map", "text/plain", mapPath + ".map", "", "");
 	    }
 	    
             // get pathname of the SVG file
@@ -437,12 +444,13 @@
 
             // gets pathname of the GIF image
             String gifPath = getApplication().getParameter(GIFPATH_PARAMETER);
-	    if (gifPath == null || gifPath.length() == 0)
-		gifPath = "untitled.gif";
+			if (gifPath == null || gifPath.length() == 0) gifPath = null;
 
-            // then create *.gif image and upload file
-	    showStatus("Saving " + gifPath);
+			// gets pathname of the PNG image
+			String pngPath = getApplication().getParameter(PNGPATH_PARAMETER);
+			if (pngPath == null || pngPath.length() == 0) pngPath = null;
 
+			if (gifPath != null || pngPath != null) {
 	    // clear the selection so it doesn't appear
 	    view().clearSelection();
 
@@ -451,11 +459,29 @@
 	    Graphics oGrf = oImgBuffer.getGraphics();
 	    this.view().enableGuides(false);
 	    this.view().drawAll(oGrf);
-	    // test gif image:
-	    //TestFrame tf = new TestFrame( "tt2: " + oImgBuffer.toString() ); 
-	    //tf.setSize(new Dimension(d.width+30, d.height+30));
-	    //tf.setImage(oImgBuffer);
-	    //tf.show();
+				
+				if (pngPath != null) {
+					// then create *.png image and upload file
+					showStatus("Saving " + baseName + ".png");
+					
+					PngEncoderIndexed oEncode = new PngEncoderIndexed(oImgBuffer);
+					byte[] aByte = oEncode.pngEncode();
+					int size = aByte.length;
+					char[] aChar = new char[size];
+					for(int i = 0; i < size; i++) {
+						aChar[i] = (char)aByte[i];
+					}
+					
+					// upload *.png file
+					savedPng = app.post(savePath, baseName + ".png", "image/png",
+										pngPath, String.valueOf( aChar, 0, size),
+										"TWikiDraw PNG file");
+				}
+				
+				if (gifPath != null) {
+					// then create *.gif image and upload file
+					showStatus("Saving " + baseName + ".gif");
+					
 	    ByteArrayOutputStream oOut = new ByteArrayOutputStream();
 	    GifEncoder oEncode = new GifEncoder(oImgBuffer, oOut);
 	    oEncode.encode();
@@ -467,10 +493,11 @@
 	    }
 	    
 	    // upload *.gif file
-	    savedGif = app.post(
-		savePath, "", "image/gif",
+					savedGif = app.post(savePath, baseName + ".gif", "image/gif",
 		gifPath, String.valueOf( aChar, 0, size),
 		"TWikiDraw GIF file");
+				}
+			}
         } catch (MalformedURLException e) {
             this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
             showStatus("Bad Wiki servlet URL: "+e.getMessage());
@@ -482,7 +509,8 @@
 	this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
 	showStatus("Saved .draw " + (savedDraw ? "OK" : "Failed") +
 		   " .map " + (savedMap ? "OK" : "Failed") +
-		   " .gif " + (savedGif ? "OK" : "Failed"));
+				   " .gif " + (savedGif ? "OK" : "Failed") +
+				   " .png " + (savedPng ? "OK" : "Failed"));
 	return savedDraw;
     }
 
