From: Martin D. <mar...@te...> - 2004-10-24 22:04:08
|
Andreas Wagner a =E9crit : > * Printing with mapPane.print(graphics2D) only shows something when i=20 > set the Bounds of the MapPane bevor invoking the print Methode.=20 > Unfortunatly my Debugger allways crashed when i tried to find out why=20 > the setting of the bounds is required. MapPane need to know the both the widget bounds and the "real world"=20 bounds in order to compute the AffineTransform converting coordinates=20 from "real world" to pixels. > * Printing over the Renderer works, it=B4s a problem of the=20 > AffineTransform i used. I tried to print with the same AffineTransform=20 > used when i show the Map on the Screen and got an output but till now i= =20 > was not able to build a AffineTransform that scales the whole=20 > BoundingBox to the chosen papersize and orientation. By adjusting AffineTransform coefficients, you should be able to print=20 yours map at any size you want and any orientation. I realize that we=20 really need to provides convenience methods, since not everyone is=20 confortable with AffineTransform. In the main time, there is a nice=20 tutorial there: http://www.glyphic.com/transform/ > Printing direct=20 > with the Renderer Layer for Layer could have the advantage that every=20 > Layer could have its own transformation when i understood this right?=20 Yes, every layer could have their own transformation but this is really=20 not an advantage. Quite the opposite, it may produces a chaotic output=20 in which layers do not superpose correctly each other. Note that each layer may have a different coordinate system. Different=20 CoordinateSystem may lead (indirectly) to different AffineTransform, but=20 it is probably safer to lets Renderer manage that (it should be able to=20 do that). > Currently when Landscape Format is printed Geotools rotates=20 > PolygoneLayers correct but TextLayers remain in the same orientation=20 > then in portred format. I think i could work around this problem when i= =20 > give the Textlayers a AffineTransform with the required rotation if=20 > landscape is selected. There is actually 2 AffineTransform objects to play with: - The one given to Graphics2D.setTransform(...). This is the transform used for rendering every features depending on device resolution instead of real world size. For example a "12 points" text font (the "12 points" size has nothing to do with "real world" size). So lets just remember that this is the AffineTransform used for rendering text among others. - The one given to the Renderer.paint(...) method. This is the transform used for rendering any features with "real world" size and coordinates (e.g. polygons). So in our case, in order to have text rotated as well as everything=20 else, the rotation must be applied on the first transform, the one given=20 to Graphics2D.setTransform(...). If after that the text still doesn't rotate properly, then it may be a=20 bug in J2D renderer. Not all part of J2D renderer was written by the=20 same person, and I noticed that in some place an identity=20 AffineTransform were wrongly used where the Graphics2D.getTransform()=20 should have been used instead. If you find some place where an identity=20 transform is explicitly used in a rendering operation, please send us a=20 note since it would probably be a bug. Regards, Martin. |