Example #1
0
        public static Image createTransparentImage(Image paramImage, float paramFloat)
        {
            BufferedImage bufferedImage1 = createBufferedImage(paramImage, 1, paramImage.getWidth(null), paramImage.getHeight(null));
            BufferedImage bufferedImage2 = new BufferedImage(bufferedImage1.Width, bufferedImage1.Height, 3);
            Graphics2D    graphics2D     = bufferedImage2.createGraphics();

            graphics2D.Composite = AlphaComposite.getInstance(3, paramFloat);
            graphics2D.drawImage(bufferedImage1, null, 0, 0);
            graphics2D.dispose();
            return(bufferedImage2);
        }
Example #2
0
        protected internal virtual void paintPopupActionIcon(Graphics paramGraphics, Rectangle paramRectangle)
        {
            bool       @bool      = (this.commandButton is JCommandButton && ((JCommandButton)this.commandButton).PopupModel.Enabled) ? 1 : 0;
            Graphics2D graphics2D = (Graphics2D)paramGraphics.create();

            if (!@bool)
            {
                graphics2D.Composite = AlphaComposite.getInstance(3, 0.5F);
            }
            this.popupActionIcon.paintIcon(this.commandButton, graphics2D, paramRectangle.x, paramRectangle.y);
            graphics2D.dispose();
        }
        //@Deprecated
        public void drawRect(Rectangle rect, Graphics2D g, Color outlineColor, Color fillColor, float alpha)
        {
            Color      originalColor = g.getColor();
            Graphics2D g2            = (Graphics2D)g;

            g2.setColor(outlineColor);
            g2.drawRect(rect.x - (int)this.x + boardHalfWidth,
                        rect.y - (int)this.y + boardHalfHeight, rect.width, rect.height);
            g2.setColor(fillColor);
            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
            g2.fillRect(rect.x - (int)this.x + boardHalfWidth,
                        rect.y - (int)this.y + boardHalfHeight, rect.width - 1, rect.height - 1);
            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
            //g2.setColor(originalColor);
        }
Example #4
0
            public virtual void paintIcon(Component param1Component, Graphics param1Graphics, int param1Int1, int param1Int2)
            {
                Graphics2D graphics2D = (Graphics2D)param1Graphics;
                int        i          = (this.dim.width > TRIANGLE.width) ? (param1Int1 + this.dim.width / 2 - TRIANGLE.width / 2) : param1Int1;
                int        j          = (this.dim.height > TRIANGLE.height) ? (param1Int2 + this.dim.height / 2 - TRIANGLE.height / 2) : param1Int2;
                Composite  composite  = graphics2D.Composite;

                graphics2D.translate(0, 1);
                graphics2D.Composite = AlphaComposite.getInstance(3, 0.5F);
                graphics2D.Color     = Color.WHITE;
                drawTriangle(graphics2D, i, j);
                graphics2D.Composite = composite;
                graphics2D.translate(0, -1);
                graphics2D.Color = C;
                drawTriangle(graphics2D, i, j);
            }
