StateChart extends AnimatedComponent { public void setRenderMode(@NotNull RenderMode mode) { myRenderMode = mode; } @VisibleForTesting  StateChart(@NotNull StateChartModel<T> model, @NotNull Map<T, Color> colors);  StateChart(@NotNull StateChartModel<T> model, @NotNull StateChartColorProvider<T> colorMapping);  StateChart(@NotNull StateChartModel<T> model,
                    @NotNull StateChartColorProvider<T> colorMapping,
                    StateChartTextConverter<T> textConverter);  StateChart(@NotNull StateChartModel<T> model,
                    @NotNull StateChartConfig<T> config,
                    @NotNull StateChartColorProvider<T> colorMapping); @VisibleForTesting  StateChart(@NotNull StateChartModel<T> model,
                    @NotNull StateChartConfig<T> config,
                    @NotNull StateChartColorProvider<T> colorMapping,
                    @NotNull StateChartTextConverter<T> textConverter); void setModel(@NotNull StateChartModel<T> model); void setRenderMode(@NotNull RenderMode mode); void setHeightGap(float gap);  }
@Test public void testStateChartTextConverter() { StateChartModel<Integer> model = new StateChartModel<>(); DataSeries<Integer> dataSeries = (range) -> ImmutableList.of(new SeriesData<>(0,1), new SeriesData<>(1000, 2)); model.addSeries(new RangedSeries<>(new Range(0, 100), dataSeries)); StateChart<Integer> stateChart = new StateChart<>(model, new StateChartColorProvider<Integer>() { @NotNull @Override public Color getColor(boolean isMouseOver, Integer value) { return Color.BLACK; } }, (value) -> "123"); stateChart.setSize(100, 100); stateChart.setRenderMode(StateChart.RenderMode.TEXT); Graphics2D fakeGraphics = mock(Graphics2D.class); when(fakeGraphics.create()).thenReturn(fakeGraphics); stateChart.paint(fakeGraphics); verify(fakeGraphics, times(1)).drawString(eq("123"), anyFloat(), anyFloat()); }
@Test public void testStateChartWithDefaultTextConverterUsesToString() { StateChartModel<ToStringTestClass> model = new StateChartModel<>(); DataSeries<ToStringTestClass> dataSeries = (range) -> ImmutableList.of( new SeriesData<>(0, new ToStringTestClass("Test")), new SeriesData<>(1000, new ToStringTestClass("Test2"))); model.addSeries(new RangedSeries<>(new Range(0, 100), dataSeries)); StateChart<ToStringTestClass> stateChart = new StateChart<>(model, new StateChartColorProvider<ToStringTestClass>() { @NotNull @Override public Color getColor(boolean isMouseOver, @NotNull ToStringTestClass value) { return Color.BLACK; } }); stateChart.setSize(100, 100); stateChart.setRenderMode(StateChart.RenderMode.TEXT); Graphics2D fakeGraphics = mock(Graphics2D.class); when(fakeGraphics.create()).thenReturn(fakeGraphics); stateChart.paint(fakeGraphics); verify(fakeGraphics, times(1)).drawString(eq("Test"), anyFloat(), anyFloat()); }