/** * Compute the filename based on the stretching factor * @param width of the button * @param height of the button * @return best matching stone slab extension file name. */ public String getFileNameExt(double width, double height, int capWidth) { float f = (float)((capWidth-width)/height); return getFileName(f, "StoneSlabExt.png",slabExtMap); }
/** * Compute the filename based on the stretching factor * @param width of the button * @param height of the button * @return best matching stone slab image file name */ private String getFileName(int width, int height) { float f = width*1f/height; String minDistFileName="StoneSlabBorderless.png"; return getFileName(f, minDistFileName,slabMap); } /**
/** * Draw a borderless stone slab * @param dim dimension of the image */ public Image getSlabImage(Dimension2D dim) { String fileName = getFileName((int)Math.rint(dim.getWidth()),(int)Math.rint(dim.getHeight())); InputStream is = getClass().getResourceAsStream(fileName); return new Image(is, dim.getWidth(), dim.getHeight(), false, true); }