/**
     *
     */
    override public void afterReportInit()
    {
        try
        {
            AreaChartProperties areaChartProperties = new AreaChartProperties();

            double[][] data = new double[][] { new double[] { 10, 15, 30, 53 },
                                               new double[] { 6, 30, 10, 21 }, new double[] { 20, 25, 20, 8 } };
            Paint[]          paints           = { new Color(0, 255, 0, 100), new Color(255, 0, 0, 100), new Color(0, 0, 255, 100) };
            string[]         legendLabels     = { "Games", "Events", "Players" };
            AxisChartDataSet axisChartDataSet = new AxisChartDataSet(data, legendLabels, paints, ChartType.AREA, areaChartProperties);

            string[]   axisLabels = { "January", "March", "May", "June" };
            DataSeries dataSeries = new DataSeries(axisLabels, "Months", "People", "Popular Events");
            dataSeries.addIAxisPlotDataSet(axisChartDataSet);

            ChartProperties chartProperties = new ChartProperties();
            AxisProperties  axisProperties  = new AxisProperties();
            axisProperties.setYAxisRoundValuesToNearest(0);
            LegendProperties legendProperties = new LegendProperties();

            AxisChart axisChart = new AxisChart(dataSeries, chartProperties, axisProperties, legendProperties, 500, 350);

            BufferedImage bufferedImage = new BufferedImage(500, 350, BufferedImage.TYPE_INT_RGB);

            axisChart.setGraphics2D(bufferedImage.createGraphics());
            axisChart.render();

            base.setVariableValue("ChartImage", bufferedImage);
        }
        catch (ChartDataException chartDataException)
        {
            throw new JRScriptletException(chartDataException);
        }
    }
        private BufferedImage toBufferedImage(BitMatrix bitMatrix)
        {
            if (bitMatrix == null)
            {
                throw new IllegalArgumentException("BitMatrix cannot be null");
            }
            int           width  = bitMatrix.getWidth();
            int           height = bitMatrix.getHeight();
            BufferedImage image  = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED);

            image.createGraphics();
            Graphics2D graphics = (Graphics2D)image.getGraphics();

            graphics.setColor(Color.WHITE);
            graphics.fillRect(0, 0, width, height);
            graphics.setColor(Color.BLACK);
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    if (bitMatrix.get(i, j))
                    {
                        graphics.fillRect(i, j, 1, 1);
                    }
                }
            }
            return(image);
        }
예제 #3
0
        public JXMapViewer()
        {
            if (!InstanceFieldsInitialized)
            {
                InitializeInstanceFields();
                InstanceFieldsInitialized = true;
            }
            PanMouseInputListener panMouseInputListener = new PanMouseInputListener(this, null);

            RecenterOnClickEnabled = false;
            addMouseListener(panMouseInputListener);
            addMouseMotionListener(panMouseInputListener);
            addMouseWheelListener(new ZoomMouseWheelListener(this, null));
            addKeyListener(new PanKeyListener(this, null));
            try
            {
                URL uRL = this.GetType().getResource("mapviewer/resources/loading.png");
                LoadingImage = ImageIO.read(uRL);
            }
            catch (Exception)
            {
                Console.WriteLine("could not load 'loading.png'");
                BufferedImage bufferedImage = new BufferedImage(16, 16, 2);
                Graphics2D    graphics2D    = bufferedImage.createGraphics();
                graphics2D.Color = Color.black;
                graphics2D.fillRect(0, 0, 16, 16);
                graphics2D.dispose();
                LoadingImage = bufferedImage;
            }
            BackgroundPainter = new AbstractPainterAnonymousInnerClass(this);
        }
예제 #4
0
        private void GenerateAuthorList()
        {
            const float  shadow_shift = 2f;
            const string font_name    = "Arial";
            const int    font_size    = 10;
            Font         font         = new Font(font_name, java.awt.Font.PLAIN, font_size);
            Dimension    size         = cadencii.apputil.Util.measureString("Qjqp", font);
            float        width        = this.Width;
            float        height       = size.height;

            //StringFormat sf = new StringFormat();
            m_scroll = new BufferedImage((int)width, (int)(40f + m_credit.Length * height * 1.1f), BufferedImage.TYPE_INT_BGR);
            Graphics2D g = m_scroll.createGraphics();

            //sf.Alignment = StringAlignment.Center;
            g.setFont(new Font(font_name, java.awt.Font.BOLD, (int)(font_size * 1.1f)));
            if (m_shadow_enablde)
            {
                g.setColor(new Color(0, 0, 0, 40));
                g.drawString(m_app_name, shadow_shift, shadow_shift);   //, width, height ), sf );
            }
            g.setColor(Color.black);
            g.drawString(m_app_name, 0f, 0f);   //, width, height ), sf );
            for (int i = 0; i < m_credit.Length; i++)
            {
                g.setFont(new Font(font_name, m_credit[i].getStyle(), font_size));
                if (m_shadow_enablde)
                {
                    g.setColor(new Color(0, 0, 0, 40));
                    g.drawString(m_credit[i].getName(), 0f + shadow_shift, 40f + i * height * 1.1f + shadow_shift);   //, width, height ), sf );
                }
                g.setColor(Color.black);
                g.drawString(m_credit[i].getName(), 0f, 40f + i * height * 1.1f);  // , width, height ), sf );
            }
        }
