/// <summary> /// Default constructor /// </summary> /// <param name="result">LearnResult - learning result</param> /// <param name="chartFilename">string - char filename</param> /// <param name="includeDataTable">bool - true id learning data should be included</param> public HistoryPDF(LearnByErrorLibrary.LearnResult result, String chartFilename, bool includeDataTable = false) { this.result = result; this.chartFilename = chartFilename; document = new Document(); document.Info.Title = "NBN C# - wynik uczenia sieci neuronowej"; document.Info.Subject = "Uczenie sieci neuronowej za pomocą algorytmu NBN C#"; document.Info.Author = "Marek Bar 33808"; document.Info.Comment = "...ponieważ tylko dobry kod się liczy."; document.Info.Keywords = "C#, NBN, neuron, uczenie, sieć, nbn c#"; DefineStyles(document); DefineCover(document); DefineInfo(document, result); DefineChartArea(document, chartFilename, Path.GetFileNameWithoutExtension(result.Filename)); DefineWeightsSection(document, result); if (includeDataTable) { MatrixMB mat = MatrixMB.Load(result.Filename); AddMatrixTable(document, mat); } Section section = document.LastSection; section.AddPageBreak();//index of pages Paragraph paragraph = section.AddParagraph("Spis treści"); paragraph.Format.Font.Size = 14; paragraph.Format.Font.Bold = true; paragraph.Format.SpaceAfter = 24; paragraph.Format.OutlineLevel = OutlineLevel.Level1; paragraph = section.AddParagraph(); paragraph.Style = "TOC"; //first link Hyperlink hyperlink = paragraph.AddHyperlink("Informacje na temat sieci neuronowej"); hyperlink.AddText("\r\n" + "Informacje na temat sieci neuronowej" + "\t"); hyperlink.AddPageRefField("Informacje na temat sieci neuronowej"); hyperlink = paragraph.AddHyperlink("Wykres przebiegu uczenia"); hyperlink.AddText("\r\n" + "Wykres przebiegu uczenia" + "\t"); hyperlink.AddPageRefField("Wykres przebiegu uczenia"); hyperlink = paragraph.AddHyperlink("Wagi otrzymane w procesie uczenia"); hyperlink.AddText("\r\n" + "Wagi otrzymane w procesie uczenia" + "\t"); hyperlink.AddPageRefField("Wagi otrzymane w procesie uczenia"); if (includeDataTable) { hyperlink = paragraph.AddHyperlink("Dane wejściowe"); hyperlink.AddText("\r\n" + "Dane wejściowe" + "\t"); hyperlink.AddPageRefField("Dane wejściowe"); } }
/// <summary> /// Adds learning data /// </summary> /// <param name="document">Document - pdf document</param> /// <param name="mat">MatrixMB - matrix object</param> private static void AddMatrixTable(Document document, LearnByErrorLibrary.MatrixMB mat) { try { var name = "Dane wejściowe" + " " + (mat.Name != "" ? " - " + mat.Name : ""); Paragraph paragraph = document.LastSection.AddParagraph(name, "Heading2"); paragraph.AddBookmark("Dane wejściowe"); Table table = new Table(); table.Borders.Width = 0.75; for (int col = 0; col < mat.Cols; col++) { Column column = table.AddColumn(Unit.FromCentimeter(1.5)); column.Format.Alignment = ParagraphAlignment.Center; } for (int r = 0; r < mat.Rows; r++) { Row row = table.AddRow(); row.Shading.Color = r % 2 == 0 ? Colors.LightGray : Colors.LightBlue; for (int c = 0; c < mat.Cols; c++) { Cell cell = row.Cells[c]; cell.AddParagraph(mat.Data[r][c].ToString()); } } table.SetEdge(0, 0, mat.Cols, mat.Rows, Edge.Box, BorderStyle.Single, 0.5, Colors.Black); document.LastSection.Add(table); } catch (Exception ex) { ex.ToLog(); } }