Skip to content

Commit

Permalink
Allows headers in NDay TimeSeries list form
Browse files Browse the repository at this point in the history
atcTimeseriesGridSource: add header row if it is not empty and retrieve attributes and dates and values accordingly
atcListForm: accept headers
frmSWSTATmod: create headers for NDay Timeseries list form
  • Loading branch information
TongZhai committed Jun 13, 2017
1 parent 0cef8e5 commit f24499c
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 22 deletions.
58 changes: 46 additions & 12 deletions atcData/atcTimeseriesGridSource.vb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Public Class atcTimeseriesGridSource
Private pCantFit As String = "#"
Private pSignificantDigits As Integer = 5
Private pValueAttributeDefs As Generic.List(Of Generic.List(Of atcAttributeDefinition))
Private pHeaders As Generic.List(Of String)

Public AttributeValuesEditable As Boolean = False

Expand All @@ -29,14 +30,19 @@ Public Class atcTimeseriesGridSource
Me.New(aDataGroup, aDisplayAttributes, aDisplayValues, False)
End Sub

Sub New(ByVal aDataGroup As atcData.atcTimeseriesGroup, _
ByVal aDisplayAttributes As Generic.List(Of String), _
ByVal aDisplayValues As Boolean, _
ByVal aFilterNoData As Boolean)
Sub New(ByVal aDataGroup As atcData.atcTimeseriesGroup,
ByVal aDisplayAttributes As Generic.List(Of String),
ByVal aDisplayValues As Boolean,
ByVal aFilterNoData As Boolean,
Optional aHeaders As Generic.List(Of String) = Nothing)
pTimeseriesGroup = aDataGroup
pDisplayAttributes = aDisplayAttributes
pDisplayValues = aDisplayValues
pFilterNoData = aFilterNoData
pHeaders = aHeaders
If pHeaders Is Nothing Then
pHeaders = New Generic.List(Of String)()
End If
RefreshAllDates()
End Sub

Expand Down Expand Up @@ -112,10 +118,14 @@ Public Class atcTimeseriesGridSource

Overrides Property Rows() As Integer
Get
Dim lAddRow As Integer = 0
If pHeaders.Count > 0 Then
lAddRow = 1
End If
If pAllDates Is Nothing Then
Return pDisplayAttributes.Count
Return pDisplayAttributes.Count + lAddRow
Else
Return pDisplayAttributes.Count + pAllDates.numValues
Return pDisplayAttributes.Count + pAllDates.numValues + lAddRow
End If
End Get
Set(ByVal Value As Integer)
Expand All @@ -124,10 +134,14 @@ Public Class atcTimeseriesGridSource

Public Overrides Property FixedRows() As Integer
Get
Dim lAddRow As Integer = 0
If pHeaders.Count > 0 Then
lAddRow = 1
End If
If AttributeValuesEditable Then
Return 0
Return 0 + lAddRow
Else
Return pDisplayAttributes.Count
Return pDisplayAttributes.Count + lAddRow
End If
End Get
Set(ByVal value As Integer)
Expand Down Expand Up @@ -230,7 +244,15 @@ Public Class atcTimeseriesGridSource
If aRow < lAttributeRows Then
Return pDisplayAttributes(aRow)
ElseIf Not pAllDates Is Nothing Then
Return pDateFormat.JDateToString(pAllDates.Value(aRow - lAttributeRows + 1))
If pHeaders.Count > 0 Then
If aRow = lAttributeRows Then
Return pHeaders.Item(0)
Else
Return pDateFormat.JDateToString(pAllDates.Value(aRow - lAttributeRows - 1 + 1))
End If
Else
Return pDateFormat.JDateToString(pAllDates.Value(aRow - lAttributeRows + 1))
End If
Else
Return ""
End If
Expand All @@ -243,15 +265,27 @@ Public Class atcTimeseriesGridSource
If aRow < lAttributeRows Then
If lIsValue Then
Return lTs.Attributes.GetFormattedValue(pDisplayAttributes(aRow))
ElseIf aRow = lAttributeRows - 1 Then
ElseIf pHeaders.Count = 0 AndAlso aRow = lAttributeRows - 1 Then
Return lValueAttDef.Name
Else
Return ""
End If
ElseIf pHeaders.Count > 0 And aRow = lAttributeRows Then
If lIsValue Then
Return lTs.Attributes.GetValue("Constituent", "Value")
ElseIf lValueAttDef IsNot Nothing Then
Return lValueAttDef.Name
Else
Return ""
End If
ElseIf Not pAllDates Is Nothing Then
Try
If lTs.Dates IsNot Nothing Then
Dim lDateDisplayed As Double = pAllDates.Value(aRow - lAttributeRows + 1)
Dim lDateIndex As Integer = aRow - lAttributeRows + 1
If pHeaders.Count > 0 Then
lDateIndex -= 1
End If
Dim lDateDisplayed As Double = pAllDates.Value(lDateIndex)
Dim lIndex As Integer = Array.BinarySearch(lTs.Dates.Values, lDateDisplayed)
If lIsValue Then
Dim lMaxWidth As Integer = pMaxWidth
Expand Down Expand Up @@ -288,7 +322,7 @@ Public Class atcTimeseriesGridSource
Return DoubleToString(lTs.Value(lIndex), lMaxWidth, lFormat, lExpFormat, lCantFit, lSignificantDigits)
End If
Else
If lTs.ValueAttributesExist(lIndex) Then
If lIndex >= 0 AndAlso lTs.ValueAttributesExist(lIndex) Then
Return lTs.ValueAttributes(lIndex).GetFormattedValue(lValueAttDef.Name)
Else
Return Nothing
Expand Down
6 changes: 4 additions & 2 deletions atcIntegratedDesignFlow/frmSWSTATmod.vb
Original file line number Diff line number Diff line change
Expand Up @@ -2264,8 +2264,11 @@ Public Class frmSWSTATmod
aBoundaryMonth:=pYearStartMonth, aBoundaryDay:=pYearStartDay,
aEndMonth:=pYearEndMonth, aEndDay:=pYearEndDay)
If lRankedAnnual.Count > 0 Then
Dim lHeaders As New Generic.List(Of String)()
lHeaders.Add("Year")
For Each lTS As atcTimeseries In lRankedAnnual
lTS.Attributes.SetValue("Units", "Common")
lHeaders.Add(lTS.Attributes.GetValue("Constituent", "Value"))
Next

