// public Rectangle PaintReactionSet( // IReactionSet reactionSet, IDrawVisitor drawVisitor) { // // total up the bounding boxes // Rectangle2D totalBounds = CreateRectangle(); // foreach (var reaction in reactionSet.reactions()) { // Rectangle2D modelBounds = BoundsCalculator.CalculateBounds(reaction); // if (totalBounds == null) { // totalBounds = modelBounds; // } else { // totalBounds = totalBounds.CreateUnion(modelBounds); // } // } // // // setup and draw // this.SetupTransformNatural(totalBounds); // ElementGroup diagram = new ElementGroup(); // foreach (var reaction in reactionSet.reactions()) { // diagram.Add(this.GenerateDiagram(reaction)); // } // this.Paint(drawVisitor, diagram); // // // the size of the painted diagram is returned // return this.ConvertToDiagramBounds(totalBounds); // } // // public Rectangle PaintReaction( // IReaction reaction, IDrawVisitor drawVisitor) { // // // calculate the bounds // Rectangle2D modelBounds = BoundsCalculator.CalculateBounds(reaction); // // // setup and draw // this.SetupTransformNatural(modelBounds); // IRenderingElement diagram = this.GenerateDiagram(reaction); // this.Paint(drawVisitor, diagram); // // return this.ConvertToDiagramBounds(modelBounds); // } /// <summary> /// Paint a ChemModel. /// </summary> /// <param name="chemModel"></param> /// <param name="drawVisitor">the visitor that does the drawing</param> /// <param name="bounds">the bounds of the area to paint on.</param> /// <param name="resetCenter">if true, set the modelCenter to the center of the ChemModel's bounds.</param> public void Paint(IChemModel chemModel, IDrawVisitor drawVisitor, Rect bounds, bool resetCenter) { // check for an empty model var moleculeSet = chemModel.MoleculeSet; IReactionSet reactionSet = chemModel.ReactionSet; // nasty, but it seems that reactions can be read in as ChemModels // with BOTH a ReactionSet AND a MoleculeSet... if (moleculeSet == null || reactionSet != null) { if (reactionSet != null) { reactionSetRenderer.Paint(reactionSet, drawVisitor, bounds, resetCenter); } return; } // calculate the total bounding box var modelBounds = BoundsCalculator.CalculateBounds(moleculeSet); this.SetupTransformToFit(bounds, modelBounds, AverageBondLengthCalculator.CalculateAverageBondLength(chemModel), resetCenter); // generate the elements IRenderingElement diagram = moleculeSetRenderer.GenerateDiagram(moleculeSet); // paint it this.Paint(drawVisitor, diagram); }
/// <summary> /// Low-level draw method used by other rendering methods. /// </summary> /// <param name="visitor">the draw visitor</param> /// <param name="bounds">a bound rendering element</param> /// <param name="zoom">if the diagram is zoomed at all</param> /// <param name="viewBounds">the view bounds - the root will be centered in the bounds</param> protected void Draw(IDrawVisitor visitor, double zoom, Bounds bounds, Rect viewBounds) { var modelScale = zoom * model.GetScale(); var zoomToFit = Math.Min(viewBounds.Width / (bounds.Width * modelScale), viewBounds.Height / (bounds.Height * modelScale)); var transform = Matrix.Identity; // setup up transform transform.TranslatePrepend(viewBounds.CenterX(), viewBounds.CenterY()); transform.ScalePrepend(modelScale, -modelScale); // default is shrink only unless specified if (model.GetFitToScreen() || zoomToFit < 1) { transform.ScalePrepend(zoomToFit, zoomToFit); } transform.TranslatePrepend(-(bounds.MinX + bounds.MaxX) / 2, -(bounds.MinY + bounds.MaxY) / 2); // not always needed var fontManager = new WPFFontManager { Zoom = zoomToFit }; visitor.RendererModel = model; visitor.FontManager = fontManager; visitor.Visit(bounds.Root, new MatrixTransform(transform)); }
public void Run() { sprite = new Sprite(pixel); EntityConstructor entityConstructor = new EntityConstructor(); EntityManager = entityConstructor.Instantiate("1", () => window.Close()); InputManager = new MouseClick(); IUpdateVisitor = new DefaultUpdateVisitor(InputManager, entityConstructor); IDrawingManager = new SFMLDrawingAdapter(window); IDrawVisitor = new DefaultDrawVisitor(IDrawingManager); //Database.Set_connection(); //Database.ExecuteData("create table if exists WinsLosses (ID INTEGER PRIMARY KEY, Wins INTEGER, Losses INTEGER)"); //Database.ExecuteData("insert into WinsLosses (ID, Wins, Losses) values (1,0,0)"); //Database.ReadData("select * from WinsLosses"); window.SetActive(); while (window.IsOpen) { window.Clear(); window.DispatchEvents(); Draw(); Update(); window.Display(); } }
/// <summary> /// Paint a molecule (an IAtomContainer). /// </summary> /// <param name="atomContainer">the molecule to paint</param> /// <param name="drawVisitor">the visitor that does the drawing</param> /// <param name="bounds">the bounds on the screen</param> /// <param name="resetCenter">if true, set the draw center to be the center of bounds</param> public void Paint(IAtomContainer atomContainer, IDrawVisitor drawVisitor, Rect bounds, bool resetCenter) { if (atomContainer.Bonds.Count > 0 || atomContainer.Atoms.Count == 1) { rendererModel.SetScale( CalculateScaleForBondLength(GeometryUtil.GetBondLengthAverage(atomContainer))); } else if (atomContainer.Atoms.Count > 1) { rendererModel.SetScale( CalculateScaleForBondLength(EstimatedBondLength(atomContainer))); } // the diagram to draw var diagram = GenerateDiagram(atomContainer); // the bounds of the model from 'Bounds' elements // no bounding elements, use the atom coordinates var modelBounds = GetBounds(diagram); if (modelBounds.IsEmpty) { modelBounds = BoundsCalculator.CalculateBounds(atomContainer); } SetupTransformToFit(bounds, modelBounds, resetCenter); this.Paint(drawVisitor, diagram); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); IDrawingManager = new MonogameDrawingAdapter(spriteBatch, Content); IDrawVisitor = new DefaultDrawVisitor(IDrawingManager); // TODO: use this.Content to load your game content here }
public void Draw(IDrawVisitor drawVisitor) { var viewIterator = views.GetIterator(); while (viewIterator.HasNext()) { var view = viewIterator.Next(); view.Draw(drawVisitor); } }
/// <summary> /// Paint a set of molecules. /// </summary> /// <param name="molecules">the <see cref="IChemObjectSet{T}"/> to paint</param> /// <param name="drawVisitor">the visitor that does the drawing</param> /// <param name="bounds">the bounds on the screen</param> /// <param name="resetCenter">if true, set the draw center to be the center of bounds</param> public void Paint(IChemObjectSet <IAtomContainer> molecules, IDrawVisitor drawVisitor, Rect bounds, bool resetCenter) { // total up the bounding boxes var totalBounds = BoundsCalculator.CalculateBounds(molecules); this.SetupTransformToFit(bounds, totalBounds, AverageBondLengthCalculator.CalculateAverageBondLength(molecules), resetCenter); IRenderingElement diagram = this.GenerateDiagram(molecules); this.Paint(drawVisitor, diagram); }
/// <inheritdoc/> public Rect Paint(IReaction reaction, IDrawVisitor drawVisitor) { // calculate the bounds var modelBounds = BoundsCalculator.CalculateBounds(reaction).Value; // setup and draw this.SetupTransformNatural(modelBounds); var diagram = this.GenerateDiagram(reaction); this.Paint(drawVisitor, diagram); return(this.ConvertToDiagramBounds(modelBounds)); }
/// <summary> /// Paint a reaction. /// </summary> /// <param name="reaction">the reaction to paint</param> /// <param name="drawVisitor">the visitor that does the drawing</param> /// <param name="bounds">the bounds on the screen</param> /// <param name="resetCenter">/// if true, set the draw center to be the center of bounds</param> public void Paint(IReaction reaction, IDrawVisitor drawVisitor, Rect bounds, bool resetCenter) { // calculate the bounds var modelBounds = BoundsCalculator.CalculateBounds(reaction).Value; this.SetupTransformToFit(bounds, modelBounds, AverageBondLengthCalculator.CalculateAverageBondLength(reaction), resetCenter); // generate the elements var diagram = this.GenerateDiagram(reaction); // paint it this.Paint(drawVisitor, diagram); }
/// <inheritdoc/> public Rect Paint(IAtomContainer atomContainer, IDrawVisitor drawVisitor) { // the bounds of the model var modelBounds = BoundsCalculator.CalculateBounds(atomContainer); // setup and draw this.SetupTransformNatural(modelBounds); IRenderingElement diagram = GenerateDiagram(atomContainer); this.Paint(drawVisitor, diagram); return(this.ConvertToDiagramBounds(modelBounds)); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // Load your game content here MonoGameAssetLoadService.Instance.LoadAssets(Content); drawManager = new DrawManager(new MonoGameDrawStrategy(spriteBatch, graphics, Content, inputAdapter)); drawVisitor = new DefaultDrawVisitor(drawManager); // Goto main screen screenNavigator.OpenScreen(ScreenFactory.MAIN_SCREEN); }
/// <inheritdoc/> public Rect Paint(IChemObjectSet <IAtomContainer> moleculeSet, IDrawVisitor drawVisitor) { // total up the bounding boxes var totalBounds = BoundsCalculator.CalculateBounds(moleculeSet); // setup and draw this.SetupTransformNatural(totalBounds); IRenderingElement diagram = this.GenerateDiagram(moleculeSet); this.Paint(drawVisitor, diagram); return(this.ConvertToDiagramBounds(totalBounds)); }
/// <summary> /// Paint a set of reactions. /// </summary> /// <param name="reactionSet">the reaction to paint</param> /// <param name="drawVisitor">the visitor that does the drawing</param> /// <param name="bounds">the bounds on the screen</param> /// <param name="resetCenter">if true, set the draw center to be the center of bounds</param> public void Paint(IReactionSet reactionSet, IDrawVisitor drawVisitor, Rect bounds, bool resetCenter) { // total up the bounding boxes var totalBounds = BoundsCalculator.CalculateBounds(reactionSet); this.SetupTransformToFit(bounds, totalBounds, AverageBondLengthCalculator.CalculateAverageBondLength(reactionSet), resetCenter); ElementGroup diagram = new ElementGroup(); foreach (var reaction in reactionSet) { diagram.Add(reactionRenderer.GenerateDiagram(reaction)); } // paint them all this.Paint(drawVisitor, diagram); }
/// <summary> /// The target method for paintChemModel, paintReaction, and paintMolecule. /// </summary> /// <param name="drawVisitor">the visitor to draw with</param> /// <param name="diagram">the IRenderingElement tree to render</param> protected virtual void Paint(IDrawVisitor drawVisitor, IRenderingElement diagram) { if (diagram == null) { return; } // cache the diagram for quick-redraw this.cachedDiagram = diagram; fontManager.FontName = rendererModel.GetFontName(); fontManager.FontWeight = rendererModel.GetUsedFontStyle(); drawVisitor.FontManager = this.fontManager; drawVisitor.RendererModel = this.rendererModel; diagram.Accept(drawVisitor, this.transform); }
/// <inheritdoc/> public Rect Paint(IReactionSet reactionSet, IDrawVisitor drawVisitor) { // total up the bounding boxes var totalBounds = BoundsCalculator.CalculateBounds(reactionSet); // setup and draw this.SetupTransformNatural(totalBounds); var diagram = new ElementGroup(); foreach (var reaction in reactionSet) { diagram.Add(reactionRenderer.GenerateDiagram(reaction)); } this.Paint(drawVisitor, diagram); // the size of the painted diagram is returned return(this.ConvertToDiagramBounds(totalBounds)); }
/// <summary> /// Paint an IChemModel using the IDrawVisitor at a scale determined by the /// bond length in RendererModel. /// </summary> /// <param name="chemModel">the chem model to draw</param> /// <param name="drawVisitor">the visitor used to draw with</param> /// <returns>the rectangular area that the diagram will occupy on screen</returns> public Rect Paint(IChemModel chemModel, IDrawVisitor drawVisitor) { var moleculeSet = chemModel.MoleculeSet; var reactionSet = chemModel.ReactionSet; if (moleculeSet == null && reactionSet != null) { Rect totalBounds = BoundsCalculator.CalculateBounds(reactionSet); this.SetupTransformNatural(totalBounds); IRenderingElement diagram = reactionSetRenderer.GenerateDiagram(reactionSet); this.Paint(drawVisitor, diagram); return(this.ConvertToDiagramBounds(totalBounds)); } if (moleculeSet != null && reactionSet == null) { Rect totalBounds = BoundsCalculator.CalculateBounds(moleculeSet); this.SetupTransformNatural(totalBounds); IRenderingElement diagram = moleculeSetRenderer.GenerateDiagram(moleculeSet); this.Paint(drawVisitor, diagram); return(this.ConvertToDiagramBounds(totalBounds)); } if (moleculeSet != null && reactionSet != null) { var totalBounds = BoundsCalculator.CalculateBounds(chemModel); this.SetupTransformNatural(totalBounds); ElementGroup diagram = new ElementGroup { reactionSetRenderer.GenerateDiagram(reactionSet), moleculeSetRenderer.GenerateDiagram(moleculeSet) }; this.Paint(drawVisitor, diagram); // the size of the painted diagram is returned return(this.ConvertToDiagramBounds(totalBounds)); } return(new Rect(0, 0, 0, 0)); }
public void Draw(IDrawVisitor visitor) { Debug.WriteLine(this); visitor.DrawScreen(this); }
public void Draw(IDrawVisitor visitor) { visitor.DrawEntity(this); }
public abstract void Draw(IDrawVisitor drawVisitor);
public override void Draw(IDrawVisitor drawVisitor) { drawVisitor.DrawForBear(this); }
public void Draw(IDrawVisitor visitor) { visitor.DrawScreen(this); }
public override void Draw(IDrawVisitor drawVisitor) { // Did you know? A plain view is also a ninja, so they can hide themselves really well! }
public override void Draw(IDrawVisitor visitor) { visitor.Draw(this); view.Draw(visitor); }
public override void Draw(IDrawVisitor drawVisitor) { drawVisitor.DrawForStone(this); }
public void Draw(IDrawVisitor visitor) { visitor.onGrid(this); }
public void Draw(IDrawVisitor visitor) { visitor.DrawLabel(this); }
public void Draw(IDrawVisitor visitor) { visitor.DrawButton(this.NonClickAbleButton); visitor.DrawLabel(this.NonClickAbleButton.Label); this.inputField.Draw(visitor); }
public void Draw(IDrawVisitor visitor) { visitor.DrawButton(this); visitor.DrawLabel(this.Label); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); IDrawingManager = new MonogameDrawingAdapter(spriteBatch, Content); IDrawVisitor = new DefaultDrawVisitor(IDrawingManager); }
public void Draw(IDrawVisitor visitor) { visitor.DrawGui(this); }