Skip navigation.
 
mlText not drawing where I think it should
FROM : Graham J Lee
DATE : Wed Nov 03 13:25:19 2004

Hi,

I'm creating an app to graph some data (and eventually do some simple
stats on them), displaying the graph in a custom view.  The graphing is
all fine, but labeling the axes is causing me some trouble.  I want to
draw the Y label going 'up' the axis, so I'm drawing the labels like
this:

   p1=NSMakePoint(width*0.50,height*0.02);
   [xLabel drawAtPoint:p1];
   /* Rotate the context, draw the Y label, rotate back */
   [NSGraphicsContext saveGraphicsState];
   aTrans=[NSAffineTransform transform];
   [aTrans translateXBy:width yBy:0];
   [aTrans rotateByDegrees:90];
   [aTrans concat];
   /*p1=NSMakePoint(width*0.50,height*0.90);*/
   p1=NSMakePoint(height*0.50,width*0.90);
   [yLabel drawAtPoint:p1];
   [NSGraphicsContext restoreGraphicsState];

With p1 defined the second time by
"p1=NSMakePoint(width*0.50,height*0.90);" then the label draws in
"kindof" the right place, but it's clear that because width and height
differ it's not *quite* the right place.  I think that this is because
the width of the rotated context is equal to height and vice versa. 
BTW, the variables width and height were found by e.g. [self
bounds].size.width earlier in the method, i.e. back when the context
was the "right" way around.

So, I try to put the label in the correct place by
"p1=NSMakePoint(height*0.50,width*0.90);" only it doesn't appear at
all.  I found that for some value of the [rotated] y ordinate that
happens to be around (width*0.86), the label starts to get chopped off
[see http://www-teaching.physics.ox.ac.uk/~leeg/ppcgview.pdf]
suggesting that it's popping off the top of the drawable area.  I guess
my questions are twofold: firstly how can I engineer things so that I
*can* draw right up to the edge of the visible view, and secondly what
is the reason that I currently can't?  I.e. what is it about drawing on
views that I don't understand, leading me to try something that doesn't
work as I think it might?

Thanks,

Graham.
--
Graham Lee
UNIX Systems Manager,
Oxford Physics Practical Course
http://nextstep.sdf-eu.org

Related mailsAuthorDate
mlText not drawing where I think it should Graham J Lee Nov 3, 13:25
mlRe: Text not drawing where I think it should R. Scott Thompson Nov 3, 15:11