#region License Information
/* HeuristicLab
* Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using HeuristicLab.Core;
using HeuristicLab.Data;
namespace HeuristicLab.Visualization {
///
/// Collects values of specific variable names in a given scope and feeds them into a ChartDataRowsModel.
///
public class ChartDataRowsModelDataCollector : OperatorBase {
///
public override string Description {
get { return @"Collects values of specific variable names in a given scope and feeds them into a ChartDataRowsModel."; }
}
///
/// Initializes a new instance of with two variable infos
/// (VariableNames and Model).
///
public ChartDataRowsModelDataCollector() {
IVariableInfo variableNamesVariableInfo = new VariableInfo("VariableNames", "Names of variables whose values should be collected", typeof(ItemList), VariableKind.In);
variableNamesVariableInfo.Local = true;
AddVariableInfo(variableNamesVariableInfo);
ItemList variableNames = new ItemList();
AddVariable(new Variable("VariableNames", variableNames));
AddVariableInfo(new VariableInfo("Model", "Data model in which the collected values should be fed.", typeof(IChartDataRowsModel), VariableKind.In | VariableKind.Out));
}
///
/// Collects the values of a specified list of variable names in the given .
///
/// The scope where to collect the values from.
/// null.
public override IOperation Apply(IScope scope) {
ItemList names = GetVariableValue>("VariableNames", scope, false);
IChartDataRowsModel model = GetVariableValue("Model", scope, true, false);
// collect data values and feed them into the model
for (int i = 0; i < names.Count; i++) {
DoubleData data = scope.GetVariableValue(names[i].Data, true) as DoubleData;
if (data != null)
model.Rows[i].AddValue(data.Data);
}
return null;
}
}
}