本文整理汇总了Java中org.jfree.chart.plot.XYPlot.addDomainMarker方法的典型用法代码示例。如果您正苦于以下问题:Java XYPlot.addDomainMarker方法的具体用法?Java XYPlot.addDomainMarker怎么用?Java XYPlot.addDomainMarker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.plot.XYPlot
的用法示例。
在下文中一共展示了XYPlot.addDomainMarker方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addBuySellSignals
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Runs a strategy over a time series and adds the value markers
* corresponding to buy/sell signals to the plot.
* @param series a time series
* @param strategy a trading strategy
* @param plot the plot
*/
private static void addBuySellSignals(TimeSeries series, Strategy strategy, XYPlot plot) {
// Running the strategy
TimeSeriesManager seriesManager = new TimeSeriesManager(series);
List<Trade> trades = seriesManager.run(strategy).getTrades();
// Adding markers to plot
for (Trade trade : trades) {
// Buy signal
double buySignalTickTime = new Minute(Date.from(series.getTick(trade.getEntry().getIndex()).getEndTime().toInstant())).getFirstMillisecond();
Marker buyMarker = new ValueMarker(buySignalTickTime);
buyMarker.setPaint(Color.GREEN);
buyMarker.setLabel("B");
plot.addDomainMarker(buyMarker);
// Sell signal
double sellSignalTickTime = new Minute(Date.from(series.getTick(trade.getExit().getIndex()).getEndTime().toInstant())).getFirstMillisecond();
Marker sellMarker = new ValueMarker(sellSignalTickTime);
sellMarker.setPaint(Color.RED);
sellMarker.setLabel("S");
plot.addDomainMarker(sellMarker);
}
}
示例2: addBuySellSignals
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private static void addBuySellSignals(TimeSeries series, Strategy strategy, XYPlot plot) {
// Running the strategy
TimeSeriesManager seriesManager = new TimeSeriesManager(series);
List<Trade> trades = seriesManager.run(strategy).getTrades();
// Adding markers to plot
for (Trade trade : trades) {
// Buy signal
double buySignalTickTime = new Minute(
Date.from(series.getTick(trade.getEntry().getIndex()).getEndTime().toInstant()))
.getFirstMillisecond();
Marker buyMarker = new ValueMarker(buySignalTickTime);
buyMarker.setPaint(Color.GREEN);
buyMarker.setLabel("B");
plot.addDomainMarker(buyMarker);
// Sell signal
double sellSignalTickTime = new Minute(
Date.from(series.getTick(trade.getExit().getIndex()).getEndTime().toInstant()))
.getFirstMillisecond();
Marker sellMarker = new ValueMarker(sellSignalTickTime);
sellMarker.setPaint(Color.RED);
sellMarker.setLabel("S");
plot.addDomainMarker(sellMarker);
}
}
示例3: testListenersWithXYPlot
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Checks that an XYPlot deregisters listeners when clearing markers.
*/
public void testListenersWithXYPlot() {
XYPlot plot = new XYPlot();
ValueMarker marker1 = new ValueMarker(1.0);
ValueMarker marker2 = new ValueMarker(2.0);
plot.addDomainMarker(marker1);
plot.addRangeMarker(marker2);
EventListener[] listeners1 = marker1.getListeners(
MarkerChangeListener.class);
assertTrue(Arrays.asList(listeners1).contains(plot));
EventListener[] listeners2 = marker1.getListeners(
MarkerChangeListener.class);
assertTrue(Arrays.asList(listeners2).contains(plot));
plot.clearDomainMarkers();
plot.clearRangeMarkers();
listeners1 = marker1.getListeners(MarkerChangeListener.class);
assertFalse(Arrays.asList(listeners1).contains(plot));
listeners2 = marker1.getListeners(MarkerChangeListener.class);
assertFalse(Arrays.asList(listeners2).contains(plot));
}
示例4: testAddDomainMarker
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Some tests for the addDomainMarker() method(s).
*/
public void testAddDomainMarker() {
XYPlot plot = new XYPlot();
Marker m = new ValueMarker(1.0);
plot.addDomainMarker(m);
List listeners = Arrays.asList(m.getListeners(
MarkerChangeListener.class));
assertTrue(listeners.contains(plot));
plot.clearDomainMarkers();
listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class));
assertFalse(listeners.contains(plot));
}