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

COVERAGE SUMMARY FOR SOURCE FILE [AbstractRubberBandTool.java]

nameclass, %method, %block, %line, %
AbstractRubberBandTool.java100% (1/1)100% (4/4)100% (119/119)100% (28/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractRubberBandTool100% (1/1)100% (4/4)100% (119/119)100% (28/28)
AbstractRubberBandTool (): void 100% (1/1)100% (3/3)100% (1/1)
feedback (): void 100% (1/1)100% (53/53)100% (9/9)
mouseMotion (Point): void 100% (1/1)100% (42/42)100% (13/13)
start (JComponent): void 100% (1/1)100% (21/21)100% (5/5)

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.drawing;
16 
17import java.awt.BasicStroke;
18import java.awt.Color;
19import java.awt.Graphics2D;
20import java.awt.Point;
21 
22import javax.swing.JComponent;
23 
24public abstract class AbstractRubberBandTool extends AbstractMouseDragTool
25{
26        public void                                start(JComponent area)
27        {
28                _area = area;
29                _penColor = (Color) _properties.get(ColorPropertyTool.TOOL_PROPERTY_COLOR);
30                _stroke = (BasicStroke) _properties.get(LinePropertyTool.TOOL_PROPERTY_LINE);
31                _started = false;
32        }
33        
34        public void                                mouseMotion(Point location)
35        {
36                if (!_started)
37                {
38                        _started = true;
39                        _prevX = location.x;
40                        _prevY = location.y;
41                        _startX = location.x;
42                        _startY = location.y;
43                }
44                else
45                {
46                        _lastX = location.x;
47                        _lastY = location.y;
48                        feedback();
49                        _prevX = _lastX;
50                        _prevY = _lastY;
51                }
52        }
53        
54        // This method provides immediate feedback to writer (not to other participants)
55        private void        feedback()
56        {
57                Graphics2D graf = (Graphics2D) _area.getGraphics();
58                graf.setColor(_penColor);
59                graf.setXORMode(Color.WHITE);
60                graf.setStroke(_stroke);
61                // Remove previous "rubber band"
62                draw(graf, _startX, _startY, _prevX, _prevY);
63                scroll(_area, new Point(_lastX, _lastY));
64                // Display new rubber band
65                draw(graf, _startX, _startY, _lastX, _lastY);
66                graf.dispose();
67        }
68        
69        abstract protected void        draw(Graphics2D graf, int x1, int y1, int x2, int y2);
70 
71        protected Color                        _penColor;
72        protected BasicStroke        _stroke;
73        protected JComponent        _area;
74        protected int                        _startX;
75        protected int                        _startY;
76        protected int                        _lastX;
77        protected int                        _lastY;
78        protected int                        _prevX;
79        protected int                        _prevY;
80        private boolean                        _started;
81}

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