Posts

Showing posts from July, 2017

9 Patch Scaling in JavaFX

Image
While playing around with  Borders  in JavaFX, I came across the term "9-patch scaling technique", and I wondered what that actually means. First of all, "9-patch" means that a rectangular area is divided into 9 areas (patches) of possibly different sizes as shown in the following image: Each area has either a fixed size (the corner areas 1, 3, 7, 9), or it can be resized vertically (4,6) or horizontally only (2,8), or it can be resized both vertially and horizontally (the central area, 5). When using "9-patch scaling", each area gets a particular fill color, pattern or even image assigned. If a pattern or image is used, it is either stretched or tiled (repeated) in those areas which are resizable, so that the pattern or image fills the whole area. Normally, the central area contains some particular content, and the outer areas are used to define a  border  around that content. In JavaFX, the rectangular area itself is a  Region  or one of its