C# Class NPlot.Axis

Encapsulates functionality common to all axis classes. All specific axis classes derive from Axis. Axis can be used as a concrete class itself - it is an Axis without any embilishments [tick marks or tick mark labels].



This class encapsulates no physical information about where the axes are drawn.
Inheritance: System.ICloneable
Afficher le fichier Open project: GridProtectionAlliance/openHistorian Class Usage Examples

Private Properties

Свойство Type Description
Init void
UpdateScale void
WorldTickPositions_FirstPass void
WorldTickPositions_SecondPass void

Méthodes publiques

Méthode Description
Axis ( ) : System

Default constructor

Axis ( Axis a ) : System

Copy constructor.

Axis ( double worldMin, double worldMax ) : System

Constructor that takes only world min and max values.

Clone ( ) : object

Deep copy of Axis.

This method includes a check that guards against derived classes forgetting to implement their own Clone method. If Clone is called on a object derived from Axis, and the Clone method hasn't been overridden by that object, then the test this.GetType == typeof(Axis) will fail.

Draw ( Graphics g, Point physicalMin, Point physicalMax, Rectangle &boundingBox ) : void

Draw the axis. This involves three steps: (1) Draw the axis line. (2) Draw the tick marks. (3) Draw the label.

DrawLabel ( Graphics g, Point offset, Point axisPhysicalMin, Point axisPhysicalMax ) : object

Draw the Axis Label

DrawTick ( Graphics g, double w, float size, string text, Point textOffset, Point axisPhysMin, Point axisPhysMax, Point &labelOffset, Rectangle &boundingBox ) : void

Draw a tick on the axis.

IncreaseRange ( double percent ) : void

Moves the world min and max values so that the world axis length is [percent] bigger. If the current world max and min values are the same, they are moved appart an arbitrary amount. This arbitrary amount is currently 0.01, and will probably be configurable in the future.

Works for the case WorldMax is less than WorldMin.

LUB ( Axis a ) : void

Sets the world extent of the current axis to be just large enough to encompas the current world extent of the axis, and the world extent of the passed in axis

OutOfRange ( double coord ) : bool

Determines whether a world value is outside range WorldMin -> WorldMax

PhysicalToWorld ( PointF p, PointF physicalMin, PointF physicalMax, bool clip ) : double

Return the world coordinate of the projection of the point p onto the axis.

WorldTickPositions ( Point physicalMin, Point physicalMax, List &largeTickPositions, List &smallTickPositions ) : void

Determines the positions of all Large and Small ticks.

WorldToPhysical ( double coord, PointF physicalMin, PointF physicalMax, bool clip ) : PointF

World to physical coordinate transform.

Not sure how much time is spent in this often called function. If it's lots, then worth optimizing (there is scope to do so).

Méthodes protégées

Méthode Description
DoClone ( Axis b, Axis a ) : void

Helper method for Clone. Does all the copying - can be called by derived types so they don't need to implement this part of the copying themselves. also useful in constructor of derived types that takes Axis class.

DrawTicks ( Graphics g, Point physicalMin, Point physicalMax, object &labelOffset, object &boundingBox ) : void

DrawTicks method. In base axis class this does nothing.

UpdateOffsetAndBounds ( object &labelOffset, object &boundingBox, Point mergeLabelOffset, Rectangle mergeBoundingBox ) : void

Update the bounding box and label offset associated with an axis to encompass the additionally specified mergeBoundingBox and mergeLabelOffset respectively.

getDefaultLabelOffset ( Point physicalMin, Point physicalMax ) : Point

returns a suitable offset for the axis label in the case that there are no ticks or tick text in the way.

Private Methods

Méthode Description
Init ( ) : void

Helper function for constructors. Do initialization here so that Clear() method is handled properly

UpdateScale ( ) : void
WorldTickPositions_FirstPass ( Point physicalMin, Point physicalMax, List &largeTickPositions, List &smallTickPositions ) : void

Determines the positions, in world coordinates, of the large ticks. When the physical extent of the axis is small, some of the positions that were generated in this pass may be converted to small tick positions and returned as well. This default implementation returns empty large ticks list and null small tick list.

WorldTickPositions_SecondPass ( Point physicalMin, Point physicalMax, List largeTickPositions, List &smallTickPositions ) : void

Determines the positions, in world coordinates, of the small ticks if they have not already been generated. This default implementation creates an empty smallTickPositions list if it doesn't already exist.

Method Details

Axis() public méthode

Default constructor
public Axis ( ) : System
Résultat System

Axis() public méthode

Copy constructor.
public Axis ( Axis a ) : System
a Axis The Axis to clone.
Résultat System

Axis() public méthode

Constructor that takes only world min and max values.
public Axis ( double worldMin, double worldMax ) : System
worldMin double The minimum world coordinate.
worldMax double The maximum world coordinate.
Résultat System

Clone() public méthode

Deep copy of Axis.
This method includes a check that guards against derived classes forgetting to implement their own Clone method. If Clone is called on a object derived from Axis, and the Clone method hasn't been overridden by that object, then the test this.GetType == typeof(Axis) will fail.
public Clone ( ) : object
Résultat object

DoClone() protected static méthode

Helper method for Clone. Does all the copying - can be called by derived types so they don't need to implement this part of the copying themselves. also useful in constructor of derived types that takes Axis class.
protected static DoClone ( Axis b, Axis a ) : void
b Axis
a Axis
Résultat void

Draw() public méthode

Draw the axis. This involves three steps: (1) Draw the axis line. (2) Draw the tick marks. (3) Draw the label.
public Draw ( Graphics g, Point physicalMin, Point physicalMax, Rectangle &boundingBox ) : void
g System.Drawing.Graphics The drawing surface on which to draw.
physicalMin Point The physical position corresponding to the world minimum of the axis.
physicalMax Point The physical position corresponding to the world maximum of the axis.
boundingBox System.Drawing.Rectangle out The bounding rectangle of the axis including axis line, label, tick marks and tick mark labels
Résultat void

DrawLabel() public méthode

Draw the Axis Label
public DrawLabel ( Graphics g, Point offset, Point axisPhysicalMin, Point axisPhysicalMax ) : object
g System.Drawing.Graphics The GDI+ drawing surface on which to draw.
offset Point offset from axis. Should be calculated so as to make sure axis label misses tick labels.
axisPhysicalMin Point The physical position corresponding to the world minimum of the axis.
axisPhysicalMax Point The physical position corresponding to the world maximum of the axis.
Résultat object

DrawTick() public méthode

Draw a tick on the axis.
public DrawTick ( Graphics g, double w, float size, string text, Point textOffset, Point axisPhysMin, Point axisPhysMax, Point &labelOffset, Rectangle &boundingBox ) : void
g System.Drawing.Graphics The graphics surface on which to draw.
w double The tick position in world coordinates.
size float The size of the tick (in pixels)
text string The text associated with the tick
textOffset Point The Offset to draw from the auto calculated position
axisPhysMin Point The minimum physical extent of the axis
axisPhysMax Point The maximum physical extent of the axis
labelOffset Point out: offset from the axies required for axis label
boundingBox System.Drawing.Rectangle out: The bounding rectangle for the tick and tickLabel drawn
Résultat void

DrawTicks() protected méthode

DrawTicks method. In base axis class this does nothing.
protected DrawTicks ( Graphics g, Point physicalMin, Point physicalMax, object &labelOffset, object &boundingBox ) : void
g System.Drawing.Graphics The graphics surface on which to draw
physicalMin Point The physical position corresponding to the world minimum of the axis.
physicalMax Point The physical position corresponding to the world maximum of the axis.
labelOffset object is set to a suitable offset from the axis to draw the axis label. In this base method, set to null.
boundingBox object is set to the smallest box that bounds the ticks and the tick text. In this base method, set to null.
Résultat void

IncreaseRange() public méthode

Moves the world min and max values so that the world axis length is [percent] bigger. If the current world max and min values are the same, they are moved appart an arbitrary amount. This arbitrary amount is currently 0.01, and will probably be configurable in the future.
Works for the case WorldMax is less than WorldMin.
public IncreaseRange ( double percent ) : void
percent double Percentage to increase world length by.
Résultat void

LUB() public méthode

Sets the world extent of the current axis to be just large enough to encompas the current world extent of the axis, and the world extent of the passed in axis
public LUB ( Axis a ) : void
a Axis The other Axis instance.
Résultat void

OutOfRange() public méthode

Determines whether a world value is outside range WorldMin -> WorldMax
public OutOfRange ( double coord ) : bool
coord double the world value to test
Résultat bool

PhysicalToWorld() public méthode

Return the world coordinate of the projection of the point p onto the axis.
public PhysicalToWorld ( PointF p, PointF physicalMin, PointF physicalMax, bool clip ) : double
p System.Drawing.PointF The point to project onto the axis
physicalMin System.Drawing.PointF The physical position corresponding to the world minimum of the axis.
physicalMax System.Drawing.PointF The physical position corresponding to the world maximum of the axis.
clip bool If true, the world value will be clipped to WorldMin or WorldMax as appropriate if it lies outside this range.
Résultat double

UpdateOffsetAndBounds() protected static méthode

Update the bounding box and label offset associated with an axis to encompass the additionally specified mergeBoundingBox and mergeLabelOffset respectively.
protected static UpdateOffsetAndBounds ( object &labelOffset, object &boundingBox, Point mergeLabelOffset, Rectangle mergeBoundingBox ) : void
labelOffset object Current axis label offset.
boundingBox object Current axis bounding box.
mergeLabelOffset Point the label offset to merge. The current label offset will be replaced by this if it's norm is larger.
mergeBoundingBox System.Drawing.Rectangle the bounding box to merge. The current bounding box will be replaced by this if null, or by the least upper bound of bother bounding boxes otherwise.
Résultat void

WorldTickPositions() public méthode

Determines the positions of all Large and Small ticks.
public WorldTickPositions ( Point physicalMin, Point physicalMax, List &largeTickPositions, List &smallTickPositions ) : void
physicalMin Point The physical position corresponding to the world minimum of the axis.
physicalMax Point The physical position corresponding to the world maximum of the axis.
largeTickPositions List ArrayList containing the positions of the large ticks.
smallTickPositions List ArrayList containing the positions of the small ticks.
Résultat void

WorldToPhysical() public méthode

World to physical coordinate transform.
Not sure how much time is spent in this often called function. If it's lots, then worth optimizing (there is scope to do so).
public WorldToPhysical ( double coord, PointF physicalMin, PointF physicalMax, bool clip ) : PointF
coord double The coordinate value to transform.
physicalMin System.Drawing.PointF The physical position corresponding to the world minimum of the axis.
physicalMax System.Drawing.PointF The physical position corresponding to the world maximum of the axis.
clip bool if false, then physical value may extend outside worldMin / worldMax. If true, the physical value returned will be clipped to physicalMin or physicalMax if it lies outside this range.
Résultat System.Drawing.PointF

getDefaultLabelOffset() protected méthode

returns a suitable offset for the axis label in the case that there are no ticks or tick text in the way.
protected getDefaultLabelOffset ( Point physicalMin, Point physicalMax ) : Point
physicalMin Point physical point corresponding to the axis world maximum.
physicalMax Point physical point corresponding to the axis world minimum.
Résultat Point