Disappearing components? [closed] - memory

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have a canvas which contains a single myComponentA. A myComponentA contains a MyComponentB. The myComponentB contains a number of myComponentA's giving a tree structure...Ok so far.
The structure is stored as an XML file.
When I load a big (60 or so components), the components are not visible... When I change the player quality to low or medium they appear...!?
Towards the bottom of the diagram a component is clipped through the middle as though it has been cut off...(The containing canvas continues on empty...)

This is probably an issue with the flex measuring mechanism. Your myComponentA should probably report its measuredHeight and measuredWidth to the parent container. This will likely be done, in your case, in an override of the measure function. e.g,
override protected function measure():void {
measuredWidth = //x position + width of rightmost child
measuredHeight = //y position + height of bottommost child
super.measure();
}
If you do something like this in both myComponentA and myComponentB, and you inherit from a Container (e.g., canvas) then things should work mostly. If your components inherit from UIComponent, you might have more trouble (i.e., there won't be any scrollbars).
Keep in mind that the measure function only sets the measuredHeight and measuredWidth. Depending on your situation, you may need to overide updateDisplayList as well to properly set the actual height/width/positions of the children.

Related

Fitting more systems on the first page of a Lilypond score

I'm working to improve upon an excellent sheet I found of Debussy's Deuxième Arabesque on the freely available Mutopia Project.
In particular, I'm interested in fitting the music on fewer pages but I struggle to have the first page display five systems instead of four with the version I arrived at.
From the reproduction above, I would like the fith system (starting at bar 13) to be at the bottom of the first page. It seems there are a lot of wasted space on the first page and I'm rather confident it will fit perfectly.
I have a hard time playing figuring out how to achieve this. I have displayed the spacing annotations as advised by the documentation but I do not seem to be able to make sense of it.
If I were typesetting this today, I would try changing the staff size, like this:
#(set-global-staff-size 18)
You can add the following to your paper block
\paper {
min-systems-per-page = #5
system-system-spacing.padding = #2 %fit staves closer together
system-system-spacing.stretchability = #15 %how flexible the spacing is
}
This will of course force that all other pages have at least five systems. You can play around with the padding and stretchability values and see what works best. Also, you might want to make the staves smaller than the default 20pt. To do that, you can add the following at the beginning of the file:
#(set-global-staff-size 18)

What TeeChart Tool can I use to Interactively select points from a FastLine Graph

While using Delphi Seattle 10 and Steema TeeChart Pro VCL FMX 2016.18, I am looking to Highlight a Selection of a Line Graph (multiple series) in the way that Zooming allows / makes a square around a highlighted selection of a Line Graph to indicate which part of it to zoom into (as long as the onmousedown action is in progress).
The purpose of this would be to allow the selection to remain highlighted while the mouse is no longer being clicked, to potentially "Delete" the highlighted Data points. All I need this for is to obtain the (X0 Y0 X1 Y1) values to possibly obtain the CalcPosPoint(X) and remove all the points inside. The data is currently obtained through a Record Struct (Memory Mapped) file, and it will there for be used to set/check for a property "deleted" to indicate on the next redraw of the graph which rows to completely ignore and which to continue printing.
I hope to be able to do this (select from 1 chart), and have it simultaneously draw on multiple graphs. I have tried to look for an example of this feature through the use of TSelectorTool (FMXTee). One of the pages I found referring to such a tool is Interactive data point selection as well as Multiple selections with Selector Tool
And my second question has to do with TeeCharts directly. Where would I find fmx240.bpl as TeeChart_Pro_Firemonkey_Demo.exe requires this file in order to run? I did manage to copy vcl240.bpl from "Embarcadero\Studio\18.0\bin" and put it into "Embarcadero\Studio\17.0\bin"
[Edited]
I have managed to capture / create a sample code (MVCE) from which I can now select a portion and create a square around a particular sample of graph lines.
The control graph right now is the bottom graph (Chart5). If anyone is interested in seeing the code, I have put up a pastebin sample.
PasteBin Sample Code
And a TeeCharts.tar.gz is accessible to anyone who wishes to see a sample of the code, as well as the data sample.
filetolink.com Source Files
I no longer feel the need for mathematical equation to differentiate the top graphs from the bottom (because the bottom axes are automatic where as the top are defined). I intend to only use the space which is adherent to the visible space, and do not intend to extend in either direction (left or right). That means at this point the size of the graph does not matter, because once I over populate the charts above, the position in the bottom graph would become irrelevant, and therefor I do not intend to use the bottom chart.
The next step is to save the positions of the boxes so that they can reappear when the graph is shift from left (past data) to the right (live data). And then uses the buttons above to make the appropriate action to the graphs.
I would like to know what way would be the most sufficient way to record the positions of the rectangles, so when the chart is shifted (via the ScrollBar1), the rectangles are moving with the direction of the scrollbar. But I'm sure I can achieve that.
I think I have found a solution. The red squares are only prevalent for the visual aspect, they can be drawn on, I don't need to do anything special with each chart, as I already know what the X0..Y1 parameters are, they are known from the initial chart. The problem h/e has to do with the initial chart. As long as the screens are all full, I can zoom in correctly w/ alignment with on all the charts (ZoomRect/Rectf(X0..Y1))
But what kind of equation would it take to adjust the charts that are not in the same zoom / max / min when the Chart5.Axes.Bottom.Automatic = True?
From there I just simply have to disable the immediate zoom feature, and allow buttons to become functional, to decide what the next course of action would be.

Highcharts - areaRange with different fill colors depending on which line is higher

I have essentially the same problem described in:
JavaScript charting library to handle shading area between two lines
That is to say: color the area between two lines, with the fill color of each portion of the area determined by which of the two boundary lines is higher at that point.
The question referenced above was answered, but the question is two years old and the solution is a little convoluted. Have subsequent advances in Highcharts introduced better / cleaner ways of solving this particular problem?

Efficiently Computing Text Widths

I need to compute the width of a column with many rows (column AutoSize feature). Using Canvas.TextWidth is far too slow.
Current solution: My current solution uses a text measurer class that builds a lookup table for a fixed alphabet once and then computes the width of a given string very fast by adding up character widths retrieved from the lookup table. For characters not contained in the lookup table, the average character width is used (also computed once).
Problem: This works well for European languages but not for Asian languages.
Question: What's the best way to tackle this problem? How can such an AutoSize feature be realized without the relatively slow Canvas functions and without depending on a specific alphabet?
Thanks for any help.
You said you want to get the maximum text width for a column. Can't you, say, take only the 4 or 5 longest strings and get their widths? That way you won't have to find the width for all items and can save quite some time.
Or you use your cache to find the rough length of the strings and then refine that by getting the actual width for the top 4 or 5 items you found.
I don't think it matters a lot whether you use Canvas.TextWidth or GetTextExtentPoint32. Just use one of these to get the exact widths, after you used one of the methods above to guesstimate the longest/widest strings.
To those who think this doesn't work
If the poster of the original question thinks it could work, I have no reason to think it won't. He knows best what kind of strings can be in the columns he has.
But that is not my main argument. He already wrote that he does a preliminary textwidth by adding the predetermined individual widths of the characters. That does not take into account any kerning. Well, kerning can only make a string narrower, so it still makes sense to check only the top 4 or 5 items for the exact width. The biggest problem that can occur is that the column could be a few pixels too wide, no more. But it will be a lot faster than using TextWidth or GetTextExtentPoint32 or similar functions on each entry (assuming more than 5 entries), and that is what the original poster wanted. I suggest that those who don't believe me simply try it out.
As for using the pure string length: even that is probably good enough. Yes, 'WWW' is probably wider than '!!!!!', but the original poster will probably know best wat kind of string material he has, and if it is feasible. '!!!!!' or 'WWW' are not the usual entries one expects. Especially if you consider that not only one single string is checked, but the longest 4 or 5 strings (or whatever number turns out to be optimal). It is very unlikely that the widest string is not among them. But the original poster can tell if that is possible or feasible. He seems to think it is.
So stop the downvoting and try it out for yourself.
I'm afraid you have to use Canvas.TextWidth, or your implementation will be imprecise. The width of text depends on the font kerning, where different character sequences may have different widths (not just the total of individual character widths).
Me, I cut out the middle-man and use the Windows API directly. Specifically, I use GetTextExtentPoint32 with the .Handle of the Canvas. There's nothing you can do to be faster, other than caching results in some way, and frankly you'll just add overhead.

Advanced RPG-Style Movement in XNA [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am making a top down, rpg-type game - similar to Pokemon, but I am stuck at character movement. Basically, what I want to achieve is a smooth tile based movement system for my player and other people on the map. Has anyone managed to do this effectively? If so, how?
If you are using a grid system, like Pokémon uses, you might be able to achieve this by setting a speed at which they can move between tiles.
For example, if you made it so that they can move one tile a second, you can then use (float)gameTime.ElapsedGameTime.TotalSeconds in your Update function to determine how quickly the game is updating. From this, you should be able to make it so that the character moves ((float)gameTime.ElapsedGameTime.TotalSeconds * TileSize) each update.
This would mean that if they have 4 updates a second (very slow, but for example), they would move 1/4 of the distance across the tile every update, and reach the end point by the end of the movement time period (1 second in this case). In this situation, if you had 32 pixel tiles, they would move 0.25 * 32 every update, or 8 pixels.
Hope this helps.
The 'technical' word for what you want is probably 'interpolation'.
I think the simplest thing you want to do is interpolate the unit position between its starting point (the middle of starting tile) and its ending point (the middle of ending tile) in the time period you want to give it a smooth movement.
Formula goes something like this:
float k = timeSinceStarted / durationOfMovement;
pos.X = startPos.X + (endPos.X - startPos.X) * k;
pos.Y = startPos.Y + (endPos.Y - startPos.Y) * k;
In a game, it's probably better to pre-compute the delta, and add increments instead of storing start position. Something like this (Note: I haven't double checked this computation).
delta = endPos - startPos;
position += delta * (timeSinceLastUpdate / durationOfMovement);

Resources