Exemplo n.º 1
0
        internal GraphicsState(Graphics graphics, Matrix matrix, bool resetState)
        {
            _compositingMode    = graphics.CompositingMode;
            _compositingQuality = graphics.CompositingQuality;
            _clip              = graphics.ScaledClip;
            _baseClip          = graphics.NativeObject.getClip();
            _interpolationMode = graphics.InterpolationMode;
            _pageScale         = graphics.PageScale;
            _pageUnit          = graphics.PageUnit;
            _pixelOffsetMode   = graphics.PixelOffsetMode;

            // FIXME: render orign is not implemented yet
            //_renderingOrigin = new Point( g.RenderingOrigin.X, g.RenderingOrigin.Y );

            _smoothingMode = graphics.SmoothingMode;
            _transform     = graphics.Transform;
            _baseTransform = graphics.BaseTransform;

            _textContrast      = graphics.TextContrast;
            _textRenderingHint = graphics.TextRenderingHint;

            if (resetState)
            {
                ResetState(graphics, matrix);
            }
        }
		internal GraphicsState(Graphics graphics, Matrix matrix, bool resetState)
		{
			_compositingMode = graphics.CompositingMode;
			_compositingQuality = graphics.CompositingQuality;
			_clip = graphics.ScaledClip;
			_baseClip = graphics.NativeObject.getClip();
			_interpolationMode = graphics.InterpolationMode;
			_pageScale = graphics.PageScale;
			_pageUnit = graphics.PageUnit;
			_pixelOffsetMode = graphics.PixelOffsetMode;
			
			// FIXME: render orign is not implemented yet
			//_renderingOrigin = new Point( g.RenderingOrigin.X, g.RenderingOrigin.Y );

			_smoothingMode = graphics.SmoothingMode;
			_transform = graphics.Transform;
			_baseTransform = graphics.BaseTransform;

			_textContrast = graphics.TextContrast;
			_textRenderingHint = graphics.TextRenderingHint;

			if (resetState)
				ResetState(graphics, matrix);
		}
Exemplo n.º 3
0
 awt.Shape awt.Stroke.createStrokedShape(awt.Shape arg_0)
 {
     return(GetNativeObject(null, PenFit.NotThin).createStrokedShape(arg_0));
 }
 protected BasicShape(awt.Shape shape)
 {
     _shape = shape;
 }
		protected BasicShape(awt.Shape shape)
		{
			_shape = shape;
		}
