ImagePaintingFactory.paintScaleBar(g2, width-s-10, h-10, s, v);
ImagePaintingFactory.paintScaleBar(g2, x+width-s-10, h-10, s, v);
    void saveImage()    {        //Builds the image to display.        boolean unitBar = model.isUnitBar();        String v = model.getUnitBarValue();         int s = (int) model.getUnitBarSize();        if (imageComponents == null) {            int width = mainImage.getWidth();            int h = mainImage.getHeight();            BufferedImage newImage = new BufferedImage(width, h,                     BufferedImage.TYPE_INT_RGB);            Graphics2D g2 = (Graphics2D) newImage.getGraphics();            g2.setColor(Color.WHITE);            ImagePaintingFactory.setGraphicRenderingSettings(g2);            //Paint the original image.            g2.drawImage(mainImage, null, 0, 0);                         if (unitBar && v != null)                ImagePaintingFactory.paintScaleBar(g2, width-s-10, h-10, s, v);            writeImage(newImage, name);        } else {            int width = mainImage.getWidth();            int h = mainImage.getHeight();            int n = imageComponents.size();            int w = width*(n+1)+ImgSaverPreviewer.SPACE*(n-1);            BufferedImage newImage = new BufferedImage(w, h,                     BufferedImage.TYPE_INT_RGB);            Graphics2D g2 = (Graphics2D) newImage.getGraphics();            g2.setColor(Color.WHITE);            ImagePaintingFactory.setGraphicRenderingSettings(g2);            //Paint the original image.            Iterator i = imageComponents.iterator();            int x = 0;            while (i.hasNext()) {                g2.drawImage((BufferedImage) i.next(), null, x, 0);                 if (unitBar && v != null)                    ImagePaintingFactory.paintScaleBar(g2, width-s-10, h-10, s,                             v);                x += width;                g2.fillRect(x, 0, ImgSaverPreviewer.SPACE, h);                x += ImgSaverPreviewer.SPACE;            }            g2.drawImage(mainImage, null, x, 0);             if (unitBar && v != null)                ImagePaintingFactory.paintScaleBar(g2, width-s-10, h-10, s, v);            writeImage(newImage, name);        }    }