本文整理汇总了Java中org.jfree.chart.plot.Marker.setPaint方法的典型用法代码示例。如果您正苦于以下问题:Java Marker.setPaint方法的具体用法?Java Marker.setPaint怎么用?Java Marker.setPaint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.plot.Marker
的用法示例。
在下文中一共展示了Marker.setPaint方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addBuySellSignals
import org.jfree.chart.plot.Marker; //导入方法依赖的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.Marker; //导入方法依赖的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: addRegionMarker
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
private void addRegionMarker( double x ) {
Marker marker = new ValueMarker( x );
marker.setPaint( _markerColor );
marker.setStroke( QTConstants.REGION_MARKER_STROKE );
Iterator i = _plots.iterator();
while ( i.hasNext() ) {
XYPlot plot = (XYPlot) i.next();
plot.addDomainMarker( marker );
}
}
示例4: updateValuesBarChart
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
/**
* Update values of a bar chart
*
* @param labelsByFreq Labels ordered by frequency
* @param nInstances Number of instances
* @param cp CategoryPlot
*/
public static void updateValuesBarChart(ImbalancedFeature[] labelsByFreq,
int nInstances, CategoryPlot cp)
{
DefaultCategoryDataset data = new DefaultCategoryDataset();
double prob;
labelsByFreq = MetricUtils.sortByFrequency(labelsByFreq);
double sum = 0.0;
for(int i=0; i<labelsByFreq.length;i++)
{
prob = labelsByFreq[i].getAppearances()*1.0/nInstances;
sum += prob;
data.setValue(prob, labelsByFreq[i].getName()," ");
}
cp.setDataset(data);
// add mean mark
sum = sum/labelsByFreq.length;
Marker start = new ValueMarker(sum);
start.setPaint(Color.red);
start.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
start.setLabel(" Mean: "+MetricUtils.truncateValue(sum, 3));
cp.addRangeMarker(start);
}
示例5: updateIRBarChart
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
/**
* Update IR bar chart
*
* @param labelsByFrequency Labels ordered by frequency
* @param IR Imbalance Ratio values
* @param cp CategoryPlot
*/
public static void updateIRBarChart(ImbalancedFeature[] labelsByFrequency,
double[] IR, CategoryPlot cp)
{
DefaultCategoryDataset myData = new DefaultCategoryDataset();
double prob = 0;
labelsByFrequency = MetricUtils.sortByFrequency(labelsByFrequency);
double sum = 0.0;
for(int i=labelsByFrequency.length-1; i>=0; i--)
{
prob= IR[i];
sum += prob;
myData.setValue(prob, labelsByFrequency[i].getName()," ");
}
cp.setDataset(myData);
// add mean mark
sum = sum/labelsByFrequency.length;
Marker meanMark = new ValueMarker(sum);
meanMark.setPaint(Color.red);
meanMark.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
meanMark.setLabel(" Mean: "+MetricUtils.truncateValue(sum, 3));
cp.addRangeMarker(meanMark);
//Add Imbalance limit mark
Marker limitMark = new ValueMarker(1.5);
limitMark.setPaint(Color.black);
limitMark.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
if((sum < 1.3) || (sum > 1.7)){
limitMark.setLabel(" Imbalance limit (IR=1.5)");
}
cp.addRangeMarker(limitMark);
}
示例6: getMarker
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
/**
* 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;
}
示例7: createWaterfallChart
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
/**
* Creates a waterfall chart. The chart object returned by this method
* uses a {@link CategoryPlot} instance as the plot, with a
* {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
* range axis, and a {@link WaterfallBarRenderer} as the renderer.
*
* @param title the chart title (<code>null</code> permitted).
* @param categoryAxisLabel the label for the category axis
* (<code>null</code> permitted).
* @param valueAxisLabel the label for the value axis (<code>null</code>
* permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param legend a flag specifying whether or not a legend is required.
*
* @return A waterfall chart.
*/
public static JFreeChart createWaterfallChart(String title,
String categoryAxisLabel, String valueAxisLabel,
CategoryDataset dataset, boolean legend) {
CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
categoryAxis.setCategoryMargin(0.0);
ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
WaterfallBarRenderer renderer = new WaterfallBarRenderer();
ItemLabelPosition position = new ItemLabelPosition(
ItemLabelAnchor.CENTER, TextAnchor.CENTER,
TextAnchor.CENTER, 0.0);
renderer.setBasePositiveItemLabelPosition(position);
renderer.setBaseNegativeItemLabelPosition(position);
StandardCategoryToolTipGenerator generator
= new StandardCategoryToolTipGenerator();
renderer.setBaseToolTipGenerator(generator);
CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
renderer);
plot.clearRangeMarkers();
Marker baseline = new ValueMarker(0.0);
baseline.setPaint(Color.black);
plot.addRangeMarker(baseline, Layer.FOREGROUND);
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
plot, legend);
currentTheme.apply(chart);
return chart;
}
示例8: addDomainMarker
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
public void addDomainMarker(Amount<X> x, String label, Color c){
double xVal = x.doubleValue(xUnit);
Marker marker = new ValueMarker(xVal);
marker.setStroke(dashed);
marker.setPaint(c);
marker.setLabelPaint(c);
marker.setLabelFont(labelFont);
marker.setLabel(label + ": " + RocketScience.ammountToRoundedString(x));
marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
marker.setLabelOffset(new RectangleInsets(0, -5, 0, 0));
chart.getXYPlot().addDomainMarker(marker);
}
示例9: addRangeMarker
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
public void addRangeMarker(Amount<Y> y, String label, Color c){
double yVal = y.doubleValue(yUnit);
Marker marker = new ValueMarker(yVal);
marker.setStroke(dashed);
marker.setPaint(c);
marker.setLabelPaint(c);
marker.setLabelFont(labelFont);
marker.setLabel(label + ": " + RocketScience.ammountToRoundedString(y));
marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
marker.setLabelOffset(new RectangleInsets(0, 5, 0, 0));
chart.getXYPlot().addRangeMarker(marker);
}
示例10: testEquals
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
Marker m1 = new ValueMarker(45.0);
Marker m2 = new ValueMarker(45.0);
assertTrue(m1.equals(m2));
assertTrue(m2.equals(m1));
m1.setPaint(Color.red);
assertFalse(m1.equals(m2));
m2.setPaint(Color.red);
assertTrue(m1.equals(m2));
BasicStroke stroke = new BasicStroke(2.2f);
m1.setStroke(stroke);
assertFalse(m1.equals(m2));
m2.setStroke(stroke);
assertTrue(m1.equals(m2));
m1.setOutlinePaint(Color.red);
assertFalse(m1.equals(m2));
m2.setOutlinePaint(Color.red);
assertTrue(m1.equals(m2));
m1.setOutlineStroke(stroke);
assertFalse(m1.equals(m2));
m2.setOutlineStroke(stroke);
assertTrue(m1.equals(m2));
m1.setAlpha(0.1f);
assertFalse(m1.equals(m2));
m2.setAlpha(0.1f);
assertTrue(m1.equals(m2));
m1.setLabel("New Label");
assertFalse(m1.equals(m2));
m2.setLabel("New Label");
assertTrue(m1.equals(m2));
m1.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
assertFalse(m1.equals(m2));
m2.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
assertTrue(m1.equals(m2));
m1.setLabelPaint(Color.red);
assertFalse(m1.equals(m2));
m2.setLabelPaint(Color.red);
assertTrue(m1.equals(m2));
m1.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
assertFalse(m1.equals(m2));
m2.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
assertTrue(m1.equals(m2));
m1.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT);
assertFalse(m1.equals(m2));
m2.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT);
assertTrue(m1.equals(m2));
m1.setLabelOffset(new RectangleInsets(UnitType.ABSOLUTE, 10.0, 10.0, 10.0, 10.0));
assertFalse(m1.equals(m2));
m2.setLabelOffset(new RectangleInsets(UnitType.ABSOLUTE, 10.0, 10.0, 10.0, 10.0));
assertTrue(m1.equals(m2));
}
示例11: createChartPanel
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
private JPanel createChartPanel( Font font, Bead bead, Laser laser ) {
PhetPCanvas canvas = new PhetPCanvas();
canvas.setPreferredSize( CHART_SIZE );
_snapshotClipNode = new PClip();
_snapshotClipNode.setPathTo( new Rectangle2D.Double( 0, 0, CHART_SIZE.width, CHART_SIZE.height ) );
_snapshotClipNode.setPaint( null );
_snapshotClipNode.setStroke( null );
_snapshotClipNode.setOffset( 0, 0 );
_plot = new PositionHistogramPlot();
_plot.setBackgroundPaint( CHART_BACKGROUND_COLOR );
// add a vertical marker at position=0
Marker originMarker = new ValueMarker( 0 );
originMarker.setLabel("");
originMarker.setPaint( OTConstants.ORIGIN_MARKER_COLOR );
originMarker.setStroke( OTConstants.ORIGIN_MARKER_STROKE );
_plot.addDomainMarker(originMarker);
_chart = new JFreeChart( null /* title */, null /* titleFont */, _plot, false /* createLegend */);
_chart.setAntiAlias( true );
_chart.setBorderVisible( true );
_chart.setBackgroundPaint( CHART_BACKGROUND_COLOR );
_chartNode = new JFreeChartNode( _chart );
_chartNode.setPickable( false );
_chartNode.setChildrenPickable( false );
_chartNode.setOffset( 0, 0 );
_chartNode.setBounds( 0, 0, CHART_SIZE.width, CHART_SIZE.height );
_chartNode.updateChartRenderingInfo();
_measurementsNode = new PText( "?" );
_measurementsNode.setOffset( 10, 10 );
_measurementsNode.setPickable( false );
setNumberOfMeasurements( _numberOfMeasurements );
_binWidthNode = new PText();
_binWidthNode.setOffset( _measurementsNode.getXOffset(), _measurementsNode.getFullBounds().getMaxY() + 3 );
_binWidthNode.setPickable( false );
_rulerParentNode = new PNode();
_rulerParentNode.setOffset( 0, 0 );
// Layering
_snapshotClipNode.addChild( _chartNode );
_snapshotClipNode.addChild( _measurementsNode );
_snapshotClipNode.addChild( _binWidthNode );
_snapshotClipNode.addChild( _rulerParentNode );
canvas.getLayer().addChild( _snapshotClipNode );
JPanel panel = new JPanel();
panel.add( canvas );
return panel;
}
示例12: configureMarker
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
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);
}
}