Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Check whether an area on panel is blank or not

Check whether an area on panel is blank or not

Scheduled Pinned Locked Moved Visual Basic
questiondata-structures
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Scubapro
    wrote on last edited by
    #1

    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

    N D 2 Replies Last reply
    0
    • S Scubapro

      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

      N Offline
      N Offline
      nishkarsh_k
      wrote on last edited by
      #2

      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...

      S 1 Reply Last reply
      0
      • N nishkarsh_k

        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...

        S Offline
        S Offline
        Scubapro
        wrote on last edited by
        #3

        Thanks for your reply... The 'blank' backcolor of my panel is white. The plot is black. But how do I traverse through the plot? Getpixel does not work with panels!

        1 Reply Last reply
        0
        • S Scubapro

          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

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          S 1 Reply Last reply
          0
          • D Dave Kreskowiak

            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

            S Offline
            S Offline
            Scubapro
            wrote on last edited by
            #5

            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.

            D 1 Reply Last reply
            0
            • S Scubapro

              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.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              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

              S 1 Reply Last reply
              0
              • D Dave Kreskowiak

                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

                S Offline
                S Offline
                Scubapro
                wrote on last edited by
                #7

                The problem is I have over 6000 points and lines that are drawn first. Then each textrectangle (100+) has to be printed at the right place.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups