/**
     *
     */
    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);
        }
    }
예제 #2
0
    private void CreatePdfLegend(PdfContentByte content, Configuration.PrintTemplateContentRow row)
    {
        CreatePdfBox(content, row);

        LegendProperties properties = new LegendProperties(row);

        if (properties.NumColumns == 0)
        {
            return;
        }

        List <CommonLayer> layerList = GetLegendLayers();

        if (layerList.Count == 0)
        {
            return;
        }

        Configuration config = AppContext.GetConfiguration();

        Configuration.MapTabRow mapTab    = config.MapTab.FindByMapTabID(_appState.MapTab);
        CommonDataFrame         dataFrame = AppContext.GetDataFrame(mapTab);
        List <CommonLayer>      topLayers = dataFrame.TopLevelLayers;

        properties.CurrentX      = 0;
        properties.CurrentY      = properties.Height;
        properties.CurrentColumn = 1;

        bool full = false;

        for (int i = 0; i < topLayers.Count && !full; ++i)
        {
            full = CreateLayerInLegend(content, mapTab, layerList, properties, topLayers[i], 0);
        }
    }
예제 #3
0
    private float GetLayerHeightInLegend(List <CommonLayer> layerList, LegendProperties properties, CommonLayer layer)
    {
        float height = 0;

        if (layer.Type == CommonLayerType.Group)
        {
            height = properties.FontSize + properties.LayerSpacing;

            foreach (CommonLayer childLayer in layer.Children)
            {
                if (layerList.Contains(childLayer))
                {
                    height += GetLayerHeightInLegend(layerList, properties, childLayer);
                    break;
                }
            }
        }
        else
        {
            int numClasses = GetNumClasses(layer);

            if (numClasses > 1)
            {
                height = properties.FontSize + properties.ClassSpacing;
            }

            height += numClasses * (properties.SwatchHeight + properties.ClassSpacing) - properties.ClassSpacing;
        }

        return(height);
    }
예제 #4
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);
        }
예제 #5
0
    private bool CreateLayerInLegend(PdfContentByte content, Configuration.MapTabRow mapTab, List <CommonLayer> layerList, LegendProperties properties, CommonLayer layer, float indent)
    {
        if (!layerList.Contains(layer))
        {
            return(false);
        }

        float layerHeight = GetLayerHeightInLegend(layerList, properties, layer);

        if (properties.CurrentY < properties.Height && properties.CurrentY - layerHeight < 0)
        {
            if (properties.CurrentColumn == properties.NumColumns)
            {
                return(true);
            }

            properties.CurrentX      += properties.ColumnWidth + properties.ColumnSpacing;
            properties.CurrentY       = properties.Height;
            properties.CurrentColumn += 1;
        }

        int numClasses = GetNumClasses(layer);

        Configuration.LayerRow configLayer = mapTab.GetMapTabLayerRows().Where(o => String.Compare(o.LayerRow.LayerName, layer.Name, true) == 0).Select(o => o.LayerRow).FirstOrDefault();
        string layerName = configLayer != null && !configLayer.IsDisplayNameNull() ? configLayer.DisplayName : layer.Name;

        // write the layer name

        if (layer.Type == CommonLayerType.Group || numClasses > 1)
        {
            properties.CurrentY -= properties.FontSize;
            string name = layerName;

            try
            {
                while (content.GetEffectiveStringWidth(name, false) > properties.ColumnWidth - indent)
                {
                    name = name.Substring(0, name.Length - 1);
                }
            }
            catch { }

            content.BeginText();
            content.SetFontAndSize(properties.BaseFont, properties.FontSize);
            content.SetRGBColorFill(0, 0, 0);
            content.ShowTextAligned(PdfContentByte.ALIGN_LEFT, name, properties.OriginX + properties.CurrentX + indent, properties.OriginY + properties.CurrentY + (properties.SwatchHeight - properties.FontSize) / 2, 0);
            content.EndText();
        }

        if (layer.Type == CommonLayerType.Group)
        {
            properties.CurrentY -= properties.LayerSpacing;

            foreach (CommonLayer childLayer in layer.Children)
            {
                CreateLayerInLegend(content, mapTab, layerList, properties, childLayer, indent + 1.5f * properties.FontSize);
            }
        }
        else
        {
            properties.CurrentY -= properties.ClassSpacing;

            foreach (CommonLegendGroup legendGroup in layer.Legend.Groups)
            {
                foreach (CommonLegendClass legendClass in legendGroup.Classes)
                {
                    if (!legendClass.ImageIsTransparent)
                    {
                        properties.CurrentY -= properties.SwatchHeight;

                        MemoryStream          stream = new MemoryStream(legendClass.Image);
                        System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(stream);
                        float w = properties.SwatchHeight * bitmap.Width / bitmap.Height;

                        iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(legendClass.Image);
                        image.SetAbsolutePosition(properties.OriginX + properties.CurrentX + indent, properties.OriginY + properties.CurrentY - properties.SwatchHeight * 0.1f);
                        image.ScaleAbsolute(w, properties.SwatchHeight);
                        content.AddImage(image);

                        string label = numClasses > 1 ? legendClass.Label : layerName;

                        try
                        {
                            while (content.GetEffectiveStringWidth(label, false) > properties.ColumnWidth - properties.SwatchWidth - properties.ClassSpacing)
                            {
                                label = label.Substring(0, label.Length - 1);
                            }
                        }
                        catch { }

                        content.BeginText();
                        content.SetFontAndSize(properties.BaseFont, properties.FontSize);
                        content.SetRGBColorFill(0, 0, 0);
                        content.ShowTextAligned(PdfContentByte.ALIGN_LEFT, label, properties.OriginX + properties.CurrentX + indent + properties.SwatchWidth + properties.ClassSpacing, properties.OriginY + properties.CurrentY + (properties.SwatchHeight - properties.FontSize) / 2, 0);
                        content.EndText();

                        properties.CurrentY -= properties.ClassSpacing;
                    }
                }
            }

            properties.CurrentY -= properties.LayerSpacing - properties.ClassSpacing;
        }

        return(false);
    }
