EMMA Coverage Report (generated Wed Feb 13 07:49:24 ICT 2008)
[all classes][net.sourceforge.hiveboard.view]

COVERAGE SUMMARY FOR SOURCE FILE [ScrollingMattePainter.java]

nameclass, %method, %block, %line, %
ScrollingMattePainter.java100% (1/1)100% (4/4)100% (161/161)100% (31/31)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ScrollingMattePainter100% (1/1)100% (4/4)100% (161/161)100% (31/31)
ScrollingMattePainter (): void 100% (1/1)100% (6/6)100% (2/2)
createAnimator (FullScreenPrefs, String): Animator 100% (1/1)100% (126/126)100% (22/22)
paint (Graphics2D): void 100% (1/1)100% (20/20)100% (4/4)
setMatteX (int): void 100% (1/1)100% (9/9)100% (3/3)

1//  Copyright 2004-2007 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package net.sourceforge.hiveboard.view;
16 
17import java.awt.Color;
18import java.awt.Font;
19import java.awt.Graphics2D;
20import java.awt.Rectangle;
21import java.awt.image.BufferedImage;
22 
23import org.jdesktop.animation.timing.Animator;
24import org.jdesktop.animation.timing.Animator.RepeatBehavior;
25import org.jdesktop.animation.timing.interpolation.PropertySetter;
26import org.jdesktop.animation.timing.interpolation.SplineInterpolator;
27 
28public class ScrollingMattePainter extends AbstractMattePainter
29{
30        @Override public Animator createAnimator(FullScreenPrefs prefs, String content)
31        {
32                // Initialize some drawing properties
33                _foreground = prefs.getForeground();
34                _background = prefs.getBackground();
35                _font = prefs.getFont();
36                
37                // Calculate limit coordinates of matte
38                int width = getPane().getWidth();
39                _geometry = new MatteGeometry(getPane(), prefs, content);
40                Rectangle matteRect = _geometry.getMatteRectangle();
41                _repaint = new Rectangle(matteRect);
42                _repaint.x = 0;
43                _repaint.width = width;
44                
45                // Create buffered image with just the text
46                _content = new BufferedImage(
47                                matteRect.width, matteRect.height, BufferedImage.TYPE_INT_ARGB);
48                Graphics2D g = _content.createGraphics();
49                g.setColor(_foreground);
50                g.setFont(_font);
51                g.drawString(
52                        content, _geometry.getMatteTextOrigin().x, _geometry.getMatteTextOrigin().y);
53                g.dispose();
54                
55                // Setup animator
56                Animator anim = PropertySetter.createAnimator(        prefs.getScrollTime(),
57                                                                                                                this,
58                                                                                                                "matteX",
59                                                                                                                width,
60                                                                                                                -matteRect.width);
61                anim.setRepeatBehavior(RepeatBehavior.LOOP);
62                double repeat = prefs.getDisplayTime() / (double) prefs.getScrollTime();
63                anim.setRepeatCount(repeat);
64                anim.setResolution(TIMER_RESOLUTION);
65                anim.setInterpolator(new SplineInterpolator(CONTROL_POINT_1_X,
66                                                            CONTROL_POINT_1_Y, 
67                                                            CONTROL_POINT_2_X, 
68                                                            CONTROL_POINT_2_Y));
69 
70                return anim;
71        }
72        
73        public void        setMatteX(int x)
74        {
75                _matteX = x;
76                getPane().repaint(_repaint);
77        }
78 
79        @Override public void paint(Graphics2D g)
80        {
81                g.setColor(_background);
82                // Paint the backgrounf first
83                g.fill(_repaint);
84                // Paint the picture with the text content
85                g.drawImage(_content, _matteX, _geometry.getMattePaintOrigin(), null);
86        }
87 
88        static private final int                TIMER_RESOLUTION = 80;
89        static private final float                CONTROL_POINT_1_X = 0.2f;
90        static private final float                CONTROL_POINT_1_Y = 0;
91        static private final float                CONTROL_POINT_2_X = 0.8f;
92        static private final float                CONTROL_POINT_2_Y = 1;
93 
94        private MatteGeometry                        _geometry;
95        private BufferedImage                        _content = null;
96        private Rectangle                                _repaint;
97        private int                                                _matteX;
98        
99        private Color                                        _foreground;
100        private Color                                        _background;
101        private Font                                        _font;
102}

[all classes][net.sourceforge.hiveboard.view]
EMMA 2.0.5312 (C) Vladimir Roubtsov