本文整理汇总了Java中org.jfree.chart.plot.Crosshair.isLabelVisible方法的典型用法代码示例。如果您正苦于以下问题:Java Crosshair.isLabelVisible方法的具体用法?Java Crosshair.isLabelVisible怎么用?Java Crosshair.isLabelVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.plot.Crosshair
的用法示例。
在下文中一共展示了Crosshair.isLabelVisible方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawHorizontalCrosshair
import org.jfree.chart.plot.Crosshair; //导入方法依赖的package包/类
/**
* Draws a crosshair horizontally across the plot.
*
* @param g2 the graphics target.
* @param dataArea the data area.
* @param y the y-value in Java2D space.
* @param crosshair the crosshair.
*/
protected void drawHorizontalCrosshair(Graphics2D g2, Rectangle2D dataArea,
double y, Crosshair crosshair) {
if (y >= dataArea.getMinY() && y <= dataArea.getMaxY()) {
Line2D line = new Line2D.Double(dataArea.getMinX(), y,
dataArea.getMaxX(), y);
Paint savedPaint = g2.getPaint();
Stroke savedStroke = g2.getStroke();
g2.setPaint(crosshair.getPaint());
g2.setStroke(crosshair.getStroke());
g2.draw(line);
if (crosshair.isLabelVisible()) {
String label = crosshair.getLabelGenerator().generateLabel(
crosshair);
RectangleAnchor anchor = crosshair.getLabelAnchor();
Point2D pt = calculateLabelPoint(line, anchor, 5, 5);
float xx = (float) pt.getX();
float yy = (float) pt.getY();
TextAnchor alignPt = textAlignPtForLabelAnchorH(anchor);
Shape hotspot = TextUtilities.calculateRotatedStringBounds(
label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER);
if (!dataArea.contains(hotspot.getBounds2D())) {
anchor = flipAnchorV(anchor);
pt = calculateLabelPoint(line, anchor, 5, 5);
xx = (float) pt.getX();
yy = (float) pt.getY();
alignPt = textAlignPtForLabelAnchorH(anchor);
hotspot = TextUtilities.calculateRotatedStringBounds(
label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER);
}
g2.setPaint(crosshair.getLabelBackgroundPaint());
g2.fill(hotspot);
g2.setPaint(crosshair.getLabelOutlinePaint());
g2.draw(hotspot);
TextUtilities.drawAlignedString(label, g2, xx, yy, alignPt);
}
g2.setPaint(savedPaint);
g2.setStroke(savedStroke);
}
}
示例2: drawVerticalCrosshair
import org.jfree.chart.plot.Crosshair; //导入方法依赖的package包/类
/**
* Draws a crosshair vertically on the plot.
*
* @param g2 the graphics target.
* @param dataArea the data area.
* @param x the x-value in Java2D space.
* @param crosshair the crosshair.
*/
protected void drawVerticalCrosshair(Graphics2D g2, Rectangle2D dataArea,
double x, Crosshair crosshair) {
if (x >= dataArea.getMinX() && x <= dataArea.getMaxX()) {
Line2D line = new Line2D.Double(x, dataArea.getMinY(), x,
dataArea.getMaxY());
Paint savedPaint = g2.getPaint();
Stroke savedStroke = g2.getStroke();
g2.setPaint(crosshair.getPaint());
g2.setStroke(crosshair.getStroke());
g2.draw(line);
if (crosshair.isLabelVisible()) {
String label = crosshair.getLabelGenerator().generateLabel(
crosshair);
RectangleAnchor anchor = crosshair.getLabelAnchor();
Point2D pt = calculateLabelPoint(line, anchor, 5, 5);
float xx = (float) pt.getX();
float yy = (float) pt.getY();
TextAnchor alignPt = textAlignPtForLabelAnchorV(anchor);
Shape hotspot = TextUtilities.calculateRotatedStringBounds(
label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER);
if (!dataArea.contains(hotspot.getBounds2D())) {
anchor = flipAnchorH(anchor);
pt = calculateLabelPoint(line, anchor, 5, 5);
xx = (float) pt.getX();
yy = (float) pt.getY();
alignPt = textAlignPtForLabelAnchorV(anchor);
hotspot = TextUtilities.calculateRotatedStringBounds(
label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER);
}
g2.setPaint(crosshair.getLabelBackgroundPaint());
g2.fill(hotspot);
g2.setPaint(crosshair.getLabelOutlinePaint());
g2.draw(hotspot);
TextUtilities.drawAlignedString(label, g2, xx, yy, alignPt);
}
g2.setPaint(savedPaint);
g2.setStroke(savedStroke);
}
}
示例3: drawHorizontalCrosshair
import org.jfree.chart.plot.Crosshair; //导入方法依赖的package包/类
/**
* Draws a crosshair horizontally across the plot.
*
* @param g2 the graphics target.
* @param dataArea the data area.
* @param y the y-value in Java2D space.
* @param crosshair the crosshair.
*/
protected void drawHorizontalCrosshair(Graphics2D g2, Rectangle2D dataArea,
double y, Crosshair crosshair) {
if (y >= dataArea.getMinY() && y <= dataArea.getMaxY()) {
Line2D line = new Line2D.Double(dataArea.getMinX(), y,
dataArea.getMaxX(), y);
Paint savedPaint = g2.getPaint();
Stroke savedStroke = g2.getStroke();
g2.setPaint(crosshair.getPaint());
g2.setStroke(crosshair.getStroke());
g2.draw(line);
if (crosshair.isLabelVisible()) {
Font savedFont = g2.getFont();
g2.setFont(crosshair.getLabelFont());
String label = crosshair.getLabelGenerator().generateLabel(
crosshair);
RectangleAnchor anchor = crosshair.getLabelAnchor();
Point2D pt = calculateLabelPoint(line, anchor, 5, 5);
float xx = (float) pt.getX();
float yy = (float) pt.getY();
TextAnchor alignPt = textAlignPtForLabelAnchorH(anchor);
Shape hotspot = TextUtils.calculateRotatedStringBounds(
label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER);
if (!dataArea.contains(hotspot.getBounds2D())) {
anchor = flipAnchorV(anchor);
pt = calculateLabelPoint(line, anchor, 5, 5);
xx = (float) pt.getX();
yy = (float) pt.getY();
alignPt = textAlignPtForLabelAnchorH(anchor);
hotspot = TextUtils.calculateRotatedStringBounds(
label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER);
}
g2.setPaint(crosshair.getLabelBackgroundPaint());
g2.fill(hotspot);
if (crosshair.isLabelOutlineVisible()) {
g2.setPaint(crosshair.getLabelOutlinePaint());
g2.setStroke(crosshair.getLabelOutlineStroke());
}
g2.draw(hotspot);
g2.setPaint(crosshair.getLabelPaint());
TextUtils.drawAlignedString(label, g2, xx, yy, alignPt);
g2.setFont(savedFont);
}
g2.setPaint(savedPaint);
g2.setStroke(savedStroke);
}
}
示例4: drawVerticalCrosshair
import org.jfree.chart.plot.Crosshair; //导入方法依赖的package包/类
/**
* Draws a crosshair vertically on the plot.
*
* @param g2 the graphics target.
* @param dataArea the data area.
* @param x the x-value in Java2D space.
* @param crosshair the crosshair.
*/
protected void drawVerticalCrosshair(Graphics2D g2, Rectangle2D dataArea,
double x, Crosshair crosshair) {
if (x >= dataArea.getMinX() && x <= dataArea.getMaxX()) {
Line2D line = new Line2D.Double(x, dataArea.getMinY(), x,
dataArea.getMaxY());
Paint savedPaint = g2.getPaint();
Stroke savedStroke = g2.getStroke();
g2.setPaint(crosshair.getPaint());
g2.setStroke(crosshair.getStroke());
g2.draw(line);
if (crosshair.isLabelVisible()) {
Font savedFont = g2.getFont();
g2.setFont(crosshair.getLabelFont());
String label = crosshair.getLabelGenerator().generateLabel(
crosshair);
RectangleAnchor anchor = crosshair.getLabelAnchor();
Point2D pt = calculateLabelPoint(line, anchor, 5, 5);
float xx = (float) pt.getX();
float yy = (float) pt.getY();
TextAnchor alignPt = textAlignPtForLabelAnchorV(anchor);
Shape hotspot = TextUtils.calculateRotatedStringBounds(
label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER);
if (!dataArea.contains(hotspot.getBounds2D())) {
anchor = flipAnchorH(anchor);
pt = calculateLabelPoint(line, anchor, 5, 5);
xx = (float) pt.getX();
yy = (float) pt.getY();
alignPt = textAlignPtForLabelAnchorV(anchor);
hotspot = TextUtils.calculateRotatedStringBounds(
label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER);
}
g2.setPaint(crosshair.getLabelBackgroundPaint());
g2.fill(hotspot);
if (crosshair.isLabelOutlineVisible()) {
g2.setPaint(crosshair.getLabelOutlinePaint());
g2.setStroke(crosshair.getLabelOutlineStroke());
g2.draw(hotspot);
}
g2.setPaint(crosshair.getLabelPaint());
TextUtils.drawAlignedString(label, g2, xx, yy, alignPt);
g2.setFont(savedFont);
}
g2.setPaint(savedPaint);
g2.setStroke(savedStroke);
}
}