//    protected void doDrawOnTo(BufferedImageRaster canvas)
//    {
//        Sector sector = this.getSector();
//        if (null == sector)
//        {
//            String message = Logging.getMessage("nullValue.SectorIsNull");
//            Logging.logger().severe(message);
//            throw new ArgumentException(message);
//        }
//
//        if (!sector.intersects(canvas.getSector()))
//        {
//            return;
//        }
//
//        BufferedImage transformedImage = null;
//        java.awt.Graphics2D g2d = null;
//        java.awt.Shape prevClip = null;
//        java.awt.Composite prevComposite = null;
//
//        try
//        {
//            int canvasWidth = canvas.getWidth();
//            int canvasHeight = canvas.getHeight();
//
//            // Apply the transform that correctly maps the image onto the canvas.
//            java.awt.geom.AffineTransform transform = this.computeSourceToDestTransform(
//                this.getWidth(), this.getHeight(), this.getSector(), canvasWidth, canvasHeight, canvas.getSector());
//
//            AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
//            Rectangle2D rect = op.getBounds2D(this.getBufferedImage());
//
//            int clipWidth = (int) Math.Ceiling((rect.getMaxX() >= canvasWidth) ? canvasWidth : rect.getMaxX());
//            int clipHeight = (int) Math.Ceiling((rect.getMaxY() >= canvasHeight) ? canvasHeight : rect.getMaxY());
//
//            if (clipWidth <= 0 || clipHeight <= 0)
//            {
//                return;
//            }
//
//            int transformedImageType = (BufferedImage.TYPE_CUSTOM != this.getBufferedImage().getType())
//                ? this.getBufferedImage().getType() : BufferedImage.TYPE_INT_ARGB;
//
//            transformedImage = new BufferedImage(clipWidth, clipHeight, transformedImageType);
//            op.filter(this.getBufferedImage(), transformedImage);
//
//            g2d = canvas.getGraphics();
//
//            prevClip = g2d.getClip();
//            prevComposite = g2d.getComposite();
//
//            // Set the alpha composite for appropriate alpha blending.
//            g2d.setComposite(java.awt.AlphaComposite.SrcOver);
//            g2d.drawImage(transformedImage, 0, 0, null);
//        }
//        catch (java.awt.image.ImagingOpException ioe)
//        {
//            // If we catch a ImagingOpException, then the transformed image has a width or height of 0.
//            // This indicates that there is no intersection between the source image and the canvas,
//            // or the intersection is smaller than one pixel.
//        }
//        catch (java.awt.image.RasterFormatException rfe)
//        {
//            // If we catch a RasterFormatException, then the transformed image has a width or height of 0.
//            // This indicates that there is no intersection between the source image and the canvas,
//            // or the intersection is smaller than one pixel.
//        }
//        finally
//        {
//            // Restore the previous clip, composite, and transform.
//            try
//            {
//                if (null != transformedImage)
//                {
//                    transformedImage.flush();
//                }
//
//                if (null != g2d)
//                {
//                    if (null != prevClip)
//                    {
//                        g2d.setClip(prevClip);
//                    }
//
//                    if (null != prevComposite)
//                    {
//                        g2d.setComposite(prevComposite);
//                    }
//                }
//            }
//            catch (Throwable t)
//            {
//                Logging.logger().log(java.util.logging.Level.FINEST, WWUtil.extractExceptionReason(t), t);
//            }
//        }
//    }

        protected void doDrawOnTo(BufferedImageRaster canvas)
        {
            Sector sector = this.getSector();

            if (null == sector)
            {
                String message = Logging.getMessage("nullValue.SectorIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (!sector.intersects(canvas.getSector()))
            {
                return;
            }

            java.awt.Graphics2D g2d = null;
            java.awt.Shape      prevClip = null;
            java.awt.Composite  prevComposite = null;
            java.lang.Object    prevInterpolation = null, prevAntialiasing = null;

            try
            {
                int canvasWidth  = canvas.getWidth();
                int canvasHeight = canvas.getHeight();

                // Apply the transform that correctly maps the image onto the canvas.
                java.awt.geom.AffineTransform transform = this.computeSourceToDestTransform(
                    this.getWidth(), this.getHeight(), this.getSector(), canvasWidth, canvasHeight, canvas.getSector());

                AffineTransformOp op   = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
                Rectangle2D       rect = op.getBounds2D(this.getBufferedImage());

                int clipWidth  = (int)Math.Ceiling((rect.getMaxX() >= canvasWidth) ? canvasWidth : rect.getMaxX());
                int clipHeight = (int)Math.Ceiling((rect.getMaxY() >= canvasHeight) ? canvasHeight : rect.getMaxY());

                if (clipWidth <= 0 || clipHeight <= 0)
                {
                    return;
                }

                g2d = canvas.getGraphics();

                prevClip          = g2d.getClip();
                prevComposite     = g2d.getComposite();
                prevInterpolation = g2d.getRenderingHint(RenderingHints.KEY_INTERPOLATION);
                prevAntialiasing  = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);

                // Set the alpha composite for appropriate alpha blending.
                g2d.setComposite(java.awt.AlphaComposite.SrcOver);
                g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

                g2d.drawImage(this.getBufferedImage(), transform, null);
            }
//        catch (java.awt.image.ImagingOpException ioe)
//        {
//            // If we catch a ImagingOpException, then the transformed image has a width or height of 0.
//            // This indicates that there is no intersection between the source image and the canvas,
//            // or the intersection is smaller than one pixel.
//        }
//        catch (java.awt.image.RasterFormatException rfe)
//        {
//            // If we catch a RasterFormatException, then the transformed image has a width or height of 0.
//            // This indicates that there is no intersection between the source image and the canvas,
//            // or the intersection is smaller than one pixel.
//        }
            catch (Throwable t)
            {
                String reason = WWUtil.extractExceptionReason(t);
                Logging.logger().log(java.util.logging.Level.SEVERE, reason, t);
            }
            finally
            {
                // Restore the previous clip, composite, and transform.
                try
                {
                    if (null != g2d)
                    {
                        if (null != prevClip)
                        {
                            g2d.setClip(prevClip);
                        }

                        if (null != prevComposite)
                        {
                            g2d.setComposite(prevComposite);
                        }

                        if (null != prevInterpolation)
                        {
                            g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, prevInterpolation);
                        }

                        if (null != prevAntialiasing)
                        {
                            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, prevAntialiasing);
                        }
                    }
                }
                catch (Throwable t)
                {
                    Logging.logger().log(java.util.logging.Level.FINEST, WWUtil.extractExceptionReason(t), t);
                }
            }
        }