예제 #5
0
        /// <summary>
        /// Resize image to specified dimensions
        /// </summary>
        /// <param name="image"> image to resize </param>
        /// <param name="width"> new image width </param>
        /// <param name="height"> new image height </param>
        /// <returns> resized image </returns>
        public static BufferedImage resizeImage(BufferedImage image, int width, int height)
        {
            BufferedImage resizedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
            Graphics2D    g            = resizedImage.createGraphics();

            g.drawImage(image, 0, 0, width, height, null);
            g.dispose();
            return(resizedImage);
        }
예제 #6
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);
        }
        public static BufferedImage convertToBufferedImage(java.awt.Image image)
        {
            BufferedImage newImage = new BufferedImage(
                image.getWidth(null), image.getHeight(null),
                BufferedImage.TYPE_INT_ARGB);
            Graphics2D g = newImage.createGraphics();

            g.drawImage(image, 0, 0, null);
            g.dispose();
            return(newImage);
        }
        private ImageIcon createIconWithBackground(string paramString, Color paramColor)
        {
            ImageIcon     imageIcon     = createIcon(paramString);
            BufferedImage bufferedImage = new BufferedImage(imageIcon.IconWidth, imageIcon.IconHeight, 1);
            Graphics2D    graphics2D    = bufferedImage.createGraphics();

            graphics2D.Color = paramColor;
            graphics2D.fillRect(0, 0, bufferedImage.Width, bufferedImage.Height);
            graphics2D.drawImage(imageIcon.Image, 0, 0, null);
            graphics2D.dispose();
            return(new ImageIcon(bufferedImage));
        }
예제 #9
0
        public virtual BufferedImage resize(BufferedImage img, int newW, int newH)
        {
            int           w    = img.Width;
            int           h    = img.Height;
            BufferedImage dimg = dimg = new BufferedImage(newW, newH, img.Type);
            Graphics2D    g    = dimg.createGraphics();

            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
            g.drawImage(img, 0, 0, newW, newH, 0, 0, w, h, null);
            g.dispose();
            return(dimg);
        }
예제 #10
0
        private static BufferedImage MPIMaster(RGBDisplayModel model, int mask)
        {
            int n = Communicator.world.Size;

            ArrayList <BufferedImage> chunks = model.splitImage(model.getOriginalImage(), 100);

            for (int i = 1; i < n; i++)
            {
                ArrayList <ImageIcon> imageList = new ArrayList <ImageIcon>();
                for (int j = 1; j < n; j++)
                {
                    try
                    {
                        imageList.Add(new ImageIcon(chunks[(i - 1) * (n - 1) + (j - 1)]));
                    }
                    catch { Exception e; }
                    { }
                }
                Communicator.world.Send(imageList, i, 0);
                Communicator.world.Send(mask, i, 0);
            }

            ArrayList <ImageIcon> resultsIcon = new ArrayList <ImageIcon>();

            for (int i = 1; i < n; i++)
            {
                ArrayList <ImageIcon> aux = Communicator.world.Receive <ArrayList <ImageIcon> >(i, 0);
                resultsIcon.AddAll(aux);
            }

            ArrayList <BufferedImage> results = new ArrayList <BufferedImage>();

            //Convert imageIcon to BufferedImage
            foreach (ImageIcon image in resultsIcon)
            {
                results.Add(convertToBufferedImage(image.getImage()));
            }

            BufferedImage resultImage   = new BufferedImage(model.getOriginalImage().getWidth(), model.getOriginalImage().getHeight(), model.getOriginalImage().getType());
            int           howManyOnLine = (int)Math.Sqrt(results.ToArray().Length);


            for (int i = 0; i < howManyOnLine; i++)
            {
                for (int j = 0; j < howManyOnLine; j++)
                {
                    resultImage.createGraphics().drawImage(results.ElementAt(i * howManyOnLine + j), 100 * i, 100 * j, null);
                }
            }

            return(resultImage);
        }
