public DisplayPanel(DrawComponent dc) { super(); this.dc = dc; // setDebug(false, true); dc.clearBounds(); Rectangle dcBounds = new Rectangle(dc.getBounds()); AffineTransform at = new AffineTransform(); at.translate(-dcBounds.x, -dcBounds.y); if (debugBounds) { logger.debug("init dcBounds " + dcBounds); // $NON-NLS-1$ logger.debug("translateX = " + (-dcBounds.x)); // $NON-NLS-1$ logger.debug("translateY = " + (-dcBounds.y)); // $NON-NLS-1$ } dc.transform(at); dc.clearBounds(); if (debugBounds) logger.debug("translated dcBounds = " + dc.getBounds()); // $NON-NLS-1$ dcBounds = GeomUtil.translateToOriginAndAdjustSize(dc.getBounds()); // dcBounds = GeomUtil.translateToOrigin(dc.getBounds()); if (debugBounds) logger.debug("translateToOriginAndAdjustSize dcBounds = " + dcBounds); // $NON-NLS-1$ setBackground(bgColor); renderingHintsManager.setRenderMode(RenderingHintsManager.RENDER_MODE_QUALITY); init(dcBounds); }
/** * @return a Rectangle which determines the Size of the BufferedImage to create If it fits the * size of the BufferedImage is viewBounds * bufferScaleFactor */ protected Rectangle getBufferRectangle() { // TODO: should be checked if width + height < 0 double bufferScaleFactor = BufferManager.sharedInstance().getBufferScaleFactor(); int bufferWidth = (int) (viewBounds.width * bufferScaleFactor); int bufferHeight = (int) (viewBounds.height * bufferScaleFactor); Rectangle newBufferBounds = new Rectangle( viewBounds.x - ((bufferWidth - viewBounds.width) / 2), viewBounds.y - ((bufferHeight - viewBounds.height) / 2), bufferWidth, bufferHeight); if (!isRectangleInReal(newBufferBounds)) { newBufferBounds = GeomUtil.checkBounds(newBufferBounds, realBounds); } newBufferBounds = checkOrigin(newBufferBounds); return newBufferBounds; }