/** * Sets the dirty bit. If true, then the painter is considered dirty, and the cache * will be cleared. This property is bound. * * @param d whether this <code>Painter</code> is dirty. */ protected void setDirty(boolean d) { boolean old = isDirty(); this.dirty = d; firePropertyChange("dirty", old, isDirty()); if (isDirty()) { clearCache(); } }
/** * Sets the dirty bit. If true, then the painter is considered dirty, and the cache * will be cleared. This property is bound. * * @param d whether this <code>Painter</code> is dirty. */ protected void setDirty(boolean d) { boolean old = isDirty(); this.dirty = d; firePropertyChange("dirty", old, isDirty()); if (isDirty()) { clearCache(); } }
/** * Sets the dirty bit. If true, then the painter is considered dirty, and the cache * will be cleared. This property is bound. * * @param d whether this <code>Painter</code> is dirty. */ protected void setDirty(boolean d) { boolean old = isDirty(); this.dirty = d; firePropertyChange("dirty", old, isDirty()); if (isDirty()) { clearCache(); } }
/** * Sets the dirty bit. If true, then the painter is considered dirty, and the cache * will be cleared. This property is bound. * * @param d whether this <code>Painter</code> is dirty. */ protected void setDirty(boolean d) { boolean old = isDirty(); this.dirty = d; firePropertyChange("dirty", old, isDirty()); if (isDirty()) { clearCache(); } }
/** * Sets the dirty bit. If true, then the painter is considered dirty, and the cache * will be cleared. This property is bound. * * @param d whether this <code>Painter</code> is dirty. */ protected void setDirty(boolean d) { boolean old = isDirty(); this.dirty = d; firePropertyChange("dirty", old, isDirty()); if (isDirty()) { clearCache(); } }
/** * Sets the dirty bit. If true, then the painter is considered dirty, and the cache * will be cleared. This property is bound. * * @param d whether this <code>Painter</code> is dirty. */ protected void setDirty(boolean d) { boolean old = isDirty(); this.dirty = d; firePropertyChange("dirty", old, isDirty()); if (isDirty()) { clearCache(); } }
/** * {@inheritDoc} * * @impl This <code>CompoundPainter</code> is dirty if it, or (optionally) any of its children, * are dirty. If the super implementation returns <code>true</code>, we return * <code>true</code>. Otherwise, if {@link #isCheckingDirtyChildPainters()} is * <code>true</code>, we iterate over all child <code>Painter</code>s and query them to * see if they are dirty. If so, then <code>true</code> is returned. Otherwise, we return * <code>false</code>. * @see #isCheckingDirtyChildPainters() */ @Override protected boolean isDirty() { boolean dirty = super.isDirty(); if (dirty) { return true; } else if (isCheckingDirtyChildPainters()) { for (Painter<?> p : painters) { if (p instanceof AbstractPainter) { AbstractPainter<?> ap = (AbstractPainter<?>) p; if (ap.isDirty()) { return true; } } } } return false; }
/** * <p>Iterates over all child <code>Painter</code>s and gives them a chance * to validate themselves. If any of the child painters are dirty, then * this <code>CompoundPainter</code> marks itself as dirty.</p> * * {@inheritDoc} */ @Override protected void validate(T object) { boolean dirty = false; for (Painter p : painters) { if (p instanceof AbstractPainter) { AbstractPainter ap = (AbstractPainter)p; ap.validate(object); if (ap.isDirty()) { dirty = true; break; } } } clearLocalCacheOnly = true; setDirty(dirty); //super will call clear cache clearLocalCacheOnly = false; }
/** * <p>Iterates over all child <code>Painter</code>s and gives them a chance * to validate themselves. If any of the child painters are dirty, then * this <code>CompoundPainter</code> marks itself as dirty.</p> * * {@inheritDoc} */ @Override protected void validate(T object) { boolean dirty = false; for (Painter<?> p : painters) { if (p instanceof AbstractPainter) { AbstractPainter ap = (AbstractPainter) p; ap.validate(object); if (ap.isDirty()) { dirty = true; break; } } } clearLocalCacheOnly = true; setDirty(dirty); //super will call clear cache clearLocalCacheOnly = false; }
/** * <p>Iterates over all child <code>Painter</code>s and gives them a chance * to validate themselves. If any of the child painters are dirty, then * this <code>CompoundPainter</code> marks itself as dirty.</p> * * {@inheritDoc} */ @Override protected void validate(T object) { boolean dirty = false; for (Painter<?> p : painters) { if (p instanceof AbstractPainter) { AbstractPainter ap = (AbstractPainter) p; ap.validate(object); if (ap.isDirty()) { dirty = true; break; } } } clearLocalCacheOnly = true; setDirty(dirty); //super will call clear cache clearLocalCacheOnly = false; }
/** * <p>Iterates over all child <code>Painter</code>s and gives them a chance * to validate themselves. If any of the child painters are dirty, then * this <code>CompoundPainter</code> marks itself as dirty.</p> * * {@inheritDoc} */ @Override protected void validate(T object) { boolean dirty = false; for (Painter<?> p : painters) { if (p instanceof AbstractPainter) { AbstractPainter ap = (AbstractPainter) p; ap.validate(object); if (ap.isDirty()) { dirty = true; break; } } } clearLocalCacheOnly = true; setDirty(dirty); //super will call clear cache clearLocalCacheOnly = false; }
@Override protected void setDirty(boolean d) { boolean old = super.isDirty(); boolean ours = isDirty(); super.setDirty(d); //must perform this check to ensure we do not double notify if (d != old && d == ours) { firePropertyChange("dirty", old, isDirty()); } }
/** * {@inheritDoc} */ @Override protected void setDirty(boolean d) { boolean old = super.isDirty(); boolean ours = isDirty(); super.setDirty(d); //must perform this check to ensure we do not double notify if (d != old && d == ours) { firePropertyChange("dirty", old, isDirty()); } }
/** * {@inheritDoc} */ @Override protected void setDirty(boolean d) { boolean old = super.isDirty(); boolean ours = isDirty(); super.setDirty(d); //must perform this check to ensure we do not double notify if (d != old && d == ours) { firePropertyChange("dirty", old, isDirty()); } }
/** * {@inheritDoc} */ @Override protected void setDirty(boolean d) { boolean old = super.isDirty(); boolean ours = isDirty(); super.setDirty(d); //must perform this check to ensure we do not double notify if (d != old && d == ours) { firePropertyChange("dirty", old, isDirty()); } }
/** * Issue #1218-swingx: must fire property change if contained painter * changed. */ public void testDirtyNotification() { AbstractPainter<Object> child = spy(new DummyPainter()); ((CompoundPainter<?>) p).setPainters(child); assertThat(p.isDirty(), is(true)); verify(child, never()).setDirty(true); p.paint(g, null, 10, 10); assertThat(p.isDirty(), is(false)); PropertyChangeListener pcl = mock(PropertyChangeListener.class); p.addPropertyChangeListener(pcl); child.setDirty(true); assertThat(p.isDirty(), is(true)); ArgumentCaptor<PropertyChangeEvent> captor = ArgumentCaptor.forClass(PropertyChangeEvent.class); verify(pcl).propertyChange(captor.capture()); assertThat(captor.getValue().getSource(), CoreMatchers.<Object>is(sameInstance(p))); assertThat(captor.getValue().getPropertyName(), is("dirty")); assertThat(captor.getAllValues().size(), is(1)); } }
/** * Issue #??-swingx: clearCache has no detectable effect. Test was poorly designed. It has had * an effect for a long time, but the member is not bound, so the test was failing erroneously. */ @Test public void testClearCacheDetectable() { p.setCacheable(true); p.paint(g, null, 10, 10); // sanity //when caching we get a different graphics object verify(p).doPaint(any(Graphics2D.class), isNull(), eq(10), eq(10)); assertThat("clean after paint", false, is(p.isDirty())); assertThat("cacheable is enabled", true, is(p.isCacheable())); assertThat("has a cached image", false, is(p.isCacheCleared())); p.clearCache(); assertThat("has a cached image", true, is(p.isCacheCleared())); }
@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 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)); }
/** * 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)); }