예제 #11
0
        public static BufferedImage createBufferedImage(Image paramImage, int paramInt1, int paramInt2, int paramInt3)
        {
            if ((paramInt1 == 1 || paramInt1 == 3) && hasAlpha(paramImage))
            {
                paramInt1 = 2;
            }
            else
            {
                paramInt1 = 1;
            }
            BufferedImage bufferedImage = new BufferedImage(paramInt2, paramInt3, paramInt1);
            Graphics2D    graphics2D    = bufferedImage.createGraphics();

            graphics2D.drawImage(paramImage, 0, 0, paramInt2, paramInt3, null);
            graphics2D.dispose();
            return(bufferedImage);
        }
예제 #12
0
        private BufferedImage createColorImage(BufferedImage originalImage, int mask)
        {
            //BufferedImage colorImage = new BufferedImage(originalImage.getWidth(),
            //    originalImage.getHeight(), originalImage.getType());

            //for (int x = 0; x < originalImage.getWidth(); x++)
            //{
            //    for (int y = 0; y < originalImage.getHeight(); y++)
            //    {
            //        int pixel = originalImage.getRGB(x, y) & mask;
            //        colorImage.setRGB(x, y, pixel);
            //    }
            //}

            //return colorImage;


            ArrayList <BufferedImage> resultList = new ArrayList <BufferedImage>();
            List <CreateImageThread>  threads    = new List <CreateImageThread>();

            int imgChunkSize = 100;
            ArrayList <BufferedImage> images = this.splitImage(originalImage, imgChunkSize);

            for (int i = 0; i < images.ToList().Count; i++)
            {
                CreateImageThread thread = new CreateImageThread();
                thread.run(images.ElementAt(i), mask, resultList, i);
                threads.Add(thread);
            }
            foreach (CreateImageThread thread in threads)
            {
                thread.ToString();
            }

            BufferedImage resultImage   = new BufferedImage(originalImage.getWidth(), originalImage.getHeight(), originalImage.getType());
            int           howManyOnLine = (int)Math.Sqrt(resultList.ToList().Count);

            for (int i = 0; i < howManyOnLine; i++)
            {
                for (int j = 0; j < howManyOnLine; j++)
                {
                    resultImage.createGraphics().drawImage(resultList.ElementAt(i * howManyOnLine + j), imgChunkSize * i, imgChunkSize * j, null);
                }
            }
            return(resultImage);
        }
예제 #13
0
        public static BufferedImage getJChart()
        {
            BufferedImage bufferedImage = null;

            try
            {
                //string reports_dir = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "reports");
                //string fileName = System.IO.Path.Combine(reports_dir, "AreaChart.jpg");
                //bufferedImage = ImageIO.read(new File(fileName));
                AreaChartProperties areaChartProperties = new AreaChartProperties();
                double[][]          data = new double[][] {
                    new double[] { 10, 15, 30, 53 },
                    new double[] { 6, 30, 10, 21 },
                    new double[] { 20, 25, 20, 8 }
                };
                Paint[]          paints           = { new Color(0, 255, 0, 100), new Color(255, 0, 0, 100), new Color(0, 0, 255, 100) };
                String[]         legendLabels     = { "Games", "Events", "Players" };
                AxisChartDataSet axisChartDataSet = new AxisChartDataSet(data, legendLabels, paints, ChartType.AREA, areaChartProperties);

                String[]   axisLabels = { "January", "March", "May", "June" };
                DataSeries dataSeries = new DataSeries(axisLabels, "Months", "People", "Popular Events");
                dataSeries.addIAxisPlotDataSet(axisChartDataSet);

                ChartProperties chartProperties = new ChartProperties();
                AxisProperties  axisProperties  = new AxisProperties();
                axisProperties.setYAxisRoundValuesToNearest(0);
                LegendProperties legendProperties = new LegendProperties();

                AxisChart axisChart = new AxisChart(dataSeries, chartProperties, axisProperties, legendProperties, 500, 350);

                bufferedImage = new BufferedImage(500, 350, BufferedImage.TYPE_INT_RGB);

                axisChart.setGraphics2D(bufferedImage.createGraphics());
                axisChart.render();
            }
            catch (ChartDataException chartDataException)

            {
                throw new JRScriptletException(chartDataException);
            }
            return(bufferedImage);
        }
예제 #14
0
        //this was moved from the overriden paintComponent()
        // instead it update the canvas BufferedImage and calls repaint()
        public virtual void updateCanvas()
        {
            Graphics2D g2 = canvas.createGraphics();

            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

            g2.Paint = Color;

            if (tool == 1)
            {
                g2.fillOval(currentX - ((int)value / 2), currentY - ((int)value / 2), (int)value, (int)value);
            }
            else if (tool == 2)
            {
                g2.Stroke = new BasicStroke((float)value, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
                g2.drawLine(oldX, oldY, currentX, currentY);
                g2.Stroke = new BasicStroke(1.0f);
            }
            repaint();
        }