CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2001
    Posts
    2,455

    Label postions on item.

    I am designing a mile stone task scheduler class. For each item (See Attached Bitmap), you have a start point and end point which is represented by a symbol (triangle, square, circle) and between a rectangle representing the connector line.

    Now, each item has 5 possible labels, one displaying the start date (drawn around the start point symbol), one displaying the end date (drawn around the end point symbol), and 3 description labels drawn anywhere around the item. My problem is that I need to come up with a solution to determine where to draw each label so that no label conflicts with another. Each label can have a vertical and horizontal justification which is based on the symbol or connector line. TOP | MIDDLE| BOTTOM and LEFT|CENTER|MIDDLE.

    E.G. Of problem: If the start date and end date are the same, then the right symbol and connector line are not drawn, but all five labels are drawn around the left symbol. If all the items are to be drawn with the justification TOP | CENTER, then they would be drawn over each other at the top of the left symbol.

    Any hints on how I can solve this problem?

    Note: The order of drawing the labels is from 0-4 top to bottom.

    Mike B
    Attached Images Attached Images

  2. #2
    Join Date
    Feb 2002
    Posts
    5,757

    Re: Label postions on item.

    drawing process relies on a relative object as start point. in normal example, first and last symbols, and lines are drawn first. now you have three options to select as a relative point. in second example of start/end time being the same, you have only one relative point to select.

    Kuphryn

  3. #3
    Join Date
    Feb 2001
    Posts
    2,455

    Re: Label postions on item.

    Quote Originally Posted by kuphryn
    drawing process relies on a relative object as start point. in normal example, first and last symbols, and lines are drawn first. now you have three options to select as a relative point. in second example of start/end time being the same, you have only one relative point to select.

    Kuphryn
    Thanks for your reply Kuphryn, my problem is not necessarily the point of reference, but how do I go about determining the label position based on the point of reference, the index of the label, and the text alignment specified.

    In the example bitmap, label 2, 3, and 4 have the connector as referece, but, what if 4 had a vertical alignment of "TOP" specified, that would mean 4 must be drawn above the connector, and labels 2 and 3 have to be moved up to accomadate 4.

    This gets even tougher since each label, must be able to accomadate a different font and font size.

    One solution I thought of, but not sure if it is overkill, is to create 3 - 3X3X5 matrix's of "Label positions", where the first 3 is Left symbol, connector, and right symbol labels, then the 3X3X5 matrix represents all the different alignment values and the 5 deep is because there is 5 lables.

    This would probably not be very efficient for drawing however?

    Mike B
    Last edited by MikeB; September 5th, 2006 at 03:07 PM.

  4. #4
    Join Date
    Feb 2002
    Posts
    5,757

    Re: Label postions on item.

    This depends on design specifically drawing. one case you draw all objects. now select a different object based on its position attribute. another case each object draws itself. key is no collision via keeping track of the set of position attributes.

    Kuphryn

  5. #5
    Join Date
    Feb 2001
    Posts
    2,455

    Re: Label postions on item.

    Sorry Kuphrin, see my previous post as it was edited while you were replying.

    Mike B

  6. #6
    Join Date
    Feb 2002
    Posts
    5,757

    Re: Label postions on item.

    array is one solution. inefficiency would be something like bunch of if/else

    Kuphryn

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured