1 package ini
.trakem2
.display
.graphics
;
3 import ini
.trakem2
.display
.Display
;
4 import ini
.trakem2
.display
.Layer
;
5 import ini
.trakem2
.display
.Paintable
;
6 import ini
.trakem2
.display
.Patch
;
9 import java
.awt
.Graphics2D
;
10 import java
.awt
.Rectangle
;
11 import java
.util
.ArrayList
;
12 import java
.util
.List
;
14 public class TestGraphicsSource
implements GraphicsSource
{
16 /** Replaces all Patch instances by a smiley face. */
17 public List
<?
extends Paintable
> asPaintable(final List
<?
extends Paintable
> ds
) {
18 final ArrayList
<Paintable
> a
= new ArrayList
<Paintable
>();
19 for (final Paintable p
: ds
) {
20 if (p
instanceof Patch
) {
21 final Paintable pa
= new Paintable() {
22 public void paint(Graphics2D g
, Rectangle srcRect
, double magnification
, boolean active
, int channels
, Layer active_layer
, List
<Layer
> layers
) {
23 Patch patch
= (Patch
)p
;
24 Rectangle r
= patch
.getBoundingBox();
25 g
.setColor(Color
.magenta
);
26 g
.fillRect(r
.x
, r
.y
, r
.width
, r
.height
);
27 g
.setColor(Color
.green
);
28 g
.fillOval(r
.x
+ r
.width
/3, r
.y
+ r
.height
/3, r
.width
/10, r
.width
/10);
29 g
.fillOval(r
.x
+ 2 * (r
.width
/3), r
.y
+ r
.height
/3, r
.width
/10, r
.width
/10);
30 g
.fillOval(r
.x
+ r
.width
/3, r
.y
+ 2*(r
.height
/3), r
.width
/3, r
.height
/6);
32 public void prePaint(Graphics2D g
, Rectangle srcRect
, double magnification
, boolean active
, int channels
, Layer active_layer
, List
<Layer
> layers
) {
33 this.paint(g
, srcRect
, magnification
, active
, channels
, active_layer
, layers
);
45 public void paintOnTop(final Graphics2D g
, final Display display
, final Rectangle srcRect
, final double magnification
) {}