本文整理汇总了Java中org.jfree.chart.plot.Marker.setLabel方法的典型用法代码示例。如果您正苦于以下问题:Java Marker.setLabel方法的具体用法?Java Marker.setLabel怎么用?Java Marker.setLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.plot.Marker
的用法示例。
在下文中一共展示了Marker.setLabel方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: attachLabels
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
/**
* replaces the marker keys with their message labels from the resource bundle. Also sets the subTitle of the graph.
*/
private void attachLabels(final StatisticalResultDTO rawDataObject, final ConversionSimulationDTO dto, final ActionContext context) {
final Marker[] markers = rawDataObject.getDomainMarkers();
if (markers != null) {
for (final Marker marker : markers) {
final String key = marker.getLabel();
if (key != null) {
final String title = context.message(key);
marker.setLabel(title);
}
}
}
final LocalSettings localSettings = settingsService.getLocalSettings();
TransferType transferType = dto.getTransferType();
transferType = transferTypeService.load(transferType.getId(), TransferType.Relationships.TRANSACTION_FEES, RelationshipHelper.nested(TransferType.Relationships.FROM, AccountType.Relationships.CURRENCY));
final String unitsPattern = transferType.getFrom().getCurrency().getPattern();
final NumberConverter<BigDecimal> numberConverter = localSettings.getUnitsConverter(unitsPattern);
final String numberString = numberConverter.toString(dto.getAmount());
final String subTitle = context.message("conversionSimulation.result.graph.subtitle", numberString);
rawDataObject.setSubTitle(subTitle);
}
示例4: setMarker
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
@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++;
}
}
示例5: 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);
}
示例6: 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);
}
示例7: 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;
}
示例8: createMarker
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
/** Factory method that creates the marker for the annotation */
public void createMarker(XYPlot plot) {
Marker marker = doCreateMarker();
marker.setLabel(getMnemonic());
marker.setLabelOffset(new RectangleInsets(PAD, PAD, PAD, PAD));
plot.addDomainMarker(marker, Layer.BACKGROUND);
}
示例9: 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);
}
示例10: 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);
}
示例11: 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));
}
示例12: 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;
}
示例13: 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);
}
}
示例14: decorate
import org.jfree.chart.plot.Marker; //导入方法依赖的package包/类
@Override
protected void decorate(final NumberAnalyzerResult result, final DCTable table,
final DisplayChartCallback displayChartCallback) {
// find the std. deviation row number.
int rowNumber = -1;
{
for (int i = 0; i < table.getRowCount(); i++) {
final Object value = table.getValueAt(i, 0);
if (NumberAnalyzer.MEASURE_STANDARD_DEVIATION.equals(value)) {
rowNumber = i;
break;
}
}
if (rowNumber == -1) {
throw new IllegalStateException("Could not determine Std. deviation row number!");
}
}
final Crosstab<?> crosstab = result.getCrosstab();
final InputColumn<? extends Number>[] columns = result.getColumns();
int columnNumber = 1;
for (final InputColumn<? extends Number> column : columns) {
final CrosstabNavigator<?> nav = crosstab.where(NumberAnalyzer.DIMENSION_COLUMN, column.getName());
final Number numRows =
(Number) nav.where(NumberAnalyzer.DIMENSION_MEASURE, NumberAnalyzer.MEASURE_ROW_COUNT).get();
if (numRows.intValue() > 0) {
final Number standardDeviation =
(Number) nav.where(NumberAnalyzer.DIMENSION_MEASURE, NumberAnalyzer.MEASURE_STANDARD_DEVIATION)
.get();
if (standardDeviation != null) {
final ActionListener action = e -> {
final Number mean =
(Number) nav.where(NumberAnalyzer.DIMENSION_MEASURE, NumberAnalyzer.MEASURE_MEAN).get();
final Number min = (Number) nav
.where(NumberAnalyzer.DIMENSION_MEASURE, NumberAnalyzer.MEASURE_LOWEST_VALUE).get();
final Number max = (Number) nav
.where(NumberAnalyzer.DIMENSION_MEASURE, NumberAnalyzer.MEASURE_HIGHEST_VALUE).get();
final NormalDistributionFunction2D normalDistributionFunction =
new NormalDistributionFunction2D(mean.doubleValue(), standardDeviation.doubleValue());
final XYDataset dataset = DatasetUtilities
.sampleFunction2D(normalDistributionFunction, min.doubleValue(), max.doubleValue(), 100,
"Normal");
final JFreeChart chart = ChartFactory
.createXYLineChart("Normal distribution of " + column.getName(), column.getName(), "",
dataset, PlotOrientation.VERTICAL, false, true, false);
ChartUtils.applyStyles(chart);
final Marker meanMarker = new ValueMarker(mean.doubleValue(), WidgetUtils.BG_COLOR_BLUE_DARK,
new BasicStroke(2f));
meanMarker.setLabel("Mean");
meanMarker.setLabelOffset(new RectangleInsets(70d, 25d, 0d, 0d));
meanMarker.setLabelFont(WidgetUtils.FONT_SMALL);
chart.getXYPlot().addDomainMarker(meanMarker);
final ChartPanel chartPanel = ChartUtils.createPanel(chart, true);
displayChartCallback.displayChart(chartPanel);
};
final DCPanel panel = AbstractCrosstabResultSwingRenderer
.createActionableValuePanel(standardDeviation, Alignment.RIGHT, action,
IconUtils.CHART_LINE);
table.setValueAt(panel, rowNumber, columnNumber);
}
}
columnNumber++;
}
super.decorate(result, table, displayChartCallback);
}