Release Notes > JTGO 4.0 Release Notes > Compatibility Issues > Patterns

Starting from JTGO 4.0, the interface IlPattern is deprecated together with its two methods fillRect and fillPolygon. The way patterns are handled within JTGO has changed also and is now based on the Paint interface and handled directly by the Java Graphics2D class.

The abstract class IltPattern defines a new abstract method, getPaint, that should be implemented to create a new user-defined pattern in JTGO.

Users who directly implemented IlPattern or extended IltPattern are affected by this change. The recommended migration procedure is to use one of the predefined patterns (all patterns defined in IlvPattern are now supported), or to implement the method IltPattern.getPaint.

You only need to perform a small modification to your implementations of IlPattern to comply with the changes. To do so, follow these steps:

  1. Make sure the IlPattern implementation extends IltPattern.
  2. Identify the pattern width and height.
  3. Override the IltPattern.getPaint method as follows:
public Paint getPaint(Color foreground, Color background) {
  int width = *[ your pattern width ]*;
  int height = *[ your pattern height ]*;
  BufferedImage bf = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  Graphics2D g2d = bf.getGraphics();
  fillRect(g2d, null, 0, 0, width-1, height-1, foreground, background);
  return new TexturePaint(bf, new Rectangle2D.Float(0, 0, width, height));
}

This code is provided as a contribution and may be optimized according to the user's needs.