/**
* Save the current image graphics to a binary FITS table with the given name
* in the current image.
*/
public void saveGraphicsWithImage(String extName) throws FitsException {
FITSImage fitsImage = imageDisplay.getFitsImage();
if (fitsImage == null) {
DialogUtil.error("Graphics can only be saved in a FITS image");
return;
}
List<Figure> figureList = canvasDraw.getFigureList();
int n = figureList.size();
List<String> typeList = new ArrayList<String>(n);
List<String> coordList = new ArrayList<String>(n);
List<String> configList = new ArrayList<String>(n);
ListIterator it = figureList.listIterator(0);
int i = 0;
while (it.hasNext()) {
CanvasFigure cfig = (CanvasFigure) it.next();
if (cfig instanceof ImageFigure) {
ImageFigure fig = (ImageFigure) cfig;
Shape shape = fig.getShape();
Paint fill = fig.getFillPaint();
Paint outline = fig.getStrokePaint();
float lineWidth = fig.getLineWidth();
Composite composite = fig.getComposite();
try {
String type = getType(shape);
String coords = getCoords(shape);
String config = getConfig(fill, outline, (int) lineWidth, composite);
typeList.add(type);
coordList.add(coords);
configList.add(config);
} catch (Exception e) {
continue; // ignore unsupported figures
}
} else if (cfig instanceof ImageLabel) {
ImageLabel fig = (ImageLabel) cfig;
Font font = fig.getFont();
String text = fig.getString();
Paint fill = fig.getFillPaint();
typeList.add("text");
coordList.add(getCoords((Point2D.Double) fig.getAnchorPoint()));
configList.add(getConfig(text, font, fill));
}
i++;
}
Fits fits = fitsImage.getFits();
_deleteBinaryTable(fits, extName);
BinaryTable table = new BinaryTable();
FitsFactory.setUseAsciiTables(false);
table.addColumn(typeList.toArray(new String[typeList.size()]));
table.addColumn(coordList.toArray(new String[coordList.size()]));