/** * <p>A convenience method for specifying the filters to use based on * BufferedImageOps. These will each be individually wrapped by an ImageFilter * and then setFilters(Effect... filters) will be called with the resulting * array</p> * * * @param effects the BufferedImageOps to wrap as filters */ public void setFilters(BufferedImageOp ... effects) { if (effects == null) effects = new BufferedImageOp[0]; BufferedImageOp[] old = getFilters(); this.filters = new BufferedImageOp[effects.length]; System.arraycopy(effects, 0, this.filters, 0, this.filters.length); setDirty(true); firePropertyChange("filters", old, getFilters()); }
/** * <p>A convenience method for specifying the filters to use based on * BufferedImageOps. These will each be individually wrapped by an ImageFilter * and then setFilters(Effect... filters) will be called with the resulting * array</p> * * * @param effects the BufferedImageOps to wrap as filters */ public void setFilters(BufferedImageOp ... effects) { if (effects == null) effects = new BufferedImageOp[0]; BufferedImageOp[] old = getFilters(); this.filters = new BufferedImageOp[effects.length]; System.arraycopy(effects, 0, this.filters, 0, this.filters.length); setDirty(true); firePropertyChange("filters", old, getFilters()); }
/** * <p>A convenience method for specifying the filters to use based on * BufferedImageOps. These will each be individually wrapped by an ImageFilter * and then setFilters(Effect... filters) will be called with the resulting * array</p> * * * @param effects the BufferedImageOps to wrap as filters */ public void setFilters(BufferedImageOp ... effects) { if (effects == null) effects = new BufferedImageOp[0]; BufferedImageOp[] old = getFilters(); this.filters = new BufferedImageOp[effects == null ? 0 : effects.length]; System.arraycopy(effects, 0, this.filters, 0, this.filters.length); setDirty(true); firePropertyChange("filters", old, getFilters()); }
/** * <p>A convenience method for specifying the filters to use based on * BufferedImageOps. These will each be individually wrapped by an ImageFilter * and then setFilters(Effect... filters) will be called with the resulting * array</p> * * * @param effects the BufferedImageOps to wrap as filters */ public void setFilters(BufferedImageOp ... effects) { if (effects == null) effects = new BufferedImageOp[0]; BufferedImageOp[] old = getFilters(); this.filters = new BufferedImageOp[effects.length]; System.arraycopy(effects, 0, this.filters, 0, this.filters.length); setDirty(true); firePropertyChange("filters", old, getFilters()); }
/** * <p>A convenience method for specifying the filters to use based on * BufferedImageOps. These will each be individually wrapped by an ImageFilter * and then setFilters(Effect... filters) will be called with the resulting * array</p> * * * @param effects the BufferedImageOps to wrap as filters */ public void setFilters(BufferedImageOp ... effects) { if (effects == null) effects = new BufferedImageOp[0]; BufferedImageOp[] old = getFilters(); this.filters = new BufferedImageOp[effects.length]; System.arraycopy(effects, 0, this.filters, 0, this.filters.length); setDirty(true); firePropertyChange("filters", old, getFilters()); }
/** * <p>A convenience method for specifying the filters to use based on * BufferedImageOps. These will each be individually wrapped by an ImageFilter * and then setFilters(Effect... filters) will be called with the resulting * array</p> * * * @param effects the BufferedImageOps to wrap as filters */ public void setFilters(BufferedImageOp... effects) { if (effects == null) effects = new BufferedImageOp[0]; BufferedImageOp[] old = getFilters(); this.filters = new BufferedImageOp[effects.length]; System.arraycopy(effects, 0, this.filters, 0, this.filters.length); setDirty(true); firePropertyChange("filters", old, getFilters()); }
private void paintWithForegroundPainterWithFilters(Graphics g) { BufferedImage im = GraphicsUtilities.createCompatibleTranslucentImage(getWidth(), getHeight()); Graphics2D g2d = im.createGraphics(); try { Graphics gfx = getComponentGraphics(g2d); assert gfx == g2d; paintWithForegroundPainterWithoutFilters(g2d); } finally { g2d.dispose(); } Graphics2D filtered = (Graphics2D) g.create(); try { for (BufferedImageOp filter : ((AbstractPainter<?>) fgPainter).getFilters()) { filtered.setComposite(new FilterComposite(filtered.getComposite(), filter)); } filtered.drawImage(im, 0, 0, this); } finally { filtered.dispose(); } }
private void paintWithForegroundPainterWithFilters(Graphics g) { BufferedImage im = GraphicsUtilities.createCompatibleTranslucentImage(getWidth(), getHeight()); Graphics2D g2d = im.createGraphics(); try { Graphics gfx = getComponentGraphics(g2d); assert gfx == g2d; paintWithForegroundPainterWithoutFilters(g2d); } finally { g2d.dispose(); } Graphics2D filtered = (Graphics2D) g.create(); try { for (BufferedImageOp filter : ((AbstractPainter<?>) fgPainter).getFilters()) { filtered.setComposite(new FilterComposite(filtered.getComposite(), filter)); } filtered.drawImage(im, 0, 0, this); } finally { filtered.dispose(); } }
private void paintWithForegroundPainterWithFilters(Graphics g) { BufferedImage im = GraphicsUtilities.createCompatibleTranslucentImage(getWidth(), getHeight()); Graphics2D g2d = im.createGraphics(); try { Graphics gfx = getComponentGraphics(g2d); assert gfx == g2d; paintWithForegroundPainterWithoutFilters(g2d); } finally { g2d.dispose(); } Graphics2D filtered = (Graphics2D) g.create(); try { for (BufferedImageOp filter : ((AbstractPainter<?>) fgPainter).getFilters()) { filtered.setComposite(new FilterComposite(filtered.getComposite(), filter)); } filtered.drawImage(im, 0, 0, this); } finally { filtered.dispose(); } }
private void paintWithForegroundPainterWithFilters(Graphics g) { BufferedImage im = GraphicsUtilities.createCompatibleTranslucentImage(getWidth(), getHeight()); Graphics2D g2d = im.createGraphics(); try { Graphics gfx = getComponentGraphics(g2d); assert gfx == g2d; paintWithForegroundPainterWithoutFilters(g2d); } finally { g2d.dispose(); } Graphics2D filtered = (Graphics2D) g.create(); try { for (BufferedImageOp filter : ((AbstractPainter<?>) fgPainter).getFilters()) { filtered.setComposite(new FilterComposite(filtered.getComposite(), filter)); } filtered.drawImage(im, 0, 0, this); } finally { filtered.dispose(); } }
/** * {@inheritDoc} */ @Override protected void paintComponent(Graphics g) { if (fgPainter == null && bgPainter == null) { super.paintComponent(g); } else { if (fgPainter == null) { Graphics2D g2d = (Graphics2D) g.create(); try{ paintWithoutForegroundPainter(g2d); } finally { g2d.dispose(); } } else if (fgPainter instanceof AbstractPainter && ((AbstractPainter<?>) fgPainter).getFilters().length > 0) { paintWithForegroundPainterWithFilters(g); } else { Graphics2D g2d = (Graphics2D) g.create(); try { paintWithForegroundPainterWithoutFilters(g2d); } finally { g2d.dispose(); } } } }
/** * {@inheritDoc} */ @Override protected void paintComponent(Graphics g) { if (fgPainter == null && bgPainter == null) { super.paintComponent(g); } else { if (fgPainter == null) { Graphics2D g2d = (Graphics2D) g.create(); try{ paintWithoutForegroundPainter(g2d); } finally { g2d.dispose(); } } else if (fgPainter instanceof AbstractPainter && ((AbstractPainter<?>) fgPainter).getFilters().length > 0) { paintWithForegroundPainterWithFilters(g); } else { Graphics2D g2d = (Graphics2D) g.create(); try { paintWithForegroundPainterWithoutFilters(g2d); } finally { g2d.dispose(); } } } }
/** * {@inheritDoc} */ @Override protected void paintComponent(Graphics g) { if (fgPainter == null && bgPainter == null) { super.paintComponent(g); } else { if (fgPainter == null) { Graphics2D g2d = (Graphics2D) g.create(); try{ paintWithoutForegroundPainter(g2d); } finally { g2d.dispose(); } } else if (fgPainter instanceof AbstractPainter && ((AbstractPainter<?>) fgPainter).getFilters().length > 0) { paintWithForegroundPainterWithFilters(g); } else { Graphics2D g2d = (Graphics2D) g.create(); try { paintWithForegroundPainterWithoutFilters(g2d); } finally { g2d.dispose(); } } } }
/** * {@inheritDoc} */ @Override protected void paintComponent(Graphics g) { if (fgPainter == null && bgPainter == null) { super.paintComponent(g); } else { if (fgPainter == null) { Graphics2D g2d = (Graphics2D) g.create(); try{ paintWithoutForegroundPainter(g2d); } finally { g2d.dispose(); } } else if (fgPainter instanceof AbstractPainter && ((AbstractPainter<?>) fgPainter).getFilters().length > 0) { paintWithForegroundPainterWithFilters(g); } else { Graphics2D g2d = (Graphics2D) g.create(); try { paintWithForegroundPainterWithoutFilters(g2d); } finally { g2d.dispose(); } } } }
for (BufferedImageOp f : getFilters()) { cache = f.filter(cache, null);
/** * 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)); }
@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())); }
@Test @Override public void testDefaults() { assertThat(p.getFilters().length, is(0)); assertThat(p.getInterpolation(), is(AbstractPainter.Interpolation.NearestNeighbor)); assertThat(p.isAntialiasing(), is(true));
@Test @Override public void testDefaults() { assertThat(p.getFilters().length, is(0)); assertThat(p.getInterpolation(), is(AbstractPainter.Interpolation.NearestNeighbor)); assertThat(p.isAntialiasing(), is(true));