Example #5
0
        private void paint(Graphics g, IDisplay @object)
        {
            int cx     = @object.X;
            int cy     = @object.Y;
            int width  = @object.Width;
            int height = @object.Height;
            int x      = cx - width / 2;
            int y      = cy + height / 2;

            System.Drawing.Bitmap image = @object.AnimImage;

            float displayWidth  = Width;
            float displayHeight = Height;

            x      = System.Math.Round(x / (moviePlayerWidth / 2f) * (displayWidth / 2f) + (displayWidth / 2f));
            y      = System.Math.Round(-y / (moviePlayerHeight / 2f) * (displayHeight / 2f) + (displayHeight / 2f));
            width  = System.Math.Round(width / (moviePlayerWidth / displayWidth));
            height = System.Math.Round(height / (moviePlayerWidth / displayWidth));
            float alpha = @object.Alpha;

            if (log.TraceEnabled)
            {
                log.trace(string.Format("paint at ({0:D},{1:D}) {2:D}x{3:D} alpha={4:F} - image={5:D}x{6:D}, object={7}", x, y, width, height, alpha, image == null ? 0 : image.Width, image == null ? 0 : image.Height, @object));
            }

            if (image != null)
            {
                if (g is Graphics2D)
                {
                    AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha);
                    ((Graphics2D)g).Composite = ac;
                }
                g.drawImage(image, x, y, x + width - 1, y + height - 1, 0, 0, image.Width - 1, image.Height - 1, null);
            }
            else
            {
                g.Color = Color.BLACK;
                g.drawRect(x, y, width, height);
            }

            if (focus == @object)
            {
                g.Color = Color.RED;
                g.drawRect(x, y, width, height);
            }
        }
        //Override
        public override void debugDrawPolygon(Shape polygon, Color color, Point position, AffineTransform entityTransform, float alpha)
        { //OPTIMIZE
            AffineTransform cameraTransform = new AffineTransform();
            Graphics2D      g2Temp          = (Graphics2D)this.gBoard.create();

            this.gBoard.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

            cameraTransform.translate(this.getRelativeX(position.x), this.getRelativeY(position.y));
            //cameraTransform.concatenate(entityTransform);
            cameraTransform.scale(this.zoomFactor, this.zoomFactor);

            g2Temp.transform(cameraTransform);
            g2Temp.draw(polygon);
            g2Temp.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
            g2Temp.setColor(color);
            g2Temp.fill(polygon);
            g2Temp.dispose();
        }
        /** NOTE: Must create a new shape for some reason; don't pass a reference to an existing shape. Doubles the translation calculation.**/
        public void drawShapeInWorldSelectionRect(Shape shape, Point worldPosition, Color outlineColor, Color fillColor, float alpha, boolean isFilled)
        {
            AffineTransform cameraTransform = new AffineTransform();
            Graphics2D      g2Temp          = (Graphics2D)this.gBoard.create();

            g2Temp.setColor(outlineColor);
            g2Temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
            cameraTransform.translate(this.getRelativeX(worldPosition.x), this.getRelativeY(worldPosition.y));
            cameraTransform.scale(zoomFactor, zoomFactor);
            g2Temp.transform(cameraTransform);
            g2Temp.draw(shape);
            if (isFilled)
            {
                g2Temp.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
                g2Temp.setColor(fillColor);
                g2Temp.fill(shape);
            }
            g2Temp.dispose();
        }
        //@Override
        public override void draw(Image image, Point world_position, AffineTransform entityTransform, float alpha)
        {
            AffineTransform cameraTransform = new AffineTransform();
            Graphics2D      g2Temp          = (Graphics2D)this.gBoard.create();

            g2Temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

            cameraTransform.translate(
                this.getRelativeX(world_position.x) + this.translationComposite.getDX(),
                this.getRelativeY(world_position.y) + this.translationComposite.getDX());

            cameraTransform.concatenate(entityTransform);

            g2Temp.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));

            g2Temp.drawImage(image,
                             cameraTransform,
                             this.observer);

            g2Temp.dispose();
        }
        public void drawOnCamera(GraphicComposite.Static sprite, AffineTransform entityTransform)
        {
            AffineTransform cameraTransform = new AffineTransform();

            this.gBoard.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

            cameraTransform.translate(
                this.getRelativeX(sprite.ownerEntity().getX()),
                this.getRelativeY(sprite.ownerEntity().getY()));

            cameraTransform.scale(zoomFactor, zoomFactor);

            cameraTransform.concatenate(entityTransform);
            Composite compositeBuffer = this.gBoard.getComposite();

            this.gBoard.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)sprite.getSprite().getAlpha()));

            BufferedImage[][] tiledImage = sprite.getSprite().getBufferedImage();
            int tileSize = sprite.getSprite().getTileDimension();

            cameraTransform.translate(-tileSize, 0);

            for (int i = 0; i < tiledImage.length; ++i)
            {
                cameraTransform.translate(tileSize, 0);

                for (int j = 0; j < tiledImage[i].length; ++j)
                {
                    this.gBoard.drawImage(tiledImage[i][j],
                                          cameraTransform,
                                          this.observer);
                    cameraTransform.translate(0, tileSize);
                }

                cameraTransform.translate(0, -3 * tileSize);
            }

            this.gBoard.setComposite(compositeBuffer);
        }