本文整理汇总了Java中org.jfree.chart.plot.Marker.setLabelOffset方法的典型用法代码示例。如果您正苦于以下问题:Java Marker.setLabelOffset方法的具体用法?Java Marker.setLabelOffset怎么用?Java Marker.setLabelOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.plot.Marker
的用法示例。
在下文中一共展示了Marker.setLabelOffset方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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));
}
示例6: 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);
}
}
示例7: 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);
}