/** * Sets the array of Painters to use. These painters will be executed in * order. A null value will be treated as an empty array. To prevent unexpected * behavior all values in provided array are copied to internally held array. * Any changes to the original array will not be reflected. * * @param painters array of painters, which will be painted in order */ public void setPainters(Painter<T>... painters) { List<? extends Painter<T>> l; if (painters == null) l = Collections.emptyList(); else l = Arrays.asList(painters); setPainters(l); }
/** * Convenience constructor for creating a CompoundPainter for an array * of painters. A defensive copy of the given array is made, so that future * modification to the array does not result in changes to the CompoundPainter. * * @param painters array of painters, which will be painted in order */ public CompoundPainter(Painter... painters) { handler = new Handler(this); setPainters(painters); }
/** * Convenience constructor for creating a CompoundPainter for a list * of painters. A defensive copy of the given array is made, so that future * modification to the list does not result in changes to the CompoundPainter. * * @param painters array of painters, which will be painted in order */ public CompoundPainter(List<? extends Painter<T>> painters) { handler = new Handler(this); setPainters(painters); } /**
/** * Convenience constructor for creating a CompoundPainter for an array * of painters. A defensive copy of the given array is made, so that future * modification to the array does not result in changes to the CompoundPainter. * * @param painters array of painters, which will be painted in order */ public CompoundPainter(Painter... painters) { handler = new Handler(this); setPainters(painters); }
/** * Convenience constructor for creating a CompoundPainter for an array * of painters. A defensive copy of the given array is made, so that future * modification to the array does not result in changes to the CompoundPainter. * * @param painters array of painters, which will be painted in order */ public CompoundPainter(Painter... painters) { handler = new Handler(this); setPainters(painters); }
/** * Convenience constructor for creating a CompoundPainter for an array * of painters. A defensive copy of the given array is made, so that future * modification to the array does not result in changes to the CompoundPainter. * * @param painters array of painters, which will be painted in order */ public CompoundPainter(Painter<T>... painters) { handler = new Handler(this); setPainters(painters); }
/** * Issue #497-swingx: setPainters can't cope with null. * */ @Test public void testSetEmptyPainters() { CompoundPainter<Object> painter = new CompoundPainter<Object>(); // okay painter.setPainters(); // fails painter.setPainters((Painter[]) null); }
@SuppressWarnings("unchecked") private void rebuildMainMapOverlay() { CompoundPainter<JXMapViewer> cp = new CompoundPainter<JXMapViewer>(); cp.setCacheable(false); /* * List<Painter> ptrs = new ArrayList<Painter>(); if(isDataProviderCreditShown()) { * ptrs.add(dataProviderCreditPainter); } if(isAddressLocationShown()) { ptrs.add(addressLocationPainter); } */ cp.setPainters(dataProviderCreditPainter, addressLocationPainter); mainMap.setOverlayPainter(cp); }
private void rebuildMainMapOverlay() { CompoundPainter cp = new CompoundPainter(); cp.setCacheable(false); /* List<Painter> ptrs = new ArrayList<Painter>(); if(isDataProviderCreditShown()) { ptrs.add(dataProviderCreditPainter); } if(isAddressLocationShown()) { ptrs.add(addressLocationPainter); }*/ cp.setPainters(dataProviderCreditPainter, addressLocationPainter); mainMap.setOverlayPainter(cp); }
/** * Issue #497-swingx: setPainters can't cope with null. * */ @Test public void testSetNullPainters() { CompoundPainter<Object> painter = new CompoundPainter<Object>(); // changed to cast to Painter, since uncasted it is equivalent to // Painter[], which is checked in the next test painter.setPainters((Painter<?>) null); }
@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)); }
/** * 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)); } }