Java Code Examples for org.jfree.chart.plot.Marker#setLabel()
The following examples show how to use
org.jfree.chart.plot.Marker#setLabel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Chart.java From crypto-bot with Apache License 2.0 | 6 votes |
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.getBar(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.getBar(trade.getExit().getIndex()).getEndTime().toInstant())) .getFirstMillisecond(); Marker sellMarker = new ValueMarker(sellSignalTickTime); sellMarker.setPaint(Color.RED); sellMarker.setLabel("S"); plot.addDomainMarker(sellMarker); } }
Example 2
Source File: BuyAndSellSignalsToChart.java From ta4j-origins with MIT License | 6 votes |
/** * 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); } }
Example 3
Source File: ChartUtil.java From ezScrum with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unused") private void setMarker(XYPlot plot) { Iterator<Date> ir = m_dateMarkerMap.keySet().iterator(); int index = 1; while (ir.hasNext()) { Date key = ir.next(); final Marker marker = new IntervalMarker(key.getTime(), m_dateMarkerMap.get(key).getTime()); if (this.m_visualMarkerLabel) marker.setLabel("#" + index); // marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); // marker.setLabelTextAnchor(TextAnchor.TOP_LEFT); marker.setAlpha(0.3f); //marker.setPaint(this.m_markerColor); plot.addDomainMarker(marker); index++; } }
Example 4
Source File: DefaultChartService.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Returns a horizontal line marker for the given x value and label. */ private Marker getMarker( Double value, String label ) { Marker marker = new ValueMarker( value ); marker.setPaint( Color.BLACK ); marker.setStroke( new BasicStroke( 1.1f ) ); marker.setLabel( label ); marker.setLabelOffset( new RectangleInsets( -10, 50, 0, 0 ) ); marker.setLabelFont( SUB_TITLE_FONT ); return marker; }
Example 5
Source File: ChartImageGenerator.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Returns a horizontal line marker for the given x value and label. */ private Marker getMarker(Double value, String label ) { Marker marker = new ValueMarker( value ); marker.setPaint( Color.BLACK ); marker.setStroke( new BasicStroke( 1.1f ) ); marker.setLabel( label ); marker.setLabelOffset( new RectangleInsets( -10, 50, 0, 0 ) ); marker.setLabelFont( SUB_TITLE_FONT ); return marker; }
Example 6
Source File: AbstractMarkerCustomizer.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
protected void configureMarker(Marker marker) { String label = getProperty(PROPERTY_LABEL); if (label != null && label.length() > 0) { marker.setLabel(label); } RectangleAnchorEnum labelAnchor = RectangleAnchorEnum.getByName(getProperty(PROPERTY_LABEL_ANCHOR)); if (labelAnchor != null) { marker.setLabelAnchor(labelAnchor.getRectangleAnchor()); } Double offsetTop = getDoubleProperty(PROPERTY_LABEL_OFFSET_TOP); Double offsetLeft = getDoubleProperty(PROPERTY_LABEL_OFFSET_LEFT); Double offsetBottom = getDoubleProperty(PROPERTY_LABEL_OFFSET_BOTTOM); Double offsetRight = getDoubleProperty(PROPERTY_LABEL_OFFSET_RIGHT); if ( offsetTop != null || offsetLeft != null || offsetBottom != null || offsetRight != null ) { RectangleInsets currentOffset = marker.getLabelOffset(); marker.setLabelOffset( new RectangleInsets( offsetTop == null ? currentOffset.getTop() : offsetTop, offsetLeft == null ? currentOffset.getLeft() : offsetLeft, offsetBottom == null ? currentOffset.getBottom() : offsetBottom, offsetRight == null ? currentOffset.getRight() : offsetRight ) ); } TextAnchorEnum labelTextAnchor = TextAnchorEnum.getByName(getProperty(PROPERTY_LABEL_TEXT_ANCHOR)); if (labelTextAnchor != null) { marker.setLabelTextAnchor(labelTextAnchor.getTextAnchor()); } Color color = JRColorUtil.getColor(getProperty(PROPERTY_COLOR), null); if (color != null) { marker.setPaint(color); } Float alpha = getFloatProperty(PROPERTY_ALPHA); if (alpha != null) { marker.setAlpha(alpha); } }
Example 7
Source File: JPanelProfil.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
/** * Update the profil chart */ public void RefreshProfilChart() { if (track == null) return; if (track.data.isEmpty()) return; // -- Clear all series if (datasetProfil.getSeriesCount() > 0) datasetProfil.removeAllSeries(); XYPlot plot = chartProfil.getXYPlot(); plot.clearDomainMarkers(); // -- Populate the serie XYSeries serie1 = new XYSeries("Elevation/Distance"); int cmpt = 1; for (CgData r : track.data) { double x = r.getTotal(settings.Unit) / 1000; double y = r.getElevation(settings.Unit); serie1.add(x, y); if (((r.getTag() & CgConst.TAG_MARK) != 0) & showProfilMarker) { Marker m = new ValueMarker(x); m.setPaint(Color.GRAY); m.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); m.setLabel(String.valueOf(cmpt)); m.setLabelOffset(new RectangleInsets(5, 0, 0, 2)); m.setLabelAnchor(RectangleAnchor.TOP_RIGHT); m.setLabelTextAnchor(TextAnchor.TOP_LEFT); plot.addDomainMarker(m); cmpt++; } } datasetProfil.addSeries(serie1); if (track.getMaxElev(settings.Unit) > track.getMinElev(settings.Unit)) { // XYPlot plot = chart.getXYPlot(); ValueAxis axisY = plot.getRangeAxis(); axisY.setRange(Math.floor(track.getMinElev(settings.Unit) / 100.0) * 100.0, Math.ceil(track.getMaxElev(settings.Unit) / 100.0) * 100.0); } }