GnuplotXYSink.java
/*
* Created on 2007/10/29
* Copyright (C) 2007 Koga Laboratory. All rights reserved.
*
*/
package org.mklab.tool.control.system.sink;
import org.mklab.nfc.matrix.DoubleMatrix;
import org.mklab.tool.control.system.parameter.ParameterAccessException;
/**
* Gnuplotへの2次元グラフの出力器を表わすクラスです。
*
* @author Koga Laboratory
* @version $Revision: 1.4 $, 2007/10/29
*/
public class GnuplotXYSink extends GnuplotSink {
/**
* 新しく生成された<code>GnuplotXYSink</code>オブジェクトを初期化します。
*/
public GnuplotXYSink() {
super();
}
/**
* @see org.mklab.tool.control.system.sink.ContinuousSink#setInputSize(int)
*/
@Override
public void setInputSize(final int inputSize) {
super.setInputSize(inputSize);
if (inputSize == -1) {
return;
}
if (isNameInitializing(inputSize / 2)) {
setupLineNames(inputSize / 2, "xy"); //$NON-NLS-1$
try {
setupParameters(this.getClass());
} catch (ParameterAccessException e) {
throw new RuntimeException(e);
}
}
}
/**
* @see org.mklab.tool.control.system.sink.Exporter#exportData()
*/
@Override
public void exportData() {
if (isReady() == false) {
return;
}
final DoubleMatrix data = getData();
final int size = (data.getRowSize() - 1) / 2;
if (size < 1 || (1 + size * 2) != data.getRowSize()) {
throw new IllegalArgumentException(Messages.getString("GnuplotXYSink.1")); //$NON-NLS-1$
}
final DoubleMatrix x = data.getRowVectors(2, 2 + size - 1);
final DoubleMatrix y = data.getRowVectors(2 + size, 2 + size + size - 1);
if (isJustReploting() == false && isNameInitializing(size)) {
setupLineNames(size, "xy"); //$NON-NLS-1$
}
exportData(x, y);
}
}