VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Context"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'Klasa Context
Dim fl As vbFile
Dim x() As Single, y() As Single
Dim plts As PlotStrategy
'-----
Public Sub setLinePlot()
  Set plts = New LinePlotStrategy
End Sub
'-----
Public Sub setBarPlot()
  Set plts = New BarPlotStrategy
End Sub
'-----
Public Sub plot()
  readFile
  plts.findBounds x(), y()
  plts.plot x(), y()              'Twórz dowolny rodzaj wykresu
End Sub
'-----
Private Sub readFile()
  Dim xc As New Collection
  Dim yc As New Collection
  Dim sline As String
  Dim tmp As Single
  Dim i As Integer
  'Wczytaj dane z pliku
  Set fl = New vbFile
  fl.OpenForRead App.Path + "\data.txt"

  While Not fl.fEof
    sline = fl.readLine
    i = InStr(sline, " ")
    tmp = Val(Left(sline, i - 1))
    xc.Add tmp
    tmp = Val(Right(sline, Len(sline) - i))
    yc.Add tmp
  Wend
  'Skopiuj dane z kolekcji do tablic
  ReDim x(xc.Count) As Single
  ReDim y(yc.Count) As Single
  For i = 1 To xc.Count
    x(i) = xc(i)
    y(i) = yc(i)
  Next i
  fl.closeFile
End Sub
