jonathan wood has written:
> I have not tried your example, but you might try using the namespace "aware"
> dom calls instead to create your elements...kinda like

> Element circle =
> document.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
> SVGConstants.SVG_CIRCLE_TAG);

> and

> circle.setAttributeNS(null, Double.toString(cx));

Thanks heaps, this seemed to be the problem. You've saved me many hours of
confusing mental pain.

David Eccles (gringer)

FWIW, here's my changed city drawing method (a colour field has been added in
the meantime to another class):

  public boolean drawCities(Vector<City> cityList){
    double mapMinX = -170;
    double mapMinY = -90;
    double mapSizeX = 1000;
    double mapSizeY = 420;
    final Vector<Element> circles = new Vector<Element>();
    String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
    for(City tCity : cityList){
      double cx =  (tCity.getX() - mapMinX) * (mapSizeX / 360.0);
      // Y is inverted
      double cy =  (-tCity.getY() - mapMinY) * (mapSizeY / 180.0);
      String cs = Pathogenic.CUBECOLOURS[tCity.getColour()];
      Element cityCirc = boardDrawing.getSVGDocument().createElementNS(svgNS,
        "circle");
      cityCirc.setAttributeNS(null, "cx", Double.toString(cx));
      cityCirc.setAttributeNS(null, "cy", Double.toString(cy));
      cityCirc.setAttributeNS(null, "r", "10");
      cityCirc.setAttributeNS(null, "style",
        "fill:"+cs+";stroke:black;stroke-width:3");
      circles.add(cityCirc);
      System.out.println("Preparing " + tCity.getName() +
        " at " + cx + "," + cy);
    }
    boardDrawing.getUpdateManager().getUpdateRunnableQueue().invokeLater
      (new Runnable() {
          public void run() {
            for(Element cityCirc : circles) {
              boardDrawing.getSVGDocument().
                getRootElement().appendChild(cityCirc);
            }
          }
        });
    return true;
  }

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to