Согласно документации:
| Цитата | Rendering a TiledLayer A TiledLayer can be rendered by manually calling its paint method; it can also be rendered automatically using a LayerManager object. The paint method will attempt to render the entire TiledLayer subject to the clip region of the Graphics object; the upper left corner of the TiledLayer is rendered at its current (x,y) position relative to the Graphics object's origin. The rendered region may be controlled by setting the clip region of the Graphics object accordingly.
|
Смотрим кусок декомпилированного кода класса:
| Код | public final void paint(Graphics g) { if(g == null) throw new NullPointerException(); if(visible) { int tileIndex = 0; if(updated) { int arrayLength = 0; for(int row = 0; row < cellMatrix.length; row++) { int totalCols = cellMatrix[row].length; for(int column = 0; column < totalCols; column++) { tileIndex = cellMatrix[row][column]; if(tileIndex != 0) arrayLength++; }
}
if(x_src == null || arrayLength > x_src.length) { x_src = new int[arrayLength]; y_src = new int[arrayLength]; x_dest = new int[arrayLength]; y_dest = new int[arrayLength]; } tileArrayLength = arrayLength; updated = false; } int ty = y; int arrayIndex = 0; for(int row = 0; row < cellMatrix.length;) { int tx = x; int totalCols = cellMatrix[row].length; for(int column = 0; column < totalCols;) { tileIndex = cellMatrix[row][column]; if(tileIndex != 0) { if(tileIndex < 0) tileIndex = getAnimatedTile(tileIndex); x_src[arrayIndex] = tileSetX[tileIndex]; y_src[arrayIndex] = tileSetY[tileIndex]; x_dest[arrayIndex] = tx; y_dest[arrayIndex] = ty; arrayIndex++; } column++; tx += cellWidth; }
row++; ty += cellHeight; }
drawTiledRegion(g, sourceImage, tileArrayLength, x_src, y_src, cellWidth, cellHeight, 0, x_dest, y_dest, 20); } }
private native void drawTiledRegion(Graphics g, Image image, int i, int ai[], int ai1[], int j, int k, int l, int ai2[], int ai3[], int i1);
|
|