예제 #6
0
파일: PdfMap.cs 프로젝트: ClaireBrill/GPV
  private float GetLayerHeightInLegend(List<CommonLayer> layerList, LegendProperties properties, CommonLayer layer)
  {
    float height = 0;

    if (layer.Type == CommonLayerType.Group)
    {
      height = properties.FontSize + properties.LayerSpacing;

      foreach (CommonLayer childLayer in layer.Children)
      {
        if (layerList.Contains(childLayer))
        {
          height += GetLayerHeightInLegend(layerList, properties, childLayer);
          break;
        }
      }
    }
    else
    {
      int numClasses = GetNumClasses(layer);

      if (numClasses > 1)
      {
        height = properties.FontSize + properties.ClassSpacing;
      }

      height += numClasses * (properties.SwatchHeight + properties.ClassSpacing) - properties.ClassSpacing;
    }

    return height;
  }
예제 #7
0
파일: PdfMap.cs 프로젝트: ClaireBrill/GPV
	private void CreatePdfLegend(PdfContentByte content, Configuration.PrintTemplateContentRow row)
	{
		CreatePdfBox(content, row);

    LegendProperties properties = new LegendProperties(row);

    if (properties.NumColumns == 0)
    {
      return;
    }

    List<CommonLayer> layerList = GetLegendLayers();

    if (layerList.Count == 0)
    {
      return;
    }

    Configuration config = AppContext.GetConfiguration();
    Configuration.MapTabRow mapTab = config.MapTab.FindByMapTabID(_appState.MapTab);
    CommonDataFrame dataFrame = AppContext.GetDataFrame(mapTab);
    List<CommonLayer> topLayers = dataFrame.TopLevelLayers;

		properties.CurrentX = 0;
    properties.CurrentY = properties.Height;
    properties.CurrentColumn = 1;

    bool full = false;

    for (int i = 0; i < topLayers.Count && !full; ++i)
    {
      full = CreateLayerInLegend(content, mapTab, layerList, properties, topLayers[i], 0);
    }
	}
