下面列出了java.awt.Graphics2D#getPaint ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected void paintTabBackground(Graphics g, int index, int x, int y,
int width, int height) {
Graphics2D g2d = (Graphics2D) g;
Paint p = g2d.getPaint();
if( isSelected(index) ) {
g2d.setPaint( ColorUtil.getGradientPaint(x, y, UIManager.getColor("NbTabControl.selectedTabBrighterBackground"),
x, y+height/2, UIManager.getColor("NbTabControl.selectedTabDarkerBackground")) );
} else if( isMouseOver(index) ) {
g2d.setPaint( ColorUtil.getGradientPaint(x, y, UIManager.getColor("NbTabControl.mouseoverTabBrighterBackground"),
x, y+height/2, UIManager.getColor("NbTabControl.mouseoverTabDarkerBackground")) );
} else {
g2d.setPaint( ColorUtil.getGradientPaint(x, y, UIManager.getColor("NbTabControl.inactiveTabBrighterBackground"),
x, y+height/2, UIManager.getColor("NbTabControl.inactiveTabDarkerBackground")) );
}
g2d.fillRect(x, y, width, height);
g2d.setPaint(p);
}
@Override
public void DoPaint(Graphics2D g) {
getTextoFormatado().CorretorPosicao = new Point(-1, -1);
g.setPaint(this.getForeColor());
super.DoPaint(g);
g.drawRect(getLeft(), getTop(), getWidth() -1, getHeight() -1);
Paint bkp = g.getPaint();
g.setPaint(isDisablePainted()? disabledColor : Color.darkGray);
int L = getLeft();
int T = getTop();
int W = getWidth() + L;
int H = getHeight() + T;
g.drawLine(L + 1, H, W, H);
g.drawLine(W, T + 1, W, H);
g.setPaint(isDisablePainted()? disabledColor : Color.gray);
g.drawLine(L + 2, H + 1, W + 1, H + 1);
g.drawLine(W + 1, T + 2, W +1, H + 1);
// g.drawLine(L + 1, H -1, W -1, H -1);
// g.drawLine(W -1, T + 1, W -1, H -1);
// g.setPaint(Color.gray);
// g.drawLine(L + 2, H, W, H);
// g.drawLine(W, T + 2, W, H);
g.setPaint(bkp);
//g.drawString(getLocation().toString(), getLeft() + 5, getTop() + 20);
}
/**
* Draws the clip path.
*
* @param g2 current graphics2D.
* @param dataArea the dataArea that the plot is being draw in.
* @param horizontalAxis the horizontal axis.
* @param verticalAxis the vertical axis.
*
* @return The GeneralPath defining the outline
*/
public GeneralPath draw(Graphics2D g2,
Rectangle2D dataArea,
ValueAxis horizontalAxis, ValueAxis verticalAxis) {
GeneralPath generalPath = generateClipPath(
dataArea, horizontalAxis, verticalAxis
);
if (this.fillPath || this.drawPath) {
Composite saveComposite = g2.getComposite();
Paint savePaint = g2.getPaint();
Stroke saveStroke = g2.getStroke();
if (this.fillPaint != null) {
g2.setPaint(this.fillPaint);
}
if (this.composite != null) {
g2.setComposite(this.composite);
}
if (this.fillPath) {
g2.fill(generalPath);
}
if (this.drawStroke != null) {
g2.setStroke(this.drawStroke);
}
if (this.drawPath) {
g2.draw(generalPath);
}
g2.setPaint(savePaint);
g2.setComposite(saveComposite);
g2.setStroke(saveStroke);
}
return generalPath;
}
/**
* Paint a semi-transparent area around the supplied panel.
* @param panel the panel to paint around
* @param screenWidth the target screen width
* @param screenHeight the target screen height
* @param g2 the target graphics object
* @param alpha the transparency level
* @param considerStatusbars consider, that the status bars take 20px top and 18 pixels bottom?
*/
public static void darkenAround(
Rectangle panel, int screenWidth, int screenHeight, Graphics2D g2, float alpha,
boolean considerStatusbars) {
Composite c = null;
Paint p = null;
if (fast) {
p = g2.getPaint();
BufferedImage fimg = holes((float)Math.min(1.0, alpha * 2));
g2.setPaint(new TexturePaint(fimg, new Rectangle(panel.x, panel.y, fimg.getWidth(), fimg.getHeight())));
} else {
c = g2.getComposite();
g2.setComposite(AlphaComposite.SrcOver.derive(alpha));
g2.setColor(Color.BLACK);
}
if (considerStatusbars) {
fillRectAbsolute(0, STATUS_BAR_TOP, screenWidth - 1, panel.y - 1, g2);
fillRectAbsolute(0, panel.y + panel.height, screenWidth - 1, screenHeight - 1 - STATUS_BAR_BOTTOM, g2);
} else {
fillRectAbsolute(0, 0, screenWidth - 1, panel.y - 1, g2);
fillRectAbsolute(0, panel.y + panel.height, screenWidth - 1, screenHeight - 1, g2);
}
fillRectAbsolute(0, panel.y, panel.x - 1, panel.y + panel.height - 1, g2);
fillRectAbsolute(panel.x + panel.width, panel.y, screenWidth - 1, panel.y + panel.height - 1, g2);
if (fast) {
g2.setPaint(p);
} else {
g2.setComposite(c);
}
}
/**
* Overrides TPoint draw method.
*
* @param panel the drawing panel requesting the drawing
* @param _g the graphics context on which to draw
*/
public void draw(DrawingPanel panel, Graphics _g) {
if(!(panel instanceof VideoPanel)||!isVisible()) {
return;
}
VideoPanel vidPanel = (VideoPanel) panel;
fillShape = getShape(vidPanel);
Graphics2D g = (Graphics2D) _g;
Paint gpaint = g.getPaint();
g.setPaint(color);
g.fill(fillShape);
g.setPaint(gpaint);
}
public void paint(Graphics g, JComponent c) {
Graphics2D g2d = (Graphics2D)g;
if (useGradient) {
Paint old = g2d.getPaint();
GradientPaint gradient = new GradientPaint(0, 0, gradientStart, 0, c
.getHeight(), gradientEnd);
g2d.setPaint(gradient);
g.fillRect(0, 0, c.getWidth(), c.getHeight());
g2d.setPaint(old);
}
}
private void drawLabel(Rendering rendering, String label) {
final Graphics2D graphics = rendering.getGraphics();
final Font oldFont = graphics.getFont();
final Stroke oldStroke = graphics.getStroke();
final Paint oldPaint = graphics.getPaint();
try {
graphics.setFont(labelFont);
GlyphVector glyphVector = labelFont.createGlyphVector(graphics.getFontRenderContext(), label);
Rectangle2D logicalBounds = glyphVector.getLogicalBounds();
float tx = (float) (logicalBounds.getX() - 0.5 * logicalBounds.getWidth());
float ty = (float) (getSymbol().getBounds().getMaxY() + logicalBounds.getHeight() + 1.0);
Shape labelOutline = glyphVector.getOutline(tx, ty);
for (int i = 0; i < labelOutlineAlphas.length; i++) {
graphics.setStroke(labelOutlineStrokes[i]);
graphics.setPaint(labelOutlineColors[i]);
graphics.draw(labelOutline);
}
graphics.setPaint(labelFontColor);
graphics.fill(labelOutline);
} finally {
graphics.setPaint(oldPaint);
graphics.setStroke(oldStroke);
graphics.setFont(oldFont);
}
}
/**
* Paint title pane.
*
* @param g the g
* @param x the x
* @param y the y
* @param width the width
* @param height the height
* @param actived the actived
*/
public static void paintTitlePane(Graphics g,int x,int y,int width
,int height,boolean actived)
{
Graphics2D g2 = (Graphics2D)g;
//是用图形进行填充的
Paint oldpaint = g2.getPaint();
g2.setPaint(BEUtils.createTexturePaint(
actived?__IconFactory__.getInstance().getFrameTitleHeadBg_active().getImage()
:__IconFactory__.getInstance().getFrameTitleHeadBg_inactive().getImage()));
g2.fillRect(x, y, width, height);
g2.setPaint(oldpaint);
}
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
Rectangle clip = g2.getClipBounds();
Paint paint = g2.getPaint();
g2.setPaint(new GradientPaint(0.0f, getHeight() * 0.22f, new Color(DARK_BLUE),
0.0f, getHeight() * 0.9f, Color.BLACK));
g2.fillRect(clip.x, clip.y, clip.width, clip.height);
g2.setPaint(paint);
}
/**
* Fills the specified {@code area} with a gradient paint created
* using the colors and anchor points of this painter.
*
* @param g2 the graphics target ({@code null} not permitted).
* @param area the area to fill ({@code null} not permitted).
*/
@Override
public void fill(Graphics2D g2, Rectangle2D area) {
Paint saved = g2.getPaint();
g2.setPaint(createTransformedGradient(area));
g2.fill(area);
g2.setPaint(saved);
}
/**
* Draws the clip path.
*
* @param g2 current graphics2D.
* @param dataArea the dataArea that the plot is being draw in.
* @param horizontalAxis the horizontal axis.
* @param verticalAxis the vertical axis.
*
* @return The GeneralPath defining the outline
*/
public GeneralPath draw(Graphics2D g2,
Rectangle2D dataArea,
ValueAxis horizontalAxis, ValueAxis verticalAxis) {
GeneralPath generalPath = generateClipPath(
dataArea, horizontalAxis, verticalAxis
);
if (this.fillPath || this.drawPath) {
Composite saveComposite = g2.getComposite();
Paint savePaint = g2.getPaint();
Stroke saveStroke = g2.getStroke();
if (this.fillPaint != null) {
g2.setPaint(this.fillPaint);
}
if (this.composite != null) {
g2.setComposite(this.composite);
}
if (this.fillPath) {
g2.fill(generalPath);
}
if (this.drawStroke != null) {
g2.setStroke(this.drawStroke);
}
if (this.drawPath) {
g2.draw(generalPath);
}
g2.setPaint(savePaint);
g2.setComposite(saveComposite);
g2.setStroke(saveStroke);
}
return generalPath;
}
/**
* Draws the clip path.
*
* @param g2 current graphics2D.
* @param dataArea the dataArea that the plot is being draw in.
* @param horizontalAxis the horizontal axis.
* @param verticalAxis the vertical axis.
*
* @return The GeneralPath defining the outline
*/
public GeneralPath draw(Graphics2D g2,
Rectangle2D dataArea,
ValueAxis horizontalAxis, ValueAxis verticalAxis) {
GeneralPath generalPath = generateClipPath(
dataArea, horizontalAxis, verticalAxis
);
if (this.fillPath || this.drawPath) {
Composite saveComposite = g2.getComposite();
Paint savePaint = g2.getPaint();
Stroke saveStroke = g2.getStroke();
if (this.fillPaint != null) {
g2.setPaint(this.fillPaint);
}
if (this.composite != null) {
g2.setComposite(this.composite);
}
if (this.fillPath) {
g2.fill(generalPath);
}
if (this.drawStroke != null) {
g2.setStroke(this.drawStroke);
}
if (this.drawPath) {
g2.draw(generalPath);
}
g2.setPaint(savePaint);
g2.setComposite(saveComposite);
g2.setStroke(saveStroke);
}
return generalPath;
}
/**
* Draws the clip path.
*
* @param g2 current graphics2D.
* @param dataArea the dataArea that the plot is being draw in.
* @param horizontalAxis the horizontal axis.
* @param verticalAxis the vertical axis.
*
* @return The GeneralPath defining the outline
*/
public GeneralPath draw(Graphics2D g2,
Rectangle2D dataArea,
ValueAxis horizontalAxis, ValueAxis verticalAxis) {
GeneralPath generalPath = generateClipPath(
dataArea, horizontalAxis, verticalAxis
);
if (this.fillPath || this.drawPath) {
Composite saveComposite = g2.getComposite();
Paint savePaint = g2.getPaint();
Stroke saveStroke = g2.getStroke();
if (this.fillPaint != null) {
g2.setPaint(this.fillPaint);
}
if (this.composite != null) {
g2.setComposite(this.composite);
}
if (this.fillPath) {
g2.fill(generalPath);
}
if (this.drawStroke != null) {
g2.setStroke(this.drawStroke);
}
if (this.drawPath) {
g2.draw(generalPath);
}
g2.setPaint(savePaint);
g2.setComposite(saveComposite);
g2.setStroke(saveStroke);
}
return generalPath;
}
public void drawTextAndDecorations(Label label,
Graphics2D g2d,
float x,
float y) {
if (fgPaint == null && bgPaint == null && swapColors == false) {
drawTextAndEmbellishments(label, g2d, x, y);
}
else {
Paint savedPaint = g2d.getPaint();
Paint foreground, background;
if (swapColors) {
background = fgPaint==null? savedPaint : fgPaint;
if (bgPaint == null) {
if (background instanceof Color) {
Color bg = (Color)background;
// 30/59/11 is standard weights, tweaked a bit
int brightness = 33 * bg.getRed()
+ 53 * bg.getGreen()
+ 14 * bg.getBlue();
foreground = brightness > 18500 ? Color.BLACK : Color.WHITE;
} else {
foreground = Color.WHITE;
}
} else {
foreground = bgPaint;
}
}
else {
foreground = fgPaint==null? savedPaint : fgPaint;
background = bgPaint;
}
if (background != null) {
Rectangle2D bgArea = label.getLogicalBounds();
bgArea = new Rectangle2D.Float(x + (float)bgArea.getX(),
y + (float)bgArea.getY(),
(float)bgArea.getWidth(),
(float)bgArea.getHeight());
g2d.setPaint(background);
g2d.fill(bgArea);
}
g2d.setPaint(foreground);
drawTextAndEmbellishments(label, g2d, x, y);
g2d.setPaint(savedPaint);
}
}
/**
* 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);
}
}
/**
* 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);
}
}
public void paintComponent(Graphics _g) {
Graphics2D g = (Graphics2D)_g;
Dimension size = getSize();
if(lastSize == null || lastSize.width != size.width || lastSize.height != size.height) {
bNeedLayout = true;
}
lastSize = size;
if(bNeedLayout) {
currentLinkMap.clear();
layoutNode(currentNode, currentLinkMap);
bNeedLayout = false;
}
Point2D center = getCenter();
if(isOpaque()) {
g.setColor(getBackground());
g.fillRect(0, 0, size.width, size.height);
float y0 = (float)(0.8 * center.getY());
float y1 = (float)(size.height);
GradientPaint painter = new GradientPaint(0.0f, y0,
topColor,
0.0f, y1,
bottomColor);
Paint oldP = g.getPaint();
g.setPaint(painter);
g.fill(new Rectangle2D.Double(0, y0, size.width, y1-y0));
g.setPaint(oldP);
}
if(bPaintRootName) {
if(currentNode != null) {
paintMirror(g, new Color(20, 20, 100), currentNode.toString(), 10, 20, 1.5, false);
}
}
paintLinkMap(g, currentLinkMap);
if(currentNode != null && currentLinkMap != null && currentLinkMap.size() == 0) {
currentNode.setPoint(center);
paintNode(g, currentNode);
}
if(label != null) {
paintMirror(g, new Color(20, 20, 100), label, 10, size.height - 20, 1.5, true);
}
if(hoverNode != null) {
setToolTipText(hoverNode.toString());
} else if(mouseObject != null) {
setToolTipText(mouseObject.toString());
} else {
setToolTipText(null);
}
}
/**
* 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);
}
}
/**
* 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);
}
}
/**
* 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);
}
}