本文整理汇总了Java中org.jfree.chart.labels.XYItemLabelGenerator.generateLabel方法的典型用法代码示例。如果您正苦于以下问题:Java XYItemLabelGenerator.generateLabel方法的具体用法?Java XYItemLabelGenerator.generateLabel怎么用?Java XYItemLabelGenerator.generateLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.labels.XYItemLabelGenerator
的用法示例。
在下文中一共展示了XYItemLabelGenerator.generateLabel方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawItemLabel
import org.jfree.chart.labels.XYItemLabelGenerator; //导入方法依赖的package包/类
/**
* Draws an item label.
*
* @param g2 the graphics device.
* @param orientation the orientation.
* @param dataset the dataset.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param x the x coordinate (in Java2D space).
* @param y the y coordinate (in Java2D space).
* @param negative indicates a negative value (which affects the item
* label position).
*/
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
XYDataset dataset, int series, int item, double x, double y,
boolean negative) {
XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
if (generator != null) {
Font labelFont = getItemLabelFont(series, item);
Paint paint = getItemLabelPaint(series, item);
g2.setFont(labelFont);
g2.setPaint(paint);
String label = generator.generateLabel(dataset, series, item);
// get the label position..
ItemLabelPosition position = null;
if (!negative) {
position = getPositiveItemLabelPosition(series, item);
}
else {
position = getNegativeItemLabelPosition(series, item);
}
// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), x, y, orientation);
TextUtilities.drawRotatedString(label, g2,
(float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
}
}
示例2: drawItemLabel
import org.jfree.chart.labels.XYItemLabelGenerator; //导入方法依赖的package包/类
/**
* Draws an item label.
*
* @param g2 the graphics device.
* @param orientation the orientation.
* @param dataset the dataset.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param x the x coordinate (in Java2D space).
* @param y the y coordinate (in Java2D space).
* @param negative indicates a negative value (which affects the item
* label position).
*/
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
XYDataset dataset, int series, int item, double x, double y,
boolean negative) {
XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
if (generator != null) {
Font labelFont = getItemLabelFont(series, item);
Paint paint = getItemLabelPaint(series, item);
g2.setFont(labelFont);
g2.setPaint(paint);
String label = generator.generateLabel(dataset, series, item);
// get the label position..
ItemLabelPosition position;
if (!negative) {
position = getPositiveItemLabelPosition(series, item);
}
else {
position = getNegativeItemLabelPosition(series, item);
}
// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), x, y, orientation);
TextUtilities.drawRotatedString(label, g2,
(float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
}
}
示例3: drawItemLabel
import org.jfree.chart.labels.XYItemLabelGenerator; //导入方法依赖的package包/类
/**
* Draws an item label.
*
* @param g2 the graphics device.
* @param orientation the orientation.
* @param dataset the dataset.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param x the x coordinate (in Java2D space).
* @param y the y coordinate (in Java2D space).
* @param negative indicates a negative value (which affects the item
* label position).
*/
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
XYDataset dataset, int series, int item, double x, double y,
boolean negative) {
XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
if (generator != null) {
Font labelFont = getItemLabelFont(series, item);
Paint paint = getItemLabelPaint(series, item);
g2.setFont(labelFont);
g2.setPaint(paint);
String label = generator.generateLabel(dataset, series, item);
// get the label position..
ItemLabelPosition position;
if (!negative) {
position = getPositiveItemLabelPosition(series, item);
}
else {
position = getNegativeItemLabelPosition(series, item);
}
// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), x, y, orientation);
TextUtils.drawRotatedString(label, g2,
(float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
}
}
示例4: drawItemLabel
import org.jfree.chart.labels.XYItemLabelGenerator; //导入方法依赖的package包/类
/**
* Draws an item label.
*
* @param g2
* the graphics device.
* @param orientation
* the orientation.
* @param dataset
* the dataset.
* @param series
* the series index (zero-based).
* @param item
* the item index (zero-based).
* @param x
* the x coordinate (in Java2D space).
* @param y
* the y coordinate (in Java2D space).
* @param negative
* indicates a negative value (which affects the item label
* position).
*/
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
XYDataset dataset, int series, int item, double x, double y,
boolean negative) {
XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
Font labelFont = getItemLabelFont(series, item);
g2.setFont(labelFont);
String label = generator.generateLabel(dataset, series, item);
if ((label == null) || (label.length() == 0))
return;
// get the label position..
ItemLabelPosition position = null;
if (!negative) {
position = getPositiveItemLabelPosition(series, item);
} else {
position = getNegativeItemLabelPosition(series, item);
}
// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), x, y, orientation);
FontMetrics metrics = g2.getFontMetrics(labelFont);
int width = SwingUtilities.computeStringWidth(metrics, label) + 2;
int height = metrics.getHeight();
int X = (int) (anchorPoint.getX() - (width / 2));
int Y = (int) (anchorPoint.getY() - (height));
g2.setPaint(searchColor);
g2.fillRect(X, Y, width, height);
super.drawItemLabel(g2, orientation, dataset, series, item, x, y,
negative);
}
示例5: drawItemLabel
import org.jfree.chart.labels.XYItemLabelGenerator; //导入方法依赖的package包/类
private void drawItemLabel(Graphics2D g2, PlotOrientation orientation, XYDataset dataset, int series, int item, Rectangle2D bar, boolean negative) {
XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
if (generator == null)
return;
String label = generator.generateLabel(dataset, series, item);
if (label == null) {
return; // nothing to do
}
Font labelFont = getItemLabelFont(series, item);
g2.setFont(labelFont);
Paint paint = getItemLabelPaint(series, item);
g2.setPaint(paint);
// find out where to place the label...
ItemLabelPosition position = null;
if (!negative) {
position = getPositiveItemLabelPosition(series, item);
} else {
position = getNegativeItemLabelPosition(series, item);
}
// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, orientation);
TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor());
}
示例6: drawItemLabel
import org.jfree.chart.labels.XYItemLabelGenerator; //导入方法依赖的package包/类
/**
* Draws an item label.
*
* @param g2 the graphics device.
* @param orientation the orientation.
* @param dataset the dataset.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param selected is the item selected?
* @param x the x coordinate (in Java2D space).
* @param y the y coordinate (in Java2D space).
* @param negative indicates a negative value (which affects the item
* label position).
*
* @since 1.2.0
*/
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
XYDataset dataset, int series, int item, boolean selected,
double x, double y, boolean negative) {
XYItemLabelGenerator generator = getItemLabelGenerator(series, item,
selected);
if (generator != null) {
Font labelFont = getItemLabelFont(series, item, selected);
Paint paint = getItemLabelPaint(series, item, selected);
g2.setFont(labelFont);
g2.setPaint(paint);
String label = generator.generateLabel(dataset, series, item);
// get the label position..
ItemLabelPosition position = null;
if (!negative) {
position = getPositiveItemLabelPosition(series, item,
selected);
}
else {
position = getNegativeItemLabelPosition(series, item,
selected);
}
// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), x, y, orientation);
TextUtilities.drawRotatedString(label, g2,
(float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
}
}
示例7: drawItemLabel
import org.jfree.chart.labels.XYItemLabelGenerator; //导入方法依赖的package包/类
/**
* Draws an item label.
*
* @param g2 the graphics device.
* @param orientation the orientation.
* @param dataset the dataset.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param x the x coordinate (in Java2D space).
* @param y the y coordinate (in Java2D space).
* @param negative indicates a negative value (which affects the item
* label position).
*/
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
XYDataset dataset, int series, int item, double x, double y,
boolean negative) {
XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
if (generator != null) {
Font labelFont = getItemLabelFont(series, item);
Paint paint = getItemLabelPaint(series, item);
g2.setFont(labelFont);
g2.setPaint(paint);
String label = generator.generateLabel(dataset, series, item);
// get the label position..
ItemLabelPosition position = null;
if (!negative) {
position = getPositiveItemLabelPosition(series, item);
}
else {
position = getNegativeItemLabelPosition(series, item);
}
// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), x, y, orientation);
TextUtilities.drawRotatedString(label, g2,
(float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
}
}
示例8: drawItemLabel
import org.jfree.chart.labels.XYItemLabelGenerator; //导入方法依赖的package包/类
/**
* Draws an item label. This method is overridden so that the bar can be
* used to calculate the label anchor point.
*
* @param g2 the graphics device.
* @param dataset the dataset.
* @param series the series index.
* @param item the item index.
* @param plot the plot.
* @param generator the label generator.
* @param bar the bar.
* @param negative a flag indicating a negative value.
*/
protected void drawItemLabel(Graphics2D g2, XYDataset dataset,
int series, int item, XYPlot plot, XYItemLabelGenerator generator,
Rectangle2D bar, boolean negative) {
String label = generator.generateLabel(dataset, series, item);
if (label == null) {
return; // nothing to do
}
Font labelFont = getItemLabelFont(series, item);
g2.setFont(labelFont);
Paint paint = getItemLabelPaint(series, item);
g2.setPaint(paint);
// find out where to place the label...
ItemLabelPosition position = null;
if (!negative) {
position = getPositiveItemLabelPosition(series, item);
}
else {
position = getNegativeItemLabelPosition(series, item);
}
// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), bar, plot.getOrientation());
if (isInternalAnchor(position.getItemLabelAnchor())) {
Shape bounds = TextUtilities.calculateRotatedStringBounds(label,
g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
if (bounds != null) {
if (!bar.contains(bounds.getBounds2D())) {
if (!negative) {
position = getPositiveItemLabelPositionFallback();
}
else {
position = getNegativeItemLabelPositionFallback();
}
if (position != null) {
anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), bar,
plot.getOrientation());
}
}
}
}
if (position != null) {
TextUtilities.drawRotatedString(label, g2,
(float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
}
}
示例9: drawItemLabel
import org.jfree.chart.labels.XYItemLabelGenerator; //导入方法依赖的package包/类
/**
* Draws an item label. This method is provided as an alternative to
* {@link #drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int,
* double, double, boolean)} so that the bar can be used to calculate the
* label anchor point.
*
* @param g2 the graphics device.
* @param dataset the dataset.
* @param series the series index.
* @param item the item index.
* @param plot the plot.
* @param generator the label generator (<code>null</code> permitted, in
* which case the method does nothing, just returns).
* @param bar the bar.
* @param negative a flag indicating a negative value.
*/
protected void drawItemLabel(Graphics2D g2, XYDataset dataset,
int series, int item, XYPlot plot, XYItemLabelGenerator generator,
Rectangle2D bar, boolean negative) {
if (generator == null) {
return; // nothing to do
}
String label = generator.generateLabel(dataset, series, item);
if (label == null) {
return; // nothing to do
}
Font labelFont = getItemLabelFont(series, item);
g2.setFont(labelFont);
Paint paint = getItemLabelPaint(series, item);
g2.setPaint(paint);
// find out where to place the label...
ItemLabelPosition position;
if (!negative) {
position = getPositiveItemLabelPosition(series, item);
}
else {
position = getNegativeItemLabelPosition(series, item);
}
// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), bar, plot.getOrientation());
if (isInternalAnchor(position.getItemLabelAnchor())) {
Shape bounds = TextUtilities.calculateRotatedStringBounds(label,
g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
if (bounds != null) {
if (!bar.contains(bounds.getBounds2D())) {
if (!negative) {
position = getPositiveItemLabelPositionFallback();
}
else {
position = getNegativeItemLabelPositionFallback();
}
if (position != null) {
anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), bar,
plot.getOrientation());
}
}
}
}
if (position != null) {
TextUtilities.drawRotatedString(label, g2,
(float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
}
}
示例10: drawItemLabel
import org.jfree.chart.labels.XYItemLabelGenerator; //导入方法依赖的package包/类
/**
* Draws an item label. This method is provided as an alternative to
* {@link #drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int,
* double, double, boolean)} so that the bar can be used to calculate the
* label anchor point.
*
* @param g2 the graphics device.
* @param dataset the dataset.
* @param series the series index.
* @param item the item index.
* @param plot the plot.
* @param generator the label generator ({@code null} permitted, in
* which case the method does nothing, just returns).
* @param bar the bar.
* @param negative a flag indicating a negative value.
*/
protected void drawItemLabel(Graphics2D g2, XYDataset dataset,
int series, int item, XYPlot plot, XYItemLabelGenerator generator,
Rectangle2D bar, boolean negative) {
if (generator == null) {
return; // nothing to do
}
String label = generator.generateLabel(dataset, series, item);
if (label == null) {
return; // nothing to do
}
Font labelFont = getItemLabelFont(series, item);
g2.setFont(labelFont);
Paint paint = getItemLabelPaint(series, item);
g2.setPaint(paint);
// find out where to place the label...
ItemLabelPosition position;
if (!negative) {
position = getPositiveItemLabelPosition(series, item);
} else {
position = getNegativeItemLabelPosition(series, item);
}
// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), bar, plot.getOrientation());
if (isInternalAnchor(position.getItemLabelAnchor())) {
Shape bounds = TextUtils.calculateRotatedStringBounds(label,
g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
if (bounds != null) {
if (!bar.contains(bounds.getBounds2D())) {
if (!negative) {
position = getPositiveItemLabelPositionFallback();
}
else {
position = getNegativeItemLabelPositionFallback();
}
if (position != null) {
anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), bar,
plot.getOrientation());
}
}
}
}
if (position != null) {
TextUtils.drawRotatedString(label, g2,
(float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
}
}
示例11: drawItemLabel
import org.jfree.chart.labels.XYItemLabelGenerator; //导入方法依赖的package包/类
/**
* Draws an item label. This method is provided as an alternative to
* {@link #drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int,
* double, double, boolean)} so that the bar can be used to calculate the
* label anchor point.
*
* @param g2 the graphics device.
* @param dataset the dataset.
* @param series the series index.
* @param item the item index.
* @param plot the plot.
* @param generator the label generator (<code>null</code> permitted, in
* which case the method does nothing, just returns).
* @param bar the bar.
* @param negative a flag indicating a negative value.
*/
protected void drawItemLabel(Graphics2D g2, XYDataset dataset,
int series, int item, XYPlot plot, XYItemLabelGenerator generator,
Rectangle2D bar, boolean negative) {
if (generator == null) {
return; // nothing to do
}
String label = generator.generateLabel(dataset, series, item);
if (label == null) {
return; // nothing to do
}
Font labelFont = getItemLabelFont(series, item);
g2.setFont(labelFont);
Paint paint = getItemLabelPaint(series, item);
g2.setPaint(paint);
// find out where to place the label...
ItemLabelPosition position = null;
if (!negative) {
position = getPositiveItemLabelPosition(series, item);
}
else {
position = getNegativeItemLabelPosition(series, item);
}
// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), bar, plot.getOrientation());
if (isInternalAnchor(position.getItemLabelAnchor())) {
Shape bounds = TextUtilities.calculateRotatedStringBounds(label,
g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
if (bounds != null) {
if (!bar.contains(bounds.getBounds2D())) {
if (!negative) {
position = getPositiveItemLabelPositionFallback();
}
else {
position = getNegativeItemLabelPositionFallback();
}
if (position != null) {
anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), bar,
plot.getOrientation());
}
}
}
}
if (position != null) {
TextUtilities.drawRotatedString(label, g2,
(float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
}
}
示例12: drawItemLabelForBar
import org.jfree.chart.labels.XYItemLabelGenerator; //导入方法依赖的package包/类
/**
* Draws an item label. This method is provided as an alternative to
* {@link #drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int,
* double, double, boolean)} so that the bar can be used to calculate the
* label anchor point.
*
* @param g2 the graphics device.
* @param dataset the dataset.
* @param series the series index.
* @param item the item index.
* @param selected is the data item selected?
* @param plot the plot.
* @param generator the label generator (<code>null</code> permitted, in
* which case the method does nothing, just returns).
* @param bar the bar.
* @param negative a flag indicating a negative value.
*
* @since 1.2.0
*/
protected void drawItemLabelForBar(Graphics2D g2, XYPlot plot,
XYDataset dataset, int series, int item, boolean selected,
XYItemLabelGenerator generator, Rectangle2D bar,
boolean negative) {
if (generator == null) {
return; // nothing to do
}
String label = generator.generateLabel(dataset, series, item);
if (label == null) {
return; // nothing to do
}
Font labelFont = getItemLabelFont(series, item, selected);
g2.setFont(labelFont);
Paint paint = getItemLabelPaint(series, item, selected);
g2.setPaint(paint);
// find out where to place the label...
ItemLabelPosition position = null;
if (!negative) {
position = getPositiveItemLabelPosition(series, item, selected);
}
else {
position = getNegativeItemLabelPosition(series, item, selected);
}
// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), bar, plot.getOrientation());
if (isInternalAnchor(position.getItemLabelAnchor())) {
Shape bounds = TextUtilities.calculateRotatedStringBounds(label,
g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
if (bounds != null) {
if (!bar.contains(bounds.getBounds2D())) {
if (!negative) {
position = getPositiveItemLabelPositionFallback();
}
else {
position = getNegativeItemLabelPositionFallback();
}
if (position != null) {
anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), bar,
plot.getOrientation());
}
}
}
}
if (position != null) {
TextUtilities.drawRotatedString(label, g2,
(float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
}
}