Check whether an area on panel is blank or not
-
How can I check whether a specific area (rectangle) on a panel is blank or not? I have a panel on which a graph is drawn. I also want to print text on this graph. However I do not want my text to interfere with my plot. Therefore I need to check in advance if the area, where I want to print my text, is blank or not. If not, I can move my text so that there is no interference. scubapro32
-
How can I check whether a specific area (rectangle) on a panel is blank or not? I have a panel on which a graph is drawn. I also want to print text on this graph. However I do not want my text to interfere with my plot. Therefore I need to check in advance if the area, where I want to print my text, is blank or not. If not, I can move my text so that there is no interference. scubapro32
I do not know if there is any short cut but there is a long way but it works.. U will be knowing the back color of ur plot... Traverse thought the plot and compare the color of all the point with ur plots back color Plz do let me know if u find some thing which is a better method Good luck...
-
I do not know if there is any short cut but there is a long way but it works.. U will be knowing the back color of ur plot... Traverse thought the plot and compare the color of all the point with ur plots back color Plz do let me know if u find some thing which is a better method Good luck...
-
How can I check whether a specific area (rectangle) on a panel is blank or not? I have a panel on which a graph is drawn. I also want to print text on this graph. However I do not want my text to interfere with my plot. Therefore I need to check in advance if the area, where I want to print my text, is blank or not. If not, I can move my text so that there is no interference. scubapro32
A faster method would be to do the math that calculates the largest area available, based on the line graph itself. Going pixel-by-pixel won't do you much good and is a very expensive operation. Things to consider are what is the total available area in the graph? What is the biggest possible size you want the textarea to be?? Where does the graph intersect that area? Once the graph passes to the right of the area you want the text in, you can stop looking at resizing the text area. Basically, you'e calculating the intersection between two lines. Does the line you're drawing for a point on the graph intersect the line that is the bottom of the text area?? If so, then you either have to move the textarea or resize it to fit in the space between where your textarea starts and the intersection of those two lines. Google for "calculate intersection of two lines" for the math to help you do this.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
A faster method would be to do the math that calculates the largest area available, based on the line graph itself. Going pixel-by-pixel won't do you much good and is a very expensive operation. Things to consider are what is the total available area in the graph? What is the biggest possible size you want the textarea to be?? Where does the graph intersect that area? Once the graph passes to the right of the area you want the text in, you can stop looking at resizing the text area. Basically, you'e calculating the intersection between two lines. Does the line you're drawing for a point on the graph intersect the line that is the bottom of the text area?? If so, then you either have to move the textarea or resize it to fit in the space between where your textarea starts and the intersection of those two lines. Google for "calculate intersection of two lines" for the math to help you do this.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007Thanks Dave, but I think mathematics won't do the trick here. First of all it's not a line graph, but more a 'random' plot of peaks as seen in an 'chromatogram'. Therefore a function of the line, and the chromatogram (sums of near Gaussic functions) is not available.
-
Thanks Dave, but I think mathematics won't do the trick here. First of all it's not a line graph, but more a 'random' plot of peaks as seen in an 'chromatogram'. Therefore a function of the line, and the chromatogram (sums of near Gaussic functions) is not available.
Scubapro wrote:
but I think mathematics won't do the trick here.
BS. Your drawing code still has to draw something from point A to point B. Whatever that something is, even if it's just a single point, you can still test for an intersection between either a line and a point (which side of the line the point is on), or if the point falls inside the area of the textarea.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Scubapro wrote:
but I think mathematics won't do the trick here.
BS. Your drawing code still has to draw something from point A to point B. Whatever that something is, even if it's just a single point, you can still test for an intersection between either a line and a point (which side of the line the point is on), or if the point falls inside the area of the textarea.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007