GetBitmapFromCollection

How can I generate bitmap from a collection? I can’t find a method similar to GoDiagram GoView.GetBitmapFromCollection()
thanks

You can just copy the code in JPEGView.java of the Imager example. Instead of encoding it in JPEG format and writing it out to the stream, just return the BufferedImage.
Hmmm, actually, that would produce an image of the current view, including selection handles and such, just as GoView.GetBitmap does. GoView.GetBitmapFromCollection is different, since it just draws the objects in the argument collection.
So you can call JGoDocument.computeBounds to figure out how big a BufferedImage you’ll need. Instead of calling JGoView.paintView, you’ll just iterate over your collection of objects and call JGoObject.paint on each one.

I didn’t find the Imager example. May be because I use SWT not Swing?

OK, the following code is completely untested–I don’t even know if it compiles…
public Image getImageFromCollection(JGoObjectSimpleCollection coll) {
Rectangle bounds = JGoDocument.computeBounds(coll);
int w = Math.max(1, (int)Math.ceil(bounds.width));
int h = Math.max(1, (int)Math.ceil(bounds.height));
Image img = new Image(getDisplay(), w, h);
Graphics2D g2 = new Graphics2D(new GC(img), getDisplay());
g2.setColor(JGoBrush.ColorWhite);
g2.fillRect(0, 0, w, h);
g2.translate(-bounds.x, -bounds.y);
//applyRenderingHints(g2); // call this if you have a JGoView available
Rectangle objRect = new Rectangle(0, 0, 0, 0);
JGoListPosition pos = coll.getFirstObjectPos();
while (pos != null) {
JGoObject obj = coll.getObjectAtPos(pos);
pos = coll.getNextObjectPosAtTop(pos);
if (!obj.isVisible())
continue;
Rectangle b = obj.getBoundingRect();
objRect.x = b.x;
objRect.y = b.y;
objRect.width = b.width;
objRect.height = b.height;
obj.expandRectByPenWidth(objRect);
if (objRect.intersects(bounds)) {
obj.paint(g2, this);
}
}
g2.dispose();
return img;
}

Thanks. It works fine.