~ubuntu-branches/ubuntu/trusty/libswingx-java/trusty

« back to all changes in this revision

Viewing changes to src/test/org/jdesktop/swingx/painter/TestablePainter.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2011-03-06 00:28:45 UTC
  • mfrom: (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110306002845-escned3cbqp5qx0t
Tags: 1:1.6.2-1
* New upstream release.
* Switch to maven as build system:
  - d/control: drop ant, add maven-debian-helper
  - d/rules: use maven.mk
* d/patches/pom.diff: drop, uneeded since upstream fixed its dependencies.
* d/watch: update to use java.net directly.
* d/rules: force debian version for JARs (Closes: #603495).
* d/copyright: Update to lastest DEP-5 r166.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * $Id: TestablePainter.java 3475 2009-08-28 08:30:47Z kleopatra $
3
 
 *
4
 
 * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5
 
 * Santa Clara, California 95054, U.S.A. All rights reserved.
6
 
 *
7
 
 * This library is free software; you can redistribute it and/or
8
 
 * modify it under the terms of the GNU Lesser General Public
9
 
 * License as published by the Free Software Foundation; either
10
 
 * version 2.1 of the License, or (at your option) any later version.
11
 
 *
12
 
 * This library is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
 * Lesser General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU Lesser General Public
18
 
 * License along with this library; if not, write to the Free Software
19
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
 
 */
21
 
package org.jdesktop.swingx.painter;
22
 
 
23
 
import java.awt.Graphics2D;
24
 
import java.awt.image.BufferedImageOp;
25
 
 
26
 
/**
27
 
 * A useful Painter implementation for Testing purposes
28
 
 * @author rbair
29
 
 */
30
 
class TestablePainter extends AbstractPainter {
31
 
    boolean painted = false;
32
 
    boolean configured = false;
33
 
    boolean configureCalledFirst = false;
34
 
    Object last;
35
 
    
36
 
    public TestablePainter() {
37
 
        super();
38
 
    }
39
 
 
40
 
    public TestablePainter(boolean cacheable) {
41
 
        super(cacheable);
42
 
    }
43
 
 
44
 
    @Override
45
 
    protected void doPaint(Graphics2D g, Object obj, int width, int height) {
46
 
        painted = true;
47
 
        last = obj;
48
 
    }
49
 
 
50
 
    @Override
51
 
    protected void validate(Object object) {
52
 
        if (last != object) {
53
 
            clearCache();
54
 
            setDirty(true);
55
 
        }
56
 
    }
57
 
 
58
 
    @Override
59
 
    protected void configureGraphics(Graphics2D g) {
60
 
        configured = true;
61
 
        configureCalledFirst = configured && !painted;
62
 
    }
63
 
 
64
 
    void reset() {
65
 
        painted = false;
66
 
        configured = false;
67
 
        setCacheable(false);
68
 
        clearCache();
69
 
        setFilters((BufferedImageOp[])null);
70
 
        setDirty(false);
71
 
    }
72
 
}