Dim lList As New atcList.atcListForm
Expand All @@ -2278,8 +2281,7 @@ Public Class frmSWSTATmod
End With
.Text = "N-Day " & HighOrLowString() & " Annual Time Series and Ranking"
AddSeasonNameIfNeeded(pNDayAttributes, lRankedAnnual)

.Initialize(lRankedAnnual.Clone, pNDayAttributes, True, , )
.Initialize(lRankedAnnual.Clone, pNDayAttributes, True,,, lHeaders)
.DisplayValueAttributes = True
.Icon = Me.Icon
End With
Expand Down
24 changes: 16 additions & 8 deletions atcList/atcListForm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,16 @@ Public Class atcListForm
Private pSource As atcTimeseriesGridSource
Private pDisplayAttributes As Generic.List(Of String)
Private pSwapperSource As atcControls.atcGridSourceRowColumnSwapper
Private pHeaders As Generic.List(Of String)

Public HAlignment As atcControls.atcAlignment = atcControls.atcAlignment.HAlignRight

Public Sub Initialize(Optional ByVal aTimeseriesGroup As atcData.atcTimeseriesGroup = Nothing, _
Optional ByVal aDisplayAttributes As Generic.List(Of String) = Nothing, _
Optional ByVal aShowValues As Boolean = True, _
Optional ByVal aFilterNoData As Boolean = False, _
Optional ByVal aShowForm As Boolean = True)
Public Sub Initialize(Optional ByVal aTimeseriesGroup As atcData.atcTimeseriesGroup = Nothing,
Optional ByVal aDisplayAttributes As Generic.List(Of String) = Nothing,
Optional ByVal aShowValues As Boolean = True,
Optional ByVal aFilterNoData As Boolean = False,
Optional ByVal aShowForm As Boolean = True,
Optional ByVal aHeaders As Generic.List(Of String) = Nothing)
If aTimeseriesGroup Is Nothing Then
pDataGroup = New atcTimeseriesGroup
Else
Expand All @@ -282,6 +284,11 @@ Public Class atcListForm
pDisplayAttributes = aDisplayAttributes
End If

pHeaders = aHeaders
If pHeaders Is Nothing Then
pHeaders = New Generic.List(Of String)()
End If

If aShowForm Then
Dim DisplayPlugins As ICollection = atcDataManager.GetPlugins(GetType(atcDataDisplay))
For Each lDisp As atcDataDisplay In DisplayPlugins
Expand Down Expand Up @@ -337,9 +344,10 @@ Public Class atcListForm

Private Sub PopulateGrid()
'with timeseries data, a list of attributes and options define a timeseries grid source
pSource = New atcTimeseriesGridSource(pDataGroup, pDisplayAttributes, _
mnuViewValues.Checked, _
mnuFilterNoData.Checked)
pSource = New atcTimeseriesGridSource(pDataGroup, pDisplayAttributes,
mnuViewValues.Checked,
mnuFilterNoData.Checked,
pHeaders)
pSource.AttributeValuesEditable = mnuEditAtrributeValues.Checked
pSource.DisplayValueAttributes = mnuViewValueAttributes.Checked
With pSource
Expand Down

0 comments on commit f24499c

Please sign in to comment.