NumberLine

INHERITS FROM	View : Responder : Object

DECLARED IN	NumberLine.h

CLASS DESCRIPTION

A NumberLine is a View that displays a mathematical number line.  The number line will be horizontal if the view is wider than it is high, or vertical if the view is higher than it is wide.  Tick marks, and labels for every fifth tick mark, are calculated and displayed automatically.  The labels can be placed either above or below (for a horizontal line) or on the left or the right (for a vertical line) of the line itself.

INSTANCE VARIABLES

Inherited from Object	Class	isa;

Inherited from Responder	id	nextResponder;

Inherited from View	NXRect	frame;
NXRect	bounds;
id	superview;
id	subviews;
id	window;
struct __vFlags	vFlags;

Declared in NumberLine	int	orientation;
int	labelPosition;
float	linePosition;
float	backgroundGray;
float	lineGray;
float	labelGray;
float	borderWidth;
struct __tickInfo {
         float	         firstTick;
         float	         tickSpacing;
         int	         numberOfTicks;
         float	         firstLabel;
         float	         labelSpacing;
         int	         numberOfLabels;
         char	         labelString[11][30];
         char	         expString[11][5];
         BOOL	         scientific;
}	tickInfo;

id	numberLineImage;

orientation 	Whether the number line is drawn horizontally or vertically.

labelPosition 	On which side of the number line the labels should be drawn.

linePosition 	The position, within the view, where the line is drawn.

backgroundGray 	The gray value for the background of the View.

lineGray 	The gray value for the number line and tick marks.

labelGray 	The gray value for the labels.

borderWidth 	Width of the border, or -1 if there is no border.

tickInfo.firstTick 	The value at the leftmost or bottommost tick mark.

tickInfo.tickSpacing 	The distance between tick marks.

tickInfo.numberOfTicks 	The total number of tick marks.

tickInfo.firstLabel 	The value at the leftmost or bottommost labelled tick mark.

tickInfo.labelSpacing 	The distance between labelled tick marks.

tickInfo.numberOfLabels 	The number of labelled tick marks.

tickInfo.labelString 	Array of formatted labels or label mantissas.

tickInfo.expString 	Array of exponents of ten to be used for scientific notation.

tickInfo.scientific 	Whether scientific notation is used for the labels.

numberLineImage 	The NXImage used for drawing the number line.

METHOD TYPES

Initializing a new NumberLine object	- initFrame:

Modifying graphics attributes	- setBackgroundGray: 
- setLineGray:
- setLabelGray:
- orientation
- setLinePosition:
- linePosition:
- setLabelPosition:
- labelPosition:
- setBordered:width:

Moving and scaling the number line	- setMin:max: 
- min
- max
- zoomIn:
- zoomOut:
- setCenter:
- center
- slide: 

Drawing the NumberLine	- drawSelf::
- drawIntoImage
- calculateTicks
- numberLineNXImage

INSTANCE METHODS

calculateTicks
- calculateTicks

Calculates the tick marks and labels for the current number line.  This method updates all the values of the structure tickInfo.  It doesn't do any drawing into either the numberLineNXImage or the View.  This method is invoked whenever the bounds change.  You will not need to invoke it yourself.

center
- (float)center

Returns the current center point of the number line.

See also:  - setCenter, - setMin:max:

drawIntoImage
- drawIntoImage

Draws the number line, with tick marks and labels, into the numberLineNXImage.  This method is invoked whenever the numberLineNXImage needs updating.  You will not need to invoke it yourself.

drawSelf::
- drawSelf:(const NXRect *)rects :(int)rectCount

Composites the contents of numberLineNXImage onto the NumberLine.

initFrame:
- initFrame:(const NXRect *)frameRect

Initializes a new NumberLine object.  The number line will display the range -10 to 10 and will be set at linePosition 30.  If frameRect.size.height is greater than frameRect.size.width, the number line will be vertical; otherwise, it will be horizontal.  Labels will be below a horizontal number line or to the left of a vertical one.

labelPosition
- (float)labelPosition

Returns one of the constants BELOWLEFT or ABOVERIGHT to indicate the position where the tick mark labels will be drawn.  The default is below a horizontal number line or to the left of a vertical number line.

See also:  - setLabelPosition:

linePosition
- (float)linePosition

Returns the position, in default coordinates, at which the number line will be drawn within the view.  The position is measured from the bottom in case of a horizontal number line and from the right in case of a vertical number line.  The default position is 30.

See also:  - setLinePosition:

max
- (float)max

Returns the current rightmost or topmost endpoint of the number line.  Redraws only if autodisplay is on.  Returns self.

See also:  - min, - setMin:max:, - setCenter:, - slide:, - zoomIn:, - zoomOut:

min
- (float)min

Returns the current leftmost or bottommost endpoint of the number line.  Redraws only if autodisplay is on.  Returns self.

See also: - max, - setMin:max:, - setCenter:, - slide:, - zoomIn:, - zoomOut:

numberLineNXImage
- numberLineNXImage

Returns the NXImage containing the drawing of the number line.  This allows, with autodisplay off,  other objects to do their own compositing in order to increase drawing speed.  Returns self.

See also:   - setAutodisplay: (View)

orientation
- (int)orientation

Returns one of the constants HORIZONTAL or VERTICAL, indicating whether the number line is horizontal or vertical.  It will be VERTICAL if and only if the NumberLine is taller than it is wide. 

setBackgroundGray:
- setBackgroundGray:(float)gray

Sets the background gray for the NumberLine.  The background will be transparent, and the default gray is NX_WHITE.  Does not redraw.  Returns self.

setBordered:width:
- setBordered:(BOOL)shouldHaveBorder width:(float)width

Indicates whether or not a black border should be drawn around the NumberLine and, if so, its width in unscaled (default) coordinates.  If  shouldHaveBorder is NO, width will be ignored.  Does not redraw.  Returns self.

setCenter:
- setCenter:(float)newCenter

Sends a setMin:max: message to itself to translate the number line to make newCenter the center point.  Redraws only if autodisplay is on.  Returns self.

See also:   - center, - slide:, - setMin:max:

setLabelGray:
- setLabelGray:(float)gray

Sets the gray value for drawing the tick mark labels.  The default is NX_BLACK.  Does not redraw.  Returns self.

setLabelPosition:
- setLinePosition:(float)newPosition

Sets the position where the tick mark labels will be drawn.  The constant BELOWLEFT will cause them to be drawn below a horizontal number line or to the left of a vertical one, while ABOVERIGHT will cause them to be drawn above a horizontal number line or to the right of a vertical one.  The position is measured in unscaled (default) coordinates.  Does not redraw.  Returns self.

See also:  - labelPosition

setLineGray:
- setLineGray:(float)gray

Sets the gray value for drawing the number line and the tick marks.  The default is NX_BLACK.  Does not redraw.  Returns self.

setLinePosition:
- setLinePosition:(float)newPosition

Sets the position, measured in unscaled (default) coordinates, at which the number line will be drawn within the NumberLine.  The position is measured from the bottom of the NumberLine if the number line is horizontal and from the right edge if it is vertical.  Does not redraw.  Returns self.

See also:  - linePosition

setMin:max:
- setMin:(float)newMin max:(float)newMax

Resets the left (or bottom) and right (or top) endpoints of the number line.  Redraws only if  autodisplay is on.  Returns self.

See also:  - min, - max, - setCenter:, - slide:, - zoomIn:, - zoomOut:

slide:
- slide:(float)translation

Sends a setMin:max: message to itself to translate the number line by translation units in the positive direction.  A negative value for translation thus causes a translation in the negative direction.  Redraws only if  autodisplay is on.  Returns self.

See also:  - setCenter:, - setMin:max:

zoomIn:
- zoomIn:(float)amount

Sends a setMin:max: message to itself to reduce the range of values displayed on the number line by a factor of amount.  The center point remains the same.  Redraws only if  autodisplay is on.  Returns self.

See also:  - setMin:max:, - zoomOut:

zoomOut:
- zoomOut:(float)amount

Sends a setMin:max: message to itself to increase the range of values displayed on the number line by a factor of amount.  The center point remains the same.  Redraws only if  autodisplay is on.  Returns self.

See also:  - setMin:max:, - zoomIn: