@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); }
/** * 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... painters) { Painter[] old = getPainters(); this.painters = new Painter[painters == null ? 0 : painters.length]; if (painters != null) { System.arraycopy(painters, 0, this.painters, 0, this.painters.length); } setDirty(true); firePropertyChange("painters", old, getPainters()); }
/** * Set a transform to be applied to all painters contained in this CompoundPainter * @param transform a new AffineTransform */ public void setTransform(AffineTransform transform) { AffineTransform old = getTransform(); this.transform = transform; setDirty(true); firePropertyChange("transform",old,transform); }
/** * Set the flag used by {@link #isDirty()} to check if the * child <code>Painter</code>s should be checked for their * <code>dirty</code> flag as part of processing. * * @see #isCheckingDirtyChildPainters() * @see #isDirty() */ public void setCheckingDirtyChildPainters(boolean b) { boolean old = isCheckingDirtyChildPainters(); this.checkForDirtyChildPainters = b; firePropertyChange("checkingDirtyChildPainters",old, isCheckingDirtyChildPainters()); }
/** * Sets if the clip should be preserved. * Normally the clip will be reset between each painter. Setting clipPreserved to * true can be used to let one painter mask other painters that come after it. * * @param shouldRestoreState new value of the clipPreserved property * @see #isClipPreserved() */ public void setClipPreserved(boolean shouldRestoreState) { boolean oldShouldRestoreState = isClipPreserved(); this.clipPreserved = shouldRestoreState; setDirty(true); firePropertyChange("clipPreserved",oldShouldRestoreState,shouldRestoreState); }
/** * {@inheritDoc} * <p> * Overridden for CompoundPainter defaults. */ @Test @Override public void testDefaults() { //TODO replace with super.testDefaults() when corrected copyOfSuper_testDefaultsWithCorrectedValues(); // super.testDefaults(); CompoundPainter cp = (CompoundPainter) p; assertThat(cp.getPainters(), is(new Painter[0])); assertThat(cp.getTransform(), is(nullValue())); assertThat(cp.isCheckingDirtyChildPainters(), is(true)); assertThat(cp.isClipPreserved(), is(false)); }
/** * {@inheritDoc} */ @Override protected void doPaint(Graphics2D g, T component, int width, int height) { for (Painter<T> p : getPainters()) { Graphics2D temp = (Graphics2D) g.create(); try { p.paint(temp, component, width, height); if(isClipPreserved()) { g.setClip(temp.getClip()); } } finally { temp.dispose(); } } }
/** * 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); }
@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()); } }
/** * 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); }
/** * {@inheritDoc} */ @Override protected CompoundPainter createTestingPainter() { return new CompoundPainter(); }
/** * {@inheritDoc} */ @Override public void propertyChange(PropertyChangeEvent evt) { CompoundPainter<?> painter = ref.get(); if (painter == null) { AbstractPainter<?> src = (AbstractPainter<?>) evt.getSource(); src.removePropertyChangeListener(this); } else { String property = evt.getPropertyName(); if ("dirty".equals(property) && evt.getNewValue() == Boolean.FALSE) { return; } painter.setDirty(true); } } }
@Override protected void doPaint(Graphics2D g, Object component, int width, int height) { if(!loaded) { load(); } super.doPaint(g, component, width, height); }
/** * {@inheritDoc} */ @Override protected void configureGraphics(Graphics2D g) { //applies the transform AffineTransform tx = getTransform(); if (tx != null) { g.setTransform(tx); } }
/** * {@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; }
/** * Sets if the clip should be preserved. * Normally the clip will be reset between each painter. Setting clipPreserved to * true can be used to let one painter mask other painters that come after it. * * @param shouldRestoreState new value of the clipPreserved property * @see #isClipPreserved() */ public void setClipPreserved(boolean shouldRestoreState) { boolean oldShouldRestoreState = isClipPreserved(); this.clipPreserved = shouldRestoreState; setDirty(true); firePropertyChange("clipPreserved",oldShouldRestoreState,shouldRestoreState); }
/** * {@inheritDoc} */ @Override protected void doPaint(Graphics2D g, T component, int width, int height) { for (Painter<T> p : getPainters()) { Graphics2D temp = (Graphics2D) g.create(); try { p.paint(temp, component, width, height); if(isClipPreserved()) { g.setClip(temp.getClip()); } } finally { temp.dispose(); } } }
/** * Set the flag used by {@link #isDirty()} to check if the * child <code>Painter</code>s should be checked for their * <code>dirty</code> flag as part of processing. * * @see #isCheckingDirtyChildPainters() * @see #isDirty() */ public void setCheckingDirtyChildPainters(boolean b) { boolean old = isCheckingDirtyChildPainters(); this.checkForDirtyChildPainters = b; firePropertyChange("checkingDirtyChildPainters",old, isCheckingDirtyChildPainters()); }
/** * 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); }
/** * {@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()); } }