/** * {@inheritDoc} */ @Override protected boolean shouldUseCache() { return super.shouldUseCache(); // || (painters != null && painters.length > 1); } }
@Override protected boolean shouldUseCache() { return super.shouldUseCache(); // || (painters != null && painters.length > 1); } }
/** * {@inheritDoc} */ @Override protected boolean shouldUseCache() { return super.shouldUseCache(); // || (painters != null && painters.length > 1); } }
/** * {@inheritDoc} */ @Override protected boolean shouldUseCache() { return super.shouldUseCache(); // || (painters != null && painters.length > 1); } }
/** * {@inheritDoc} */ @Override protected boolean shouldUseCache() { return (isCacheable() && painters != null && painters.length > 0) || super.shouldUseCache(); } }
if (shouldUseCache() || filters.length > 0) { validate(obj); BufferedImage cache = cachedImage == null ? null : cachedImage.get(); if (shouldUseCache()) { cachedImage = new SoftReference<BufferedImage>(cache); cacheCleared = false;
if (shouldUseCache() || filters.length > 0) { validate(obj); BufferedImage cache = cachedImage == null ? null : cachedImage.get(); if (shouldUseCache()) { cachedImage = new SoftReference<BufferedImage>(cache); cacheCleared = false;
if (shouldUseCache() || filters.length > 0) { validate(obj); BufferedImage cache = cachedImage == null ? null : cachedImage.get(); if (shouldUseCache()) { cachedImage = new SoftReference<BufferedImage>(cache); cacheCleared = false;
/** * Ensure that paint orders calls correctly. */ @Test public void testInOrderPaintCallsWithoutCaching() { when(p.shouldUseCache()).thenReturn(false); InOrder orderedCalls = inOrder(p); p.paint(g, null, 10, 10); orderedCalls.verify(p).configureGraphics(g); orderedCalls.verify(p, times(0)).validate(null); orderedCalls.verify(p).doPaint(g, null, 10, 10); }
/** * Ensure that paint orders calls correctly. */ @Test public void testInOrderPaintCallsWithCaching() { when(p.shouldUseCache()).thenReturn(true); InOrder orderedCalls = inOrder(p); p.paint(g, null, 10, 10); orderedCalls.verify(p).configureGraphics(g); orderedCalls.verify(p).validate(null); //when caching we get a different graphics object verify(p).doPaint(any(Graphics2D.class), isNull(), eq(10), eq(10)); }
/** * Ensures that setting filters makes shouldUseCache return true. */ @Test public void testFiltersEnableCache() { p.setFilters(mock(BufferedImageOp.class)); assertThat(p.shouldUseCache(), is(true)); }
@Test public void testSetttingOnePainterDoesNotEnableCache() { ((CompoundPainter) p).setPainters(mock(Painter.class)); assertThat(p.shouldUseCache(), is(false)); }
@Test @Ignore("not sure this is the right thing to do") public void testSettingMoreThanOnePainterEnablesCache() { ((CompoundPainter) p).setPainters(mock(Painter.class), mock(Painter.class)); assertThat(p.shouldUseCache(), is(true)); }
/** * Ensures that setting cacheable makes shouldUseCache return true. */ @Test public void testSetCacheableEnablesCache() { p.setCacheable(true); assertThat(p.shouldUseCache(), is(true)); }
/** * Ensure that shouldUseCache forces the use of the cache. */ @Test public void testShouldUseCacheRepaintsWithCachedCopy() { when(p.shouldUseCache()).thenReturn(true); p.paint(g, null, 10, 10); //when caching we get a different graphics object verify(p, times(1)).doPaint(any(Graphics2D.class), isNull(), eq(10), eq(10)); p.paint(g, null, 10, 10); p.paint(g, null, 10, 10); p.paint(g, null, 10, 10); p.paint(g, null, 10, 10); //we do not invoke doPaint a subsequent calls verify(p, times(1)).doPaint(any(Graphics2D.class), isNull(), eq(10), eq(10)); } }
/** * TODO remove when the compound painter does not start dirty */ private void copyOfSuper_testDefaultsWithCorrectedValues() { assertThat(p.getFilters().length, is(0)); assertThat(p.getInterpolation(), is(AbstractPainter.Interpolation.NearestNeighbor)); assertThat(p.isAntialiasing(), is(true)); assertThat(p.isCacheable(), is(false)); assertThat(p.isCacheCleared(), is(true)); //TODO why does CompoundPainter start dirty? assertThat(p.isDirty(), is(true)); assertThat(p.isInPaintContext(), is(false)); assertThat(p.isVisible(), is(true)); assertThat(p.shouldUseCache(), is(false)); }
@Test public void testDefaults() { assertThat(p.getFilters().length, is(0)); assertThat(p.getInterpolation(), is(AbstractPainter.Interpolation.NearestNeighbor)); assertThat(p.isAntialiasing(), is(true)); assertThat(p.isCacheable(), is(false)); assertThat(p.isCacheCleared(), is(true)); assertThat(p.isDirty(), is(false)); assertThat(p.isInPaintContext(), is(false)); assertThat(p.isVisible(), is(true)); assertThat(p.shouldUseCache(), is(p.isCacheable())); }
/** * TODO remove when the compound painter does not start dirty */ private void copyOfSuper_testDefaultsWithCorrectedValues() { assertThat(p.getFilters().length, is(0)); assertThat(p.getInterpolation(), is(AbstractPainter.Interpolation.NearestNeighbor)); assertThat(p.isAntialiasing(), is(true)); assertThat(p.isCacheable(), is(false)); assertThat(p.isCacheCleared(), is(true)); //TODO this is because the constructor calls the setters assertThat(p.isDirty(), is(true)); assertThat(p.isInPaintContext(), is(false)); assertThat(p.isVisible(), is(true)); assertThat(p.shouldUseCache(), is(false)); }
assertThat(p.isInPaintContext(), is(false)); assertThat(p.isVisible(), is(true)); assertThat(p.shouldUseCache(), is(p.isCacheable()));
assertThat(p.isInPaintContext(), is(false)); assertThat(p.isVisible(), is(true)); assertThat(p.shouldUseCache(), is(p.isCacheable()));