List of usage examples for java.awt Dimension equals
public boolean equals(Object obj)
From source file:org.apache.fop.render.pcl.PCLGenerator.java
/** * Paint a bitmap at the current cursor position. The bitmap is converted to a monochrome * (1-bit) bitmap image./*from ww w . j a va2s . co m*/ * @param img the bitmap image * @param targetDim the target Dimention (in mpt) * @param sourceTransparency true if the background should not be erased * @throws IOException In case of an I/O error */ public void paintBitmap(RenderedImage img, Dimension targetDim, boolean sourceTransparency) throws IOException { double targetHResolution = img.getWidth() / UnitConv.mpt2in(targetDim.width); double targetVResolution = img.getHeight() / UnitConv.mpt2in(targetDim.height); double targetResolution = Math.max(targetHResolution, targetVResolution); int resolution = (int) Math.round(targetResolution); int effResolution = calculatePCLResolution(resolution, true); Dimension orgDim = new Dimension(img.getWidth(), img.getHeight()); Dimension effDim; if (targetResolution == effResolution) { effDim = orgDim; //avoid scaling side-effects } else { effDim = new Dimension((int) Math.ceil(UnitConv.mpt2px(targetDim.width, effResolution)), (int) Math.ceil(UnitConv.mpt2px(targetDim.height, effResolution))); } boolean scaled = !orgDim.equals(effDim); //ImageWriterUtil.saveAsPNG(img, new java.io.File("D:/text-0-org.png")); boolean monochrome = isMonochromeImage(img); if (!monochrome) { //Transparency mask disabled. Doesn't work reliably final boolean transparencyDisabled = true; RenderedImage mask = (transparencyDisabled ? null : getMask(img, effDim)); if (mask != null) { pushCursorPos(); selectCurrentPattern(0, 1); //Solid white setTransparencyMode(true, true); paintMonochromeBitmap(mask, effResolution); popCursorPos(); } RenderedImage red = BitmapImageUtil.convertToMonochrome(img, effDim, this.ditheringQuality); selectCurrentPattern(0, 0); //Solid black setTransparencyMode(sourceTransparency || mask != null, true); paintMonochromeBitmap(red, effResolution); } else { RenderedImage effImg = img; if (scaled) { effImg = BitmapImageUtil.convertToMonochrome(img, effDim); } setSourceTransparencyMode(sourceTransparency); selectCurrentPattern(0, 0); //Solid black paintMonochromeBitmap(effImg, effResolution); } }
From source file:org.kchine.r.server.impl.RGraphicsPanelRemote.java
public synchronized void paintComponent(Graphics g) { super.paintComponent(g); Dimension d = getSize(); if (!d.equals(_lastSize)) { _lastResizeTime = System.currentTimeMillis(); _lastSize = d;/*from w ww. j a v a2 s . c om*/ return; } else { } if (forceAntiAliasing) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } int i = 0, j = _l.size(); g.setFont(_gs.f); g.setClip(0, 0, d.width, d.height); // reset clipping rect g.setColor(Color.white); g.fillRect(0, 0, d.width, d.height); while (i < j) { GDObject o = (GDObject) _l.elementAt(i++); o.paint(this, _gs, g); } }