Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / ExtentHistory.java @ 213

History | View | Annotate | Download (1.89 KB)

1
/* Generated by Together */
2

    
3
package com.iver.cit.gvsig.fmap;
4

    
5
import java.awt.geom.Rectangle2D;
6

    
7
public class ExtentHistory {
8
    private int NUMREC;
9
    private Rectangle2D[] extents;
10
    private int num = 0;
11

    
12
    /**
13
     * Creates a new ExtentsHistory object.
14
     */
15
    public ExtentHistory() {
16
        NUMREC = 4;
17
        extents = new Rectangle2D.Double[NUMREC];
18
    }
19

    
20
    /**
21
     * Creates a new ExtentsHistory object.
22
     *
23
     * @param numEntries Numero de entradas que se guardan en el historico de
24
     *        rect?ngulos, por defecto 20
25
     */
26
    public ExtentHistory(int numEntries) {
27
        NUMREC = numEntries;
28
    }
29

    
30
    /**
31
     * Pone un nuevo rect?ngulo al final del array
32
     *
33
     * @param ext Rect?ngulo que se a?ade al hist?rico
34
     */
35
    public void put(Rectangle2D.Double ext) {
36
        if ((ext != null) && ((num < 1) || (ext != extents[num - 1]))) {
37
            if (num < (NUMREC)) {
38
                extents[num] = ext;
39
                num = num + 1;
40
            } else {
41
                for (int i = 0; i < (NUMREC - 1); i++) {
42
                    extents[i] = extents[i + 1];
43
                }
44

    
45
                extents[num - 1] = ext;
46
            }
47
        }
48
    }
49

    
50
    /**
51
     * Devuelve true si hay alg?n rect?ngulo en el hist?rico
52
     *
53
     * @return true o false en caso de que haya o no haya rect?ngulos
54
     */
55
    public boolean hasPrevious() {
56
        return num > 0;
57
    }
58

    
59
    /**
60
     * Obtiene el ?ltimo rect?ngulo que se a?adi? al hist?rico
61
     *
62
     * @return Ultimo rect?ngulo a?adido
63
     */
64
    public Rectangle2D get() {
65
        Rectangle2D ext = extents[num - 1];
66

    
67
        return ext;
68
    }
69

    
70
    /**
71
     * Devuelve el ?ltimo rect?ngulo del hist?rico y lo elimina del mismo
72
     *
73
     * @return Ultimo rect?ngulo a?adido
74
     */
75
    public Rectangle2D removePrev() {
76
        Rectangle2D ext = extents[num - 1];
77
        num = num - 1;
78

    
79
        return ext;
80
    }
81
}