AxisPaint { public void paint(final Graphics2D graphics) { final DblPoint origin = new DblPoint(0., 0.); final Shape xaxis = new Shape( new PtDirLine<>(origin, new DblPoint(1.0, 0.)) ); final Shape yaxis = new Shape( new PtDirLine<>(origin, new DblPoint(0., 1.)) ); final Color color = graphics.getColor(); graphics.setStroke(new AwtStroke(new DefaultStroke())); graphics.setColor(Color.RED); new AwtLine(this.field).draw(xaxis, graphics, this.ctx); new AwtLine(this.field).draw(yaxis, graphics, this.ctx); graphics.setColor(color); } AxisPaint(final Field<Double> field, final Surface ctx);  AxisPaint(final Surface ctx); void paint(final Graphics2D graphics);  }
@Test public void preservesGraphicsColor() { final Surface ctx = AxisPaintTest.context(); final Graphics2D graphics = Mockito.mock(Graphics2D.class); Mockito.when(graphics.getColor()).thenReturn(Color.BLUE); new AxisPaint(ctx).paint(graphics); Mockito.verify(graphics).setColor(Color.BLUE); }
@Test public void overridesGraphicsStroke() { final Surface ctx = AxisPaintTest.context(); final Graphics2D graphics = Mockito.mock(Graphics2D.class); new AxisPaint(ctx).paint(graphics); Mockito.verify(graphics).setStroke(Mockito.isA(AwtStroke.class)); }
@Test public void drawsLines() { final Surface ctx = AxisPaintTest.context(); final Graphics2D graphics = Mockito.mock(Graphics2D.class); new AxisPaint(ctx).paint(graphics); Mockito.verify(graphics, Mockito.atLeast(2)).drawLine( Mockito.anyInt(), Mockito.anyInt(), Mockito.anyInt(), Mockito.anyInt() ); }