Last change
on this file was 1097, checked in by davidb, 6 years ago |
Newly structured files from Corey's work on logic/graphics separation
|
File size:
1.1 KB
|
Line | |
---|
1 | package org.expeditee.core;
|
---|
2 |
|
---|
3 | import org.expeditee.core.bounds.AxisAlignedBoxBounds;
|
---|
4 | import org.expeditee.core.bounds.Bounds;
|
---|
5 | import org.expeditee.core.bounds.CombinationBounds;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * Handles the accumulation of damage areas and clip generation.
|
---|
9 | *
|
---|
10 | * @author cts16
|
---|
11 | */
|
---|
12 | public class DamageAreas {
|
---|
13 |
|
---|
14 | private CombinationBounds _damagedAreas = null;
|
---|
15 |
|
---|
16 | public DamageAreas()
|
---|
17 | {
|
---|
18 | // Do nothing (member allocated on use)
|
---|
19 | }
|
---|
20 |
|
---|
21 | /** Adds an area to the damaged areas. */
|
---|
22 | public synchronized void addArea(Bounds area)
|
---|
23 | {
|
---|
24 | if (_damagedAreas == null) {
|
---|
25 | _damagedAreas = new CombinationBounds(area);
|
---|
26 | } else {
|
---|
27 | _damagedAreas.add(area);
|
---|
28 | }
|
---|
29 | }
|
---|
30 |
|
---|
31 | /** Resets the damaged areas to no area damaged. */
|
---|
32 | public synchronized void clear()
|
---|
33 | {
|
---|
34 | _damagedAreas = null;
|
---|
35 | }
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Returns the rectangular clip enclosing the damaged areas.
|
---|
39 | * Clears the clip at the same time.
|
---|
40 | */
|
---|
41 | public synchronized Clip getClip()
|
---|
42 | {
|
---|
43 | AxisAlignedBoxBounds bounds = AxisAlignedBoxBounds.getEnclosing(_damagedAreas);
|
---|
44 | clear();
|
---|
45 | if (bounds != null) {
|
---|
46 | return new Clip(bounds);
|
---|
47 | } else {
|
---|
48 | return Clip.getFullClip();
|
---|
49 | }
|
---|
50 | }
|
---|
51 |
|
---|
52 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.