C# Класс NPlot.PhysicalAxis

This class adds physical positioning information [PhysicalMin, PhysicalMax] and related functionality on top of a specific Axis class. It's an interesting question where to put this information. It belongs with every specific axis type, but on the other hand, users of the library as it is normally used should not see it because positioning of axes is handled internally by PlotSurface2D. Therefore it doesn't make sense to put it in the Axis class unless it is internal. But if this were done it would restrict use of this information outside the library always, which is not what is wanted. The main disadvantage with the method chosen is that there is a lot of passing of the positional information between physical axis and the underlying logical axis type. C# doesn't have templates. If it did, I might derive PhysicalAxis from the templated Axis type (LinearAxis etc). Instead, have used a has-a relationship with an Axis superclass.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Draw ( Graphics g, Rectangle &boundingBox ) : void

Draws the axis on the given graphics surface.

GetBoundingBox ( ) : Rectangle

Returns the smallest rectangle that completely contains all parts of the axis [including ticks and label].

PhysicalAxis ( Axis a, Point physicalMin, Point physicalMax ) : System

Construct

PhysicalToWorld ( Point p, bool clip ) : double

Given a physical point on the graphics surface, returns the world value of it's projection onto the axis [i.e. closest point on the axis]. The function is implemented for axes of arbitrary orientation.

SetWorldLimitsFromPhysical ( Point min, Point max ) : void

This sets new world limits for the axis from two physical points selected within the plot area.

WorldToPhysical ( double coord, bool clip ) : PointF

Given a world coordinate value, returns the physical position of the coordinate along the axis.

Описание методов

Draw() публичный Метод

Draws the axis on the given graphics surface.
public Draw ( Graphics g, Rectangle &boundingBox ) : void
g System.Drawing.Graphics The graphics surface on which to draw.
boundingBox System.Drawing.Rectangle out: the axis bounding box - the smallest rectangle that /// completely contains all parts of the axis [including ticks and label].
Результат void

GetBoundingBox() публичный Метод

Returns the smallest rectangle that completely contains all parts of the axis [including ticks and label].
public GetBoundingBox ( ) : Rectangle
Результат System.Drawing.Rectangle

PhysicalAxis() публичный Метод

Construct
public PhysicalAxis ( Axis a, Point physicalMin, Point physicalMax ) : System
a Axis The axis this is a physical representation of.
physicalMin Point the physical position of the world minimum axis value.
physicalMax Point the physical position of the world maximum axis value.
Результат System

PhysicalToWorld() публичный Метод

Given a physical point on the graphics surface, returns the world value of it's projection onto the axis [i.e. closest point on the axis]. The function is implemented for axes of arbitrary orientation.
public PhysicalToWorld ( Point p, bool clip ) : double
p Point Physical point to find corresponding world value of.
clip bool if true, returns a world position outside WorldMin / WorldMax /// range if this is closer to the axis line. If false, such values will /// be clipped to be either WorldMin or WorldMax as appropriate.
Результат double

SetWorldLimitsFromPhysical() публичный Метод

This sets new world limits for the axis from two physical points selected within the plot area.
public SetWorldLimitsFromPhysical ( Point min, Point max ) : void
min Point The upper left point of the selection.
max Point The lower right point of the selection.
Результат void

WorldToPhysical() публичный Метод

Given a world coordinate value, returns the physical position of the coordinate along the axis.
public WorldToPhysical ( double coord, bool clip ) : PointF
coord double the world coordinate
clip bool if true, the physical position returned will be clipped to the physical max / min position as appropriate if the world value is outside the limits of the axis.
Результат PointF