_Converting Windows Metafiles to Java_
by Carmen Delessio

Listing One
  case 0x41b: //rectangle
       numRectangles++;
       shapeName = "rectangle" + numRectangles;
       y2 = readInt(parmStream);
       x2 = readInt(parmStream);
       y = readInt(parmStream);
       x = readInt(parmStream);
       w = (short) Math.abs(x2-x);
       h = (short) Math.abs(y2-y);
       x = cvtTool.twip2pixel(x);
       y = cvtTool.twip2pixel(y);
       w = cvtTool.twip2pixel(w);
       h = cvtTool.twip2pixel(h);
       tempBuffer = "" + "( " + x + ", " + y + ", " + w + ", " + h +
                    ");//  rectangle" ;
       if (drawFilled){
          javaGraphic = javaGraphic + "    g.fillRect " + "( " +
                        shapeName + ".x" + ", " + shapeName + ".y " +
                        ", " + shapeName + ".width"  + ", " + shapeName +
                        ".height" + ");" + "\n";
       }
       else{
          javaGraphic = javaGraphic + "    g.drawRect " + "( " +
                        shapeName + ".x" + ", " + shapeName + ".y " +
                        ", " + shapeName + ".width"  + ", " + shapeName +
                        ".height" + ");" + "\n";
       }
       javaDeclare = javaDeclare + "    Rectangle " + shapeName +
                     ";" + "\n";
       javaInit = javaInit + "      " + shapeName   +
                  "= new Rectangle" + tempBuffer + "\n";
       break;

Listing Two
      poly1.addPoint(125,165);
      poly1.addPoint(148,178);
      poly1.addPoint(177,182);
      poly1.addPoint(213,179);
      poly1.addPoint(238,166);

      g.drawLine( 125,165, 148, 178);//  line
      g.drawLine( 148,178, 177, 182);//  line
      g.drawLine( 177,182, 213, 179);//  line
      g.drawLine( 213,179, 238, 166);//  line

1



