protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); WhiteTexture = new Texture2D(GraphicsDevice, 10, 10, false, SurfaceFormat.Color); FontS = Content.Load <SpriteFont>("Fonts/Font1"); FontS.LineSpacing = 12; FontL = Content.Load <SpriteFont>("Fonts/Font2"); FontL.LineSpacing = 14; Logo = Content.Load <Texture2D>("Logo"); IntroShader = Content.Load <Effect>("Shaders/Intro"); DefaultFont = FontL; Color[] colorData = new Color[100]; for (int i = 0; i < 100; i++) { colorData[i] = Color.White; } WhiteTexture.SetData <Color>(colorData); layouter = new Layouter(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height); if (initialFile != "") { loadFile(initialFile); } }
private Result <None> ConfigureVisualizer(IImageSettings settings) { var analyzerResult = Analyzer.GetWordList() .Then(l => Analyzer.GetMaxFrequency()); if (!analyzerResult.IsSuccess) { return(Result.Fail <None>(analyzerResult.Error)); } foreach (var word in Analyzer.GetWordList().GetValueOrThrow().OrderByDescending(w => w.Frequency)) { const double scalingParameter = 0.65; var fontSize = 100f * (float)Math.Pow((double)word.Frequency / Analyzer.GetMaxFrequency().GetValueOrThrow(), scalingParameter); var result = settings.GetFont(fontSize) .Then(font => MeasureString(word.Value, font)) .Then(size => Layouter.PutNextRectangle(size.ToSize())) .Then(position => Visualizer.AddWord(word, position, settings.GetFont(fontSize).GetValueOrThrow())); if (!result.IsSuccess) { return(result); } } return(Result.Ok()); }
public void Start() { var ui = new UiElements(uiCache); using (var editor = ui.List.Edit()) { for (var y = 0; y < 5; ++y) { editor.Contents.Add(new UIFactory <Items, Title>((Title x) => { })); for (var i = 0; i < 5; ++i) { editor.Contents.Add(new UIFactory <Items, Title>(x => { using (var e = Layouter.LeftToRight(x.Item)) { e.Create(); e.Create(); e.Create(); } })); } } } }
public IEnumerable <Rectangle> PutRectanglesOnLayout(IEnumerable <Size> sizes) { foreach (var size in sizes) { yield return(Layouter.PutNextRectangle(size)); } }
private List <CloudItem> CreateItems(List <IWord> wordList) { SetUpLayouter(new Point(0, 0)); SetMinMaxWeight(wordList); var rectsToScale = new List <Rectangle>(); foreach (var word in wordList) { var rectSize = Measure(word.Text, word.Entries); var rectangle = Layouter.PutNextRectangle(rectSize); rectsToScale.Add(rectangle); } var backgroundSize = GetBackgroundSize(rectsToScale); var mainFrame = new Rectangle(new Point(0, 0), backgroundSize); SetUpLayouter(mainFrame.GetRectangleCenter()); var scaledRectangles = new List <Rectangle>(); foreach (var tempRectangle in rectsToScale) { var rect = Layouter.PutNextRectangle(tempRectangle.Size); scaledRectangles.Add(rect); } var items = new List <CloudItem>(); items.AddRange( wordList.Select((word, i) => new CloudItem(scaledRectangles[i], word, GetFont(word.Entries)))); return(items); }
private IEnumerable <Tag> InsertTagsInFrames(IEnumerable <Tag> tags) { foreach (var tag in tags) { var frame = Layouter.PutNextRectangle(tag.GetCeilingSize()); yield return(tag.InsertTagInFrame(frame)); } }
public void SetUp() { var canvas = new Canvas(800, 600); layouter = new Layouter(new Spiral(canvas), canvas); center = new Point(400, 300); rectangles = new List <Rectangle>(); }
private void RunDataReport(ReportModel reportModel, IDataManager data) { ILayouter layouter = new Layouter(); IReportCreator reportCreator = DataPageBuilder.CreateInstance(reportModel, data, layouter); reportCreator.SectionRendering += new EventHandler <SectionRenderEventArgs>(PushPrinting); reportCreator.PageCreated += OnPageCreated; reportCreator.BuildExportList(); ShowCompleted(); }
public IEnumerable <Tag> CreateTagsCloud(IEnumerable <string> words) { var interestingWords = WordHandler.NormalizeAndExcludeBoringWords(words); var readyTags = WordConverter.ConvertToTags(interestingWords) .Select(InsertTagInFrame) .OrderByDescending(t => t.Frequency); Layouter.Recreate(); return(readyTags); }
private void RunFormSheet(ReportModel reportModel) { Layouter layouter = new Layouter(); IReportCreator reportCreator = FormPageBuilder.CreateInstance(reportModel, layouter); reportCreator.SectionRendering += new EventHandler <SectionRenderEventArgs>(PushPrinting); reportCreator.PageCreated += OnPageCreated; reportCreator.BuildExportList(); ShowCompleted(); }
public void PutNextRectangle_ManyRectangles_CorrectLocation() { var allRect = new List <Rectangle>(); for (var i = 0; i < 7; i++) { allRect.Add(Layouter.PutNextRectangle(new Size(100, 100))); } (MaxCenterEnvirons(allRect) + MaxRectDiagonal(allRect)) .Should().BeLessThan(352); }
public void TearDown() { var testContext = TestContext.CurrentContext; if (testContext.Result.Outcome.Status != TestStatus.Failed) { return; } var image = Layouter.GetRectangles().CreateImage(ScaleFactor, new SolidBrush(Color.FromArgb(100, 100, 100, 255))); var imageDestination = Path.Combine(testContext.TestDirectory, testContext.Test.FullName + ".bmp"); image.Save(imageDestination); TestContext.Out.Write("Generated layout written in {0}", imageDestination); }
public Result <IEnumerable <Tag> > CreateTagsCloud(IEnumerable <string> words) { var readyTags = words.AsResult() .Then(WordHandler.NormalizeAndExcludeBoringWords) .Then(WordConverter.ConvertToTags) .ReplaceError(err => "MyStem.exe not found! " + "Please, go to: http://download.cdn.yandex.net/mystem/mystem-3.0-win7-32bit.zip" ) .Then(InsertTagsInFrames) .Then(tags => tags.OrderByDescending(t => t.Frequency).AsEnumerable()); Layouter.Reset(); return(readyTags); }
public static AbstractRenderer Create(IReportModel model,IDataManager container) { ReportDocument repDocumet = new ReportDocument(); if (model != null) { Layouter layouter = new Layouter(); switch (model.ReportSettings.ReportType) { case GlobalEnums.ReportType.FormSheet :{ return new RenderFormSheetReport(model,repDocumet,layouter); } case GlobalEnums.ReportType.DataReport:{ return new RenderDataReport(model,container,repDocumet,layouter); } } } throw new MissingModelException(); }
public void PutNextRectangle_QuantityOfRectangles_EqualsQuantity() { var allRect = new List <Rectangle>(); const int expectedQuantity = 5; var sizeOfRectangles = new Size[expectedQuantity]; for (var i = 0; i < expectedQuantity; i++) { sizeOfRectangles[i] = new Size(i + 1, i + 2); } foreach (var size in sizeOfRectangles) { allRect.Add(Layouter.PutNextRectangle(size)); } allRect.Count.Should().Be(expectedQuantity); }
private List <Rectangle> FillCloudWithRandRect(int expectedQuantity) { var allRect = new List <Rectangle>(); var sizeOfRectangles = new Size[expectedQuantity]; var rnd = new Random(); for (var i = 0; i < expectedQuantity; i++) { sizeOfRectangles[i] = new Size( i + rnd.Next(10, 300), i + rnd.Next(10, 300)); } foreach (var size in sizeOfRectangles) { allRect.Add(Layouter.PutNextRectangle(size)); } return(allRect); }
protected ExporterCollection ConvertSection(BaseSection section, int dataRow) { FireSectionRenderEvent(section, dataRow); PrintHelper.AdjustParent((BaseSection)section, section.Items); ExporterCollection list = new ExporterCollection(); if (section.Items.Count > 0) { Point offset = new Point(section.Location.X, section.SectionOffset); // Call layouter only once per section Rectangle desiredRectangle = Layouter.Layout(this.Graphics, section); Rectangle sectionRectangle = new Rectangle(section.Location, section.Size); if (!sectionRectangle.Contains(desiredRectangle)) { section.Size = new Size(section.Size.Width, desiredRectangle.Size.Height + GlobalValues.ControlMargins.Top + GlobalValues.ControlMargins.Bottom); } foreach (BaseReportItem item in section.Items) { ISimpleContainer container = item as ISimpleContainer; if (container != null) { ExportContainer exportContainer = StandardPrinter.ConvertToContainer(container, offset); StandardPrinter.AdjustBackColor(container); ExporterCollection clist = StandardPrinter.ConvertPlainCollection(container.Items, offset); exportContainer.Items.AddRange(clist); list.Add(exportContainer); } else { list = StandardPrinter.ConvertPlainCollection(section.Items, offset); } } } return(list); }
public static XmlDocument BpmnToXml(BpmGenome genome) { var xml = Base(); var process = xml.CreateElement("bpmn", "process", BpmnUri); process.SetAttribute("id", "Process_" + Guid.NewGuid()); process.SetAttribute("isExecutable", "false"); xml.DocumentElement.AppendChild(process); var start = StartEvent(process); var outgoing = GeneToXml(process, genome.RootGene, start); var end = EndEvent(process, outgoing); var diagram = xml.CreateElement("bpmndi", "BPMNDiagram", BpmndiUri); diagram.SetAttribute("id", "BPMNDiagram_" + Guid.NewGuid()); xml.DocumentElement.AppendChild(diagram); var plane = xml.CreateElement("bpmndi", "BPMNPlane", BpmndiUri); plane.SetAttribute("id", "BPMNPlane_" + Guid.NewGuid()); plane.SetAttribute("bpmnElement", process.GetAttribute("id")); diagram.AppendChild(plane); var layouter = new Layouter(xml.DocumentElement); layouter.auto(genome.RootGene, start, end); layouter.flows(process); foreach (var x in layouter.AllElements()) { plane.AppendChild(x); } return(xml); }
public override void LayoutCore() { const int indent = 18; Layouter.PutAt(this, CollapseButton, CollapseButton.Box.Margins.Left); Layouter.PutRight(CollapseButton, HMembers, indent - CollapseButton.Bounds.Size.X); CollapseButton.Bounds.Location.Y += (HMembers.Bounds.Size.Y - CollapseButton.Bounds.Size.Y) / 2; if (VMembers.Children.Count > 0) { CollapseButton.Visible = true; if (this.Collapsed) { VMembers.Visible = false; this.Bounds.Size.X = HMembers.Bounds.Right - this.Bounds.Location.X; this.Bounds.Size.Y = HMembers.Bounds.Bottom - this.Bounds.Location.Y; } else { VMembers.Visible = true; Layouter.PutUnder(HMembers, VMembers); this.Bounds.Size.X = HMembers.Bounds.Right - this.Bounds.Location.X; this.Bounds.Size.Y = VMembers.Bounds.Bottom - this.Bounds.Location.Y; Layouter.GrowToInclude(this, HMembers); Layouter.GrowToInclude(this, VMembers); this.Bounds.Size.Add(1); } } else { CollapseButton.Visible = false; VMembers.Visible = false; Layouter.PutAround(CollapseButton, HMembers, this); this.Bounds.Size.X = HMembers.Bounds.Right - this.Bounds.Location.X; this.Bounds.Size.Y = HMembers.Bounds.Bottom - this.Bounds.Location.Y; } }
/// <summary> /// 仮想化を実行します。 /// </summary> private void Present() { _presenting = false; if (Layouter == null) { return; } Layouter.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); var elements = new HashSet <ControlBase>(); var viewport = Viewport; _childRectDic.Clear(); Layouter.CalcRectDic(_childRectDic, new Point()); foreach (var item in _childRectDic) { if (viewport.IntersectsWith(item.Value)) { elements.Add(item.Key); } } // MEMO : 表示中のものを表示できる分だけのホストを作ります。 while (_visualChildren.Count < elements.Count) { var e = new VirtualElementHost(); AddVisualChild(e); _visualChildren.Add(e); _unusedElements.Add(e); } foreach (var c in _visualChildren) { if (c.Content != null && !elements.Contains(c.Content)) { _elements.Remove(c.Content); c.Content = null; c.Visibility = Visibility.Collapsed; _unusedElements.Add(c); } } foreach (var item in elements) { UIElement element; if (!_elements.TryGetValue(item, out element)) { var index = _unusedElements.Count - 1; var t = _unusedElements[index]; _unusedElements.RemoveAt(index); t.Content = item; t.Visibility = Visibility.Visible; _elements.Add(item, t); t.InvalidateMeasure(); t.InvalidateVisual(); } else { if (item.MeasureDirty) { element.InvalidateMeasure(); } if (item.ArrangeDirty) { element.InvalidateVisual(); } } } InvalidateMeasure(); InvalidateVisual(); }
/// <summary> /// /// </summary> /// <param name="reportModel"></param> /// <param name="list"></param> /// <param name="reportParameters"></param> /// <returns></returns> public static IReportCreator CreatePageBuilder (IReportModel reportModel, IList list, ReportParameters reportParameters) { if (reportModel == null) { throw new ArgumentNullException("reportModel"); } if (list == null) { throw new ArgumentNullException("list"); } ReportEngine.CheckForParameters(reportModel,reportParameters); IDataManager dataMan = DataManager.CreateInstance(list,reportModel.ReportSettings); if (dataMan != null) { Layouter layouter = new Layouter(); return DataPageBuilder.CreateInstance(reportModel,dataMan,layouter); } else { throw new MissingDataManagerException(); } }
private void RunDataReport (ReportModel reportModel,IDataManager data) { ILayouter layouter = new Layouter(); IReportCreator reportCreator = DataPageBuilder.CreateInstance(reportModel,data,layouter); reportCreator.SectionRendering += new EventHandler<SectionRenderEventArgs>(PushPrinting); reportCreator.PageCreated += OnPageCreated; reportCreator.BuildExportList(); ShowCompleted(); }
public AMF0ReflectionOptimizer(Type type, AMFReader reader) { _mappedClass = type; _reader = reader; _layouter = new Layouter(); }
public void PutNextRectangle_OneRectangle_CenterOfRectСalibration() { Layouter.PutNextRectangle(new Size(200, 100)).Location.Should().Be(new Point(400, 450)); }
private Tag InsertTagInFrame(Tag tag) { var frame = Layouter.PutNextRectangle(tag.GetCeilingSize()); return(tag.InsertTagInFrame(frame)); }
/// <summary> /// Use this method for pullData and FormSheet /// </summary> /// <param name="fileName"></param> /// <param name="reportParameters">null if no parameters are used</param> /// <returns><see cref="BasePager"</returns> public static IReportCreator CreatePageBuilder (string fileName, ReportParameters reportParameters) { if (String.IsNullOrEmpty(fileName)) { throw new ArgumentNullException("fileName"); } IReportModel reportModel = LoadReportModel (fileName); IReportCreator builder = null; Layouter layouter = new Layouter(); if (reportModel.DataModel == GlobalEnums.PushPullModel.FormSheet) { builder = FormPageBuilder.CreateInstance(reportModel,layouter); } else { CheckForParameters(reportModel,reportParameters); IDataManager dataMan = DataManagerFactory.CreateDataManager(reportModel,reportParameters); builder = DataPageBuilder.CreateInstance(reportModel, dataMan,layouter); } return builder; }
public void UpdateLayouter(CVType nComparativeType, SPType nSuperpositionType, int nVisualSpaceDim, int nParametersDim, List <ParameterNameValue> parameters) { Camera.main.transform.position = new Vector3(0, 0, -300); if (GameObject.Find("Composition") != null) { GameObject.DestroyImmediate(GameObject.Find("Composition")); } comparativeType = nComparativeType; visualSpaceDim = nVisualSpaceDim; parametersDim = nParametersDim; switch (comparativeType) { case CVType.Juxtaposition: { if (parametersDim == 1) { layouter = new LayouterStripes(); (layouter as LayouterStripes).mainParameter = ensemble.getParameter(1); (layouter as LayouterStripes).minValue = ensemble.parametersInfo[(layouter as LayouterStripes).mainParameter].minValue; (layouter as LayouterStripes).maxValue = ensemble.parametersInfo[(layouter as LayouterStripes).mainParameter].maxValue; (layouter as LayouterStripes).count = ensemble.parametersInfo[(layouter as LayouterStripes).mainParameter].count; (layouter as LayouterStripes).delta = ensemble.structuresSize.x * 0.5f; } else if (parametersDim == 2 && ensemble.parametersInfo.Count >= 2) { layouter = new LayouterBoxes(); (layouter as LayouterBoxes).mainParameter = ensemble.getParameter(1); (layouter as LayouterBoxes).mCount = ensemble.parametersInfo[(layouter as LayouterBoxes).mainParameter].count; (layouter as LayouterBoxes).mMinValue = ensemble.parametersInfo[(layouter as LayouterBoxes).mainParameter].minValue; (layouter as LayouterBoxes).mMaxValue = ensemble.parametersInfo[(layouter as LayouterBoxes).mainParameter].maxValue; (layouter as LayouterBoxes).mDelta = ensemble.structuresSize.x * 0.5f; (layouter as LayouterBoxes).secParameter = ensemble.getParameter(2); (layouter as LayouterBoxes).sCount = ensemble.parametersInfo[(layouter as LayouterBoxes).secParameter].count; (layouter as LayouterBoxes).sMinValue = ensemble.parametersInfo[(layouter as LayouterBoxes).secParameter].minValue; (layouter as LayouterBoxes).sMaxValue = ensemble.parametersInfo[(layouter as LayouterBoxes).secParameter].maxValue; (layouter as LayouterBoxes).sDelta = ensemble.structuresSize.y * 0.5f; } else { Debug.Log("Not permitted combination! Yet!"); } break; } case CVType.Superposition: { if (parametersDim == 1) { layouter = new LayouterSuperPosition(); (layouter as LayouterSuperPosition).mainParameter = ensemble.getParameter(1); (layouter as LayouterSuperPosition).minValue = ensemble.parametersInfo[(layouter as LayouterSuperPosition).mainParameter].minValue; (layouter as LayouterSuperPosition).maxValue = ensemble.parametersInfo[(layouter as LayouterSuperPosition).mainParameter].maxValue; (layouter as LayouterSuperPosition).count = ensemble.parametersInfo[(layouter as LayouterSuperPosition).mainParameter].count; (layouter as LayouterSuperPosition).delta = 0.5f; (layouter as LayouterSuperPosition).type = nSuperpositionType; } else { Debug.Log("Not permitted combination! Yet!"); } break; } case CVType.Hybrid: { if (parametersDim == 2 && ensemble.parametersInfo.Count >= 2) { layouter = new LayouterSuperStripes(); (layouter as LayouterSuperStripes).mainParameter = ensemble.getParameter(1); (layouter as LayouterSuperStripes).mCount = ensemble.parametersInfo[(layouter as LayouterSuperStripes).mainParameter].count; (layouter as LayouterSuperStripes).mMinValue = ensemble.parametersInfo[(layouter as LayouterSuperStripes).mainParameter].minValue; (layouter as LayouterSuperStripes).mMaxValue = ensemble.parametersInfo[(layouter as LayouterSuperStripes).mainParameter].maxValue; (layouter as LayouterSuperStripes).mDelta = ensemble.structuresSize.x * 0.5f; (layouter as LayouterSuperStripes).secParameter = ensemble.getParameter(2); (layouter as LayouterSuperStripes).sCount = ensemble.parametersInfo[(layouter as LayouterSuperStripes).secParameter].count; (layouter as LayouterSuperStripes).sMinValue = ensemble.parametersInfo[(layouter as LayouterSuperStripes).secParameter].minValue; (layouter as LayouterSuperStripes).sMaxValue = ensemble.parametersInfo[(layouter as LayouterSuperStripes).secParameter].maxValue; (layouter as LayouterSuperStripes).sDelta = 0.5f; (layouter as LayouterSuperStripes).type = nSuperpositionType; } else if (parametersDim == 3 && ensemble.parametersInfo.Count >= 3) { layouter = new LayouterSuperBoxes(); (layouter as LayouterSuperBoxes).mainParameter = ensemble.getParameter(1); (layouter as LayouterSuperBoxes).mCount = ensemble.parametersInfo[(layouter as LayouterSuperBoxes).mainParameter].count; (layouter as LayouterSuperBoxes).mMinValue = ensemble.parametersInfo[(layouter as LayouterSuperBoxes).mainParameter].minValue; (layouter as LayouterSuperBoxes).mMaxValue = ensemble.parametersInfo[(layouter as LayouterSuperBoxes).mainParameter].maxValue; (layouter as LayouterSuperBoxes).mDelta = ensemble.structuresSize.x * 0.5f; (layouter as LayouterSuperBoxes).secParameter = ensemble.getParameter(2); (layouter as LayouterSuperBoxes).sCount = ensemble.parametersInfo[(layouter as LayouterSuperBoxes).secParameter].count; (layouter as LayouterSuperBoxes).sMinValue = ensemble.parametersInfo[(layouter as LayouterSuperBoxes).secParameter].minValue; (layouter as LayouterSuperBoxes).sMaxValue = ensemble.parametersInfo[(layouter as LayouterSuperBoxes).secParameter].maxValue; (layouter as LayouterSuperBoxes).sDelta = ensemble.structuresSize.y * 0.5f; (layouter as LayouterSuperBoxes).thirdParameter = ensemble.getParameter(2); (layouter as LayouterSuperBoxes).tCount = ensemble.parametersInfo[(layouter as LayouterSuperBoxes).thirdParameter].count; (layouter as LayouterSuperBoxes).tMinValue = ensemble.parametersInfo[(layouter as LayouterSuperBoxes).thirdParameter].minValue; (layouter as LayouterSuperBoxes).tMaxValue = ensemble.parametersInfo[(layouter as LayouterSuperBoxes).thirdParameter].maxValue; (layouter as LayouterSuperBoxes).tDelta = 0.5f; (layouter as LayouterSuperBoxes).type = nSuperpositionType; } else { Debug.Log("Not permitted combination! Yet!"); } break; } } if (visualSpaceDim == 3) { Camera.main.gameObject.GetComponent <MouseCameraControl> ().pitch.activate = true; Camera.main.gameObject.GetComponent <MouseCameraControl> ().yaw.activate = true; } else { Camera.main.gameObject.GetComponent <MouseCameraControl> ().pitch.activate = false; Camera.main.gameObject.GetComponent <MouseCameraControl> ().yaw.activate = false; } layouter.axisParameters = parameters; string abstractionName = pickupAbstractionNew(); int numOfElements = Mathf.FloorToInt((Camera.main.orthographicSize * 2f) / (abstractions[abstractionName].scale * 300f)); if (numOfElements == 0) { numOfElements = 5; } layouter.PlacePreview(numOfElements); wasLayoutChanged = true; isCompositionCreated = false; }
/// <summary> /// For internal use only /// </summary> /// <param name="reportModel"></param> /// <returns></returns> public static IReportCreator CreatePageBuilder (IReportModel reportModel) { if (reportModel == null) { throw new ArgumentNullException("reportModel"); } IDataManager dataMan = DataManagerFactory.CreateDataManager(reportModel,(ReportParameters)null); Layouter layouter = new Layouter(); IReportCreator builder = DataPageBuilder.CreateInstance(reportModel, dataMan,layouter); return builder; }
private void RunFormSheet (ReportModel reportModel) { Layouter layouter = new Layouter(); IReportCreator reportCreator = FormPageBuilder.CreateInstance(reportModel,layouter); reportCreator.SectionRendering += new EventHandler<SectionRenderEventArgs>(PushPrinting); reportCreator.PageCreated += OnPageCreated; reportCreator.BuildExportList(); ShowCompleted (); }
public void PutNextRectangle_ThrowException(int width, int height, string exMessage) { Action res = () => { Layouter.PutNextRectangle(new Size(width, height)); }; res.ShouldThrow <ArgumentException>().WithMessage(exMessage); }