本文整理汇总了Java中org.jfree.data.xy.DefaultHighLowDataset类的典型用法代码示例。如果您正苦于以下问题:Java DefaultHighLowDataset类的具体用法?Java DefaultHighLowDataset怎么用?Java DefaultHighLowDataset使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultHighLowDataset类属于org.jfree.data.xy包,在下文中一共展示了DefaultHighLowDataset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOHLCDataset
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
private OHLCDataset getOHLCDataset(List<Candle> chartDatas) {
final int size = chartDatas.size();
Date[] date = new Date[size];
double[] high = new double[size];
double[] low = new double[size];
double[] open = new double[size];
double[] close = new double[size];
double[] volume = new double[size];
int i = 0;
for(Candle chartData : chartDatas) {
date[i] = new Date(chartData.getStartTimeStamp());
high[i] = chartData.getHigh();
low[i] = chartData.getLow();
open[i] = chartData.getOpen();
close[i] = chartData.getClose();
volume[i] = chartData.getVolume();
i++;
}
return new DefaultHighLowDataset("Price", date, high, low, open, close, volume);
}
示例2: createOHLCDataset
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
/**
* Builds a JFreeChart OHLC dataset from a ta4j time series.
* @param series a time series
* @return an Open-High-Low-Close dataset
*/
private static OHLCDataset createOHLCDataset(TimeSeries series) {
final int nbTicks = series.getTickCount();
Date[] dates = new Date[nbTicks];
double[] opens = new double[nbTicks];
double[] highs = new double[nbTicks];
double[] lows = new double[nbTicks];
double[] closes = new double[nbTicks];
double[] volumes = new double[nbTicks];
for (int i = 0; i < nbTicks; i++) {
Tick tick = series.getTick(i);
dates[i] = new Date(tick.getEndTime().toEpochSecond() * 1000);
opens[i] = tick.getOpenPrice().toDouble();
highs[i] = tick.getMaxPrice().toDouble();
lows[i] = tick.getMinPrice().toDouble();
closes[i] = tick.getClosePrice().toDouble();
volumes[i] = tick.getVolume().toDouble();
}
OHLCDataset dataset = new DefaultHighLowDataset("btc", dates, highs, lows, opens, closes, volumes);
return dataset;
}
示例3: createCandlestickChart
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
@Override
protected JFreeChart createCandlestickChart() throws JRException
{
JFreeChart jfreeChart = super.createCandlestickChart();
XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
CandlestickRenderer renderer = (CandlestickRenderer)xyPlot.getRenderer();
DefaultHighLowDataset dataset = (DefaultHighLowDataset)xyPlot.getDataset();
if (dataset != null)
{
for (int i = 0; i < dataset.getSeriesCount(); i++)
{
renderer.setSeriesFillPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(i));
renderer.setSeriesPaint(i, Color.DARK_GRAY);
}
}
return jfreeChart;
}
示例4: createCandlestickChart
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
@Override
protected JFreeChart createCandlestickChart() throws JRException
{
JFreeChart jfreeChart = super.createCandlestickChart();
XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
CandlestickRenderer renderer = (CandlestickRenderer)xyPlot.getRenderer();
DefaultHighLowDataset dataset = (DefaultHighLowDataset)xyPlot.getDataset();
@SuppressWarnings("unchecked")
List<Paint> seriesPaints = (List<Paint>)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS);
for(int i = 0; i < dataset.getSeriesCount(); i++)
{
renderer.setSeriesFillPaint(i, seriesPaints.get(i));
renderer.setSeriesPaint(i, Color.DARK_GRAY);
}
return jfreeChart;
}
示例5: setData
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
/**
* Sets data and converts it to JFreeChart format
* @param data Trendbars data
*/
private void setData(String seriesKey, TrendbarJson[] data) {
Date[] date = new Date[data.length];
double[] high = new double[data.length];
double[] low = new double[data.length];
double[] open = new double[data.length];
double[] close = new double[data.length];
double[] volume = new double[data.length];
for (int i = 0; i < data.length; i++) {
TrendbarJson trendbar = data[i];
date[i] = new Date(trendbar.getTimestamp());
if(trendbar.getHigh() > maxRange) {
maxRange = trendbar.getHigh();
}
high[i] = trendbar.getHigh();
low[i] = trendbar.getLow();
if(trendbar.getLow() < minRange) {
minRange = trendbar.getLow();
}
open[i] = trendbar.getOpen();
close[i] = trendbar.getClose();
volume[i] = trendbar.getVolume()/100.00;
}
this.dataSet = new DefaultHighLowDataset(seriesKey, date, high, low, open, close, volume);
}
示例6: getDefaultHighLowDataset
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
protected DefaultHighLowDataset getDefaultHighLowDataset(
final Currency currency, final GoodType goodType) {
final PricesModel pricesModel = ApplicationContext.getInstance()
.getModelRegistry().getNationalEconomyModel(currency).pricesModel;
final Map<GoodType, PriceModel> priceModelsForGoodType = pricesModel
.getPriceModelsForGoodTypes();
final PriceModel priceModel = priceModelsForGoodType.get(goodType);
if (priceModel != null) {
return new DefaultHighLowDataset("", priceModel.getDate(),
priceModel.getHigh(), priceModel.getLow(),
priceModel.getOpen(), priceModel.getClose(),
priceModel.getVolume());
}
return null;
}
示例7: getDefaultHighLowDataset
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
protected DefaultHighLowDataset getDefaultHighLowDataset(
final Currency currency) {
final PricesModel pricesModel = ApplicationContext.getInstance()
.getModelRegistry().getNationalEconomyModel(currency).pricesModel;
final Map<GoodType, PriceModel> priceModelsForGoodType = pricesModel
.getPriceModelsForGoodTypes();
final PriceModel priceModel = priceModelsForGoodType
.get(GoodType.LABOURHOUR);
if (priceModel != null) {
return new DefaultHighLowDataset("", priceModel.getDate(),
priceModel.getHigh(), priceModel.getLow(),
priceModel.getOpen(), priceModel.getClose(),
priceModel.getVolume());
}
return null;
}
示例8: getDefaultHighLowDataset
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
protected DefaultHighLowDataset getDefaultHighLowDataset(
final Currency currency, final Currency commodityCurrency) {
final PricesModel pricesModel = ApplicationContext.getInstance()
.getModelRegistry().getNationalEconomyModel(currency).pricesModel;
final Map<Currency, PriceModel> priceModelsForCurrencies = pricesModel
.getPriceModelsForCurrencies();
final PriceModel priceModel = priceModelsForCurrencies
.get(commodityCurrency);
if (priceModel != null) {
return new DefaultHighLowDataset("", priceModel.getDate(),
priceModel.getHigh(), priceModel.getLow(),
priceModel.getOpen(), priceModel.getClose(),
priceModel.getVolume());
}
return null;
}
示例9: createCandlestickChart
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
/**
*
* @param evaluation
* @throws net.sf.jasperreports.engine.JRException
*/
protected JFreeChart createCandlestickChart() throws JRException
{
ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
JFreeChart jfreeChart =
ChartFactory.createCandlestickChart(
evaluateTextExpression(getChart().getTitleExpression()),
evaluateTextExpression(((JRCandlestickPlot)getPlot()).getTimeAxisLabelExpression()),
evaluateTextExpression(((JRCandlestickPlot)getPlot()).getValueAxisLabelExpression()),
(DefaultHighLowDataset)getDataset(),
isShowLegend()
);
configureChart(jfreeChart, getPlot());
XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
JRCandlestickPlot candlestickPlot = (JRCandlestickPlot)getPlot();
CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer();
boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume().booleanValue();
candlestickRenderer.setDrawVolume(isShowVolume);
// Handle the axis formating for the category axis
configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(),
candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(),
candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(),
candlestickPlot.getOwnTimeAxisLineColor(), false,
(Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()),
(Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression()));
// Handle the axis formating for the value axis
configureAxis(xyPlot.getRangeAxis(), candlestickPlot.getValueAxisLabelFont(),
candlestickPlot.getValueAxisLabelColor(), candlestickPlot.getValueAxisTickLabelFont(),
candlestickPlot.getValueAxisTickLabelColor(), candlestickPlot.getValueAxisTickLabelMask(), candlestickPlot.getValueAxisVerticalTickLabels(),
candlestickPlot.getOwnValueAxisLineColor(), true,
(Comparable<?>)evaluateExpression(candlestickPlot.getRangeAxisMinValueExpression()),
(Comparable<?>)evaluateExpression(candlestickPlot.getRangeAxisMaxValueExpression()));
return jfreeChart;
}
示例10: getCustomDataset
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
@Override
public Dataset getCustomDataset()
{
int size = elements.size();
if (size > 0)
{
Date[] dateArray = new Date[size];
double[] highArray = new double[size];
double[] lowArray = new double[size];
double[] openArray = new double[size];
double[] closeArray = new double[size];
double[] volumeArray = new double[size];
for (int i = 0; i < elements.size(); i++) {
HighLowElement bean = elements.get(i);
dateArray[i] = new Date(bean.getDate().getTime());
highArray[i] = bean.getHigh().doubleValue();
lowArray[i] = bean.getLow().doubleValue();
openArray[i] = bean.getOpen().doubleValue();
closeArray[i] = bean.getClose().doubleValue();
volumeArray[i] = bean.getVolume().doubleValue();
}
return new DefaultHighLowDataset(series, dateArray, highArray, lowArray, openArray, closeArray, volumeArray);
}
return null;
}
示例11: createCandlestickChart
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
/**
*
*/
protected JFreeChart createCandlestickChart() throws JRException
{
ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
JFreeChart jfreeChart =
ChartFactory.createCandlestickChart(
evaluateTextExpression(getChart().getTitleExpression()),
evaluateTextExpression(((JRCandlestickPlot)getPlot()).getTimeAxisLabelExpression()),
evaluateTextExpression(((JRCandlestickPlot)getPlot()).getValueAxisLabelExpression()),
(DefaultHighLowDataset)getDataset(),
isShowLegend()
);
configureChart(jfreeChart);
XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
JRCandlestickPlot candlestickPlot = (JRCandlestickPlot)getPlot();
CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer();
boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume().booleanValue();
candlestickRenderer.setDrawVolume(isShowVolume);
// Handle the axis formating for the category axis
configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(),
candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(),
candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(),
candlestickPlot.getTimeAxisLineColor(), false,
(Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()),
(Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression()));
// Handle the axis formating for the value axis
configureAxis(xyPlot.getRangeAxis(), candlestickPlot.getValueAxisLabelFont(),
candlestickPlot.getValueAxisLabelColor(), candlestickPlot.getValueAxisTickLabelFont(),
candlestickPlot.getValueAxisTickLabelColor(), candlestickPlot.getValueAxisTickLabelMask(), candlestickPlot.getValueAxisVerticalTickLabels(),
candlestickPlot.getValueAxisLineColor(), true,
(Comparable<?>)evaluateExpression(candlestickPlot.getRangeAxisMinValueExpression()),
(Comparable<?>)evaluateExpression(candlestickPlot.getRangeAxisMaxValueExpression()));
return jfreeChart;
}
示例12: doSet
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
private void doSet() {
if(seriesTitle != null && date != null &&
high != null && low != null &&
open != null && close != null &&
volume != null) {
hlDataset = new DefaultHighLowDataset(seriesTitle, date, high, low, open, close, volume);
seriesTitle = null;
date = null;
high = low = open = close = volume = null;
}
}
示例13: testPublicCloneable
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
/**
* Verify that this class implements {@link PublicCloneable}.
*/
public void testPublicCloneable() {
DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1",
new Date[0], new double[0], new double[0], new double[0],
new double[0], new double[0]);
assertTrue(d1 instanceof PublicCloneable);
}
示例14: highLowChartDataTest
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
protected void highLowChartDataTest(JFreeChart chart, int series, Object[][] values) {
DefaultHighLowDataset dataset = (DefaultHighLowDataset) chart.getXYPlot().getDataset();
int index = 0;
for (Object[] value : values) {
Assert.assertEquals("chart data series", value[0], dataset.getSeriesKey(series));
Assert.assertEquals("chart data date", value[1], dataset.getXDate(series, index));
Assert.assertEquals("chart data high value", value[2], dataset.getHigh(series, index));
Assert.assertEquals("chart data low value", value[3], dataset.getLow(series, index));
Assert.assertEquals("chart data open value", value[4], dataset.getOpenValue(series, index));
Assert.assertEquals("chart data close value", value[5], dataset.getClose(series, index));
Assert.assertEquals("chart data volume value", value[6], dataset.getVolume(series, index));
index++;
}
}
示例15: _updateHighLowJLabels
import org.jfree.data.xy.DefaultHighLowDataset; //导入依赖的package包/类
/**
* Calculate and update high low value labels, according to current displayed
* time range. This is a time consuming method, and shall be called by
* user thread.
*/
private void _updateHighLowJLabels() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
ChartJDialog.this.jLabel2.setText("");
ChartJDialog.this.jLabel4.setText("");
}
});
final ValueAxis valueAxis = this.getPlot().getDomainAxis();
final Range range = valueAxis.getRange();
final long lowerBound = (long)range.getLowerBound();
final long upperBound = (long)range.getUpperBound();
final DefaultHighLowDataset defaultHighLowDataset = (DefaultHighLowDataset)this.priceOHLCDataset;
// Perform binary search, to located day in price time series, which
// is equal or lesser than upperBound.
int low = 0;
int high = defaultHighLowDataset.getItemCount(0) - 1;
long best_dist = Long.MAX_VALUE;
int best_mid = -1;
while (low <= high) {
int mid = (low + high) >>> 1;
long v = defaultHighLowDataset.getXDate(0, mid).getTime();
if (v > upperBound) {
high = mid - 1;
}
else if (v < upperBound) {
low = mid + 1;
long dist = upperBound - v;
if (dist < best_dist) {
best_dist = dist;
best_mid = mid;
}
}
else {
best_dist = 0;
best_mid = mid;
break;
}
}
if (best_mid < 0) {
return;
}
double high_last_price = Double.NEGATIVE_INFINITY;
double low_last_price = Double.MAX_VALUE;
for (int i = best_mid; i >= 0; i--) {
final long time = defaultHighLowDataset.getXDate(0, i).getTime();
if (time < lowerBound) {
break;
}
if (high_last_price < defaultHighLowDataset.getHighValue(0, i)) {
high_last_price = defaultHighLowDataset.getHighValue(0, i);
}
if (low_last_price > defaultHighLowDataset.getLowValue(0, i)) {
low_last_price = defaultHighLowDataset.getLowValue(0, i);
}
}
final double h = high_last_price;
final double l = low_last_price;
if (high_last_price >= low_last_price) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
ChartJDialog.this.jLabel2.setText(stockPriceDecimalFormat(h));
ChartJDialog.this.jLabel4.setText(stockPriceDecimalFormat(l));
}
});
}
}