Option Strict On
Option Explicit On

Namespace Nexamas.UI.Visualization

    ''' <summary>
    ''' Deterministic chart layout viewport. It is independent from controls and render hosts.
    ''' </summary>
    Friend NotInheritable Class MASChartViewport

        Friend Sub New(x As Double, y As Double, width As Double, height As Double)
            Me.X = x
            Me.Y = y
            Me.Width = width
            Me.Height = height
        End Sub

        Friend ReadOnly Property X As Double
        Friend ReadOnly Property Y As Double
        Friend ReadOnly Property Width As Double
        Friend ReadOnly Property Height As Double

        Friend ReadOnly Property Right As Double
            Get
                Return X + Width
            End Get
        End Property

        Friend ReadOnly Property Bottom As Double
            Get
                Return Y + Height
            End Get
        End Property

        Friend ReadOnly Property IsValid As Boolean
            Get
                Return MASChartDataPoint.IsFinite(X) AndAlso
                       MASChartDataPoint.IsFinite(Y) AndAlso
                       MASChartDataPoint.IsFinite(Width) AndAlso
                       MASChartDataPoint.IsFinite(Height) AndAlso
                       Width > 0.0R AndAlso
                       Height > 0.0R
            End Get
        End Property

        Friend Shared Function Create(width As Double, height As Double) As MASChartViewport
            Return New MASChartViewport(0.0R, 0.0R, width, height)
        End Function

    End Class

End Namespace
