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); }
public void drawTempContent(Graphics2D g2d) { // PaintUtil.drawTempContent(g2d, getTempContentManager()); if (getTempContentManager() != null && getTempContentManager().getTempContent() != null) { for (Iterator<Object> it = getTempContentManager().getTempContent().iterator(); it.hasNext(); ) { Object o = it.next(); if (o != null) { if (o instanceof DrawComponent) { DrawComponent dc = (DrawComponent) o; Renderer r = null; if (dc.getRoot() != null) { r = dc.getRenderer(); } if (r == null) { String renderMode = dc.getRenderMode(); r = getDrawComponent() .getRenderModeManager() .getRenderer(renderMode, dc.getRenderModeClass().getName()); } RenderUtil.paintJ2DRenderer(r, dc, g2d); } else if (o instanceof JToolTip) { // TODO: find out why Tooltips are not painted at given location JToolTip tooltip = (JToolTip) o; tooltip.setComponent(this); tooltip.paint(g2d); logger.debug("TooltTip painted!"); // $NON-NLS-1$ logger.debug("TooltTip Location = " + tooltip.getLocation()); // $NON-NLS-1$ } else if (o instanceof Component) { Component c = (Component) o; c.paint(g2d); } } } } }
/** * paints the drawComponent, if no notifyChange has been called a BitBlockTransfer from the * BufferedImage is performed */ @Override // public void paint(Graphics g) public void paintComponent(Graphics g) { if (disposed) return; if (dc == null || dc.isDisposed()) return; Graphics2D g2d = (Graphics2D) g; long startPaintTime = 0; if (debugPaint) { startPaintTime = System.currentTimeMillis(); } if (isChanged) { if (debugPaint) logger.debug("buffer cleared!"); // $NON-NLS-1$ viewImage = null; paintDrawComponent(); isChanged = false; } if (bufferedImage != null) { long startTime = 0; if (debugPaint) startTime = System.currentTimeMillis(); // Do a BitBlock Transfer calcBufferedViewImage(); if (viewImage != null) { g2d.drawImage(viewImage, 0, 0, this); } if (debugPaint) logger.debug( "BitBlockTransfer took " + (System.currentTimeMillis() - startTime) + " ms!"); //$NON-NLS-1$ //$NON-NLS-2$ if (debugBounds) { if (viewImage != null) { logger.debug("viewImage width = " + viewImage.getWidth()); // $NON-NLS-1$ logger.debug("viewImage height = " + viewImage.getHeight()); // $NON-NLS-1$ } } } // Draw Temporary Content above Buffer (SelectionRectangle etc.) if (drawTempContent == true) { long begin = System.currentTimeMillis(); g2d.translate(-getOffsetX(), -getOffsetY()); g2d.scale(getScale(), getScale()); drawTempContent(g2d); if (debugPaint) { logger.debug( "Draw Temp Content took " + (System.currentTimeMillis() - begin) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$ } } if (debugPaint) { logger.debug( "Total Paint took " + (System.currentTimeMillis() - startPaintTime) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$ logger.debug(""); // $NON-NLS-1$ } }