g2d.translate(-0.5, -0.5);
I have created my 9 pixel symbols in Illustrator and a program I found on sourceforge called sodipodi. So I think the problem is not in the SVG data but in the Batik renderer (or my use of it). Any idea why this is required to print at an exact location?
Thanks, Chris
Following is an excerpt of my display/print code:
public void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2d = (Graphics2D)g;
drawPage(g2d, false);
}
public int print(Graphics g, PageFormat pf, int page) throws PrinterException
{
if(page >= 1) return Printable.NO_SUCH_PAGE;
Graphics2D g2d = (Graphics2D)g;
g2d.translate((int)pf.getImageableX(), (int)pf.getImageableY());
drawPage(g2d, true);
return Printable.PAGE_EXISTS;
}
public void drawPage(Graphics2D g2d, boolean printFlag)
{
RenderingHints rh = new RenderingHints(null);
rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHints(rh);
g2d.setStroke(new BasicStroke(0.01f));
int gridWidth = 99; // 10x10 grid of 9 pixel symbols
int gridHeight = 99; // with 1-pixel separating lines
for(int i = 1; i < 10; i++)
{
int width = (9 * i) + i - 1;
g2d.draw(new Line2D.Float(width, 0, width, gridHeight));
}
for(int j = 1; j < 10; j++)
{
int height = (9 * j) + j - 1;
g2d.draw(new Line2D.Float(0, height, gridWidth, height));
}
int iconLineWidth = 10; // svg image plus line (9+1) int iconLineHeight = 10; if(printFlag == true) { g2d.translate(-0.5f, -0.5f); // KLUDGE }
for(int x = 0; x < 10; x++)
{
for(int y = 0; y < 10; y++)
{
if(grid[x][y] != -1)
{
svgSymbol(grid[x][y]).paint(g2d);
}
g2d.translate(0, iconLineHeight);
}
g2d.translate(iconLineWidth, -10 * iconLineHeight);
}
}
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