예제 #8
0
파일: PdfMap.cs 프로젝트: ClaireBrill/GPV
  private bool CreateLayerInLegend(PdfContentByte content, Configuration.MapTabRow mapTab, List<CommonLayer> layerList, LegendProperties properties, CommonLayer layer, float indent)
  {
    if (!layerList.Contains(layer))
    {
      return false;
    }

    float layerHeight = GetLayerHeightInLegend(layerList, properties, layer);

    if (properties.CurrentY < properties.Height && properties.CurrentY - layerHeight < 0)
    {
      if (properties.CurrentColumn == properties.NumColumns)
      {
        return true;
      }

      properties.CurrentX += properties.ColumnWidth + properties.ColumnSpacing;
      properties.CurrentY = properties.Height;
      properties.CurrentColumn += 1;
    }

    int numClasses = GetNumClasses(layer);

    Configuration.LayerRow configLayer = mapTab.GetMapTabLayerRows().Where(o => String.Compare(o.LayerRow.LayerName, layer.Name, true) == 0).Select(o => o.LayerRow).FirstOrDefault();
    string layerName = configLayer != null && !configLayer.IsDisplayNameNull() ? configLayer.DisplayName : layer.Name;

    // write the layer name

    if (layer.Type == CommonLayerType.Group || numClasses > 1)
    {
      properties.CurrentY -= properties.FontSize;
      string name = layerName;

      try
      {
        while (content.GetEffectiveStringWidth(name, false) > properties.ColumnWidth - indent)
        {
          name = name.Substring(0, name.Length - 1);
        }
      }
      catch { }

      content.BeginText();
      content.SetFontAndSize(properties.BaseFont, properties.FontSize);
      content.SetRGBColorFill(0, 0, 0);
      content.ShowTextAligned(PdfContentByte.ALIGN_LEFT, name, properties.OriginX + properties.CurrentX + indent, properties.OriginY + properties.CurrentY + (properties.SwatchHeight - properties.FontSize) / 2, 0);
      content.EndText();
    }

    if (layer.Type == CommonLayerType.Group)
    {
      properties.CurrentY -= properties.LayerSpacing;

      foreach (CommonLayer childLayer in layer.Children)
      {
        CreateLayerInLegend(content, mapTab, layerList, properties, childLayer, indent + 1.5f * properties.FontSize);
      }
    }
    else
    {
      properties.CurrentY -= properties.ClassSpacing;

      foreach (CommonLegendGroup legendGroup in layer.Legend.Groups)
      {
        foreach (CommonLegendClass legendClass in legendGroup.Classes)
        {
          if (!legendClass.ImageIsTransparent)
          {
            properties.CurrentY -= properties.SwatchHeight;

            MemoryStream stream = new MemoryStream(legendClass.Image);
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(stream);
            float w = properties.SwatchHeight * bitmap.Width / bitmap.Height;

            iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(legendClass.Image);
            image.SetAbsolutePosition(properties.OriginX + properties.CurrentX + indent, properties.OriginY + properties.CurrentY - properties.SwatchHeight * 0.1f);
            image.ScaleAbsolute(w, properties.SwatchHeight);
            content.AddImage(image);

            string label = numClasses > 1 ? legendClass.Label : layerName;

            try
            {
              while (content.GetEffectiveStringWidth(label, false) > properties.ColumnWidth - properties.SwatchWidth - properties.ClassSpacing)
              {
                label = label.Substring(0, label.Length - 1);
              }
            }
            catch { }

            content.BeginText();
            content.SetFontAndSize(properties.BaseFont, properties.FontSize);
            content.SetRGBColorFill(0, 0, 0);
            content.ShowTextAligned(PdfContentByte.ALIGN_LEFT, label, properties.OriginX + properties.CurrentX + indent + properties.SwatchWidth + properties.ClassSpacing, properties.OriginY + properties.CurrentY + (properties.SwatchHeight - properties.FontSize) / 2, 0);
            content.EndText();

            properties.CurrentY -= properties.ClassSpacing;
          }
        }
      }

      properties.CurrentY -= properties.LayerSpacing - properties.ClassSpacing;
    }

    return false;
  }