/* * Encog(tm) Workbench v3.4 * http://www.heatonresearch.com/encog/ * https://github.com/encog/encog-java-workbench * * Copyright 2008-2016 Heaton Research, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information on Heaton Research copyrights, licenses * and trademarks visit: * http://www.heatonresearch.com/copyright */ package org.encog.workbench.tabs.visualize.scatter; import org.jfree.data.DomainInfo; import org.jfree.data.Range; import org.jfree.data.RangeInfo; import org.jfree.data.xy.AbstractXYDataset; import org.jfree.data.xy.XYDataset; public class ScatterXY extends AbstractXYDataset implements XYDataset, DomainInfo, RangeInfo { private ScatterFile scatterFile; /** The minimum domain value. */ private Number domainMin; /** The maximum domain value. */ private Number domainMax; /** The minimum range value. */ private Number rangeMin; /** The maximum range value. */ private Number rangeMax; /** The range of the domain. */ private Range domainRange; /** The range. */ private Range range; private int xIndex; private int yIndex; /** * Creates a sample dataset. * * @param seriesCount the number of series. * @param itemCount the number of items. */ public ScatterXY(ScatterFile scatterFile, int xIndex, int yIndex) { this.scatterFile = scatterFile; this.xIndex = xIndex; this.yIndex = yIndex; double minX = scatterFile.findMin(this.xIndex); double maxX = scatterFile.findMax(this.xIndex); double minY = scatterFile.findMin(this.yIndex); double maxY = scatterFile.findMax(this.yIndex); this.domainMin = new Double(minX); this.domainMax = new Double(maxX); this.domainRange = new Range(minX, maxX); this.rangeMin = new Double(minY); this.rangeMax = new Double(maxY); this.range = new Range(minY, maxY); } /** * Returns the x-value for the specified series and item. Series are numbered 0, 1, ... * * @param series the index (zero-based) of the series. * @param item the index (zero-based) of the required item. * * @return the x-value for the specified series and item. */ public Number getX(int series, int item) { return this.scatterFile.getSeries(series).get(item)[this.xIndex]; } /** * Returns the y-value for the specified series and item. Series are numbered 0, 1, ... * * @param series the index (zero-based) of the series. * @param item the index (zero-based) of the required item. * * @return the y-value for the specified series and item. */ public Number getY(int series, int item) { return this.scatterFile.getSeries(series).get(item)[this.yIndex]; } /** * Returns the number of series in the dataset. * * @return the series count. */ public int getSeriesCount() { return this.scatterFile.getSeriesCount(); } /** * Returns the key for the series. * * @param series the index (zero-based) of the series. * * @return The key for the series. */ public Comparable getSeriesKey(int series) { return this.scatterFile.getSeries().get(series); } /** * Returns the number of items in the specified series. * * @param series the index (zero-based) of the series. * * @return the number of items in the specified series. */ public int getItemCount(int series) { int i = this.scatterFile.getSeries(series).size(); return i; } /** * Returns the minimum domain value. * * @return The minimum domain value. */ public double getDomainLowerBound() { return this.domainMin.doubleValue(); } /** * Returns the lower bound for the domain. * * @param includeInterval include the x-interval? * * @return The lower bound. */ public double getDomainLowerBound(boolean includeInterval) { return this.domainMin.doubleValue(); } /** * Returns the maximum domain value. * * @return The maximum domain value. */ public double getDomainUpperBound() { return this.domainMax.doubleValue(); } /** * Returns the upper bound for the domain. * * @param includeInterval include the x-interval? * * @return The upper bound. */ public double getDomainUpperBound(boolean includeInterval) { return this.domainMax.doubleValue(); } /** * Returns the range of values in the domain. * * @return the range. */ public Range getDomainBounds() { return this.domainRange; } /** * Returns the bounds for the domain. * * @param includeInterval include the x-interval? * * @return The bounds. */ public Range getDomainBounds(boolean includeInterval) { return this.domainRange; } /** * Returns the range of values in the domain. * * @return the range. */ public Range getDomainRange() { return this.domainRange; } /** * Returns the minimum range value. * * @return The minimum range value. */ public double getRangeLowerBound() { return this.rangeMin.doubleValue(); } /** * Returns the lower bound for the range. * * @param includeInterval include the y-interval? * * @return The lower bound. */ public double getRangeLowerBound(boolean includeInterval) { return this.rangeMin.doubleValue(); } /** * Returns the maximum range value. * * @return The maximum range value. */ public double getRangeUpperBound() { return this.rangeMax.doubleValue(); } /** * Returns the upper bound for the range. * * @param includeInterval include the y-interval? * * @return The upper bound. */ public double getRangeUpperBound(boolean includeInterval) { return this.rangeMax.doubleValue(); } /** * Returns the range of values in the range (y-values). * * @param includeInterval include the y-interval? * * @return The range. */ public Range getRangeBounds(boolean includeInterval) { return this.range; } /** * Returns the range of y-values. * * @return The range. */ public Range getValueRange() { return this.range; } /** * Returns the minimum domain value. * * @return The minimum domain value. */ public Number getMinimumDomainValue() { return this.domainMin; } /** * Returns the maximum domain value. * * @return The maximum domain value. */ public Number getMaximumDomainValue() { return this.domainMax; } /** * Returns the minimum range value. * * @return The minimum range value. */ public Number getMinimumRangeValue() { return this.domainMin; } /** * Returns the maximum range value. * * @return The maximum range value. */ public Number getMaximumRangeValue() { return this.domainMax; } }