Revision 6220 org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/AbstractPaginatedBand.java

View differences:

AbstractPaginatedBand.java
1 1
package org.gvsig.raster.lib.buffer.impl;
2 2

  
3 3
import java.io.IOException;
4
import java.nio.Buffer;
4 5
import java.nio.ByteBuffer;
6
import java.nio.IntBuffer;
5 7

  
6 8
import org.gvsig.raster.lib.buffer.api.Band;
7 9
import org.gvsig.raster.lib.buffer.api.BandNotification;
......
16 18
 */
17 19
public abstract class AbstractPaginatedBand extends AbstractBand {
18 20

  
19
    protected ByteBuffer data;
21
    protected Buffer data;
20 22
    protected int firstRowOfPage;
21 23
    protected int rowsPerPage;
22 24
    protected BandPageManager pageManager;
25
    private boolean loaded;
23 26

  
24 27

  
25 28
    protected static final int MAX_PREFERED_SIZE = 10485760; // 10MB;
......
34 37
    public AbstractPaginatedBand(int rows, int columns, NoData noData, BandPageManager pageManager) {
35 38
        this.rows = rows;
36 39
        this.columns = columns;
40
        this.loaded=false;
37 41
        calculateRowsPerPage();
38
        data = ByteBuffer.allocate(rowsPerPage * columns * getDataSize());
42
        
39 43
        if (noData == null) {
40 44
            this.noData = BufferLocator.getBufferManager().createNoData(null, null);
41 45
        } else {
......
86 90
    }
87 91

  
88 92
    protected void loadPage(int row) {
89
        if(!(row>=firstRowOfPage && row<firstRowOfPage+rowsPerPage)){
93
        if (loaded && row >= firstRowOfPage
94
            && row < firstRowOfPage + rowsPerPage) {
90 95
            return;
91 96
        }
97
        loaded=false;
98

  
92 99
        saveCurrentPage();
93 100
        firstRowOfPage = row / rowsPerPage; //Divisi?n entera
94 101
        try {
......
97 104
                rowsInPage = this.rows - firstRowOfPage;
98 105
            }
99 106
            this.pageManager.load(data, firstRowOfPage, rowsInPage, this.getDataType());
107
            loaded=true;
100 108
        } catch (IOException e) {
101 109
            throw new RuntimeException("Can't save current page", e);
102 110
        }

Also available in: Unified diff