本文整理匯總了Java中org.jfree.ui.RectangleAnchor.createRectangle方法的典型用法代碼示例。如果您正苦於以下問題:Java RectangleAnchor.createRectangle方法的具體用法?Java RectangleAnchor.createRectangle怎麽用?Java RectangleAnchor.createRectangle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jfree.ui.RectangleAnchor
的用法示例。
在下文中一共展示了RectangleAnchor.createRectangle方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: draw
import org.jfree.ui.RectangleAnchor; //導入方法依賴的package包/類
/**
* Draws the text box.
*
* @param g2 the graphics device.
* @param x the x-coordinate.
* @param y the y-coordinate.
* @param anchor the anchor point.
*/
public void draw(final Graphics2D g2,
final float x, final float y,
final RectangleAnchor anchor) {
final Size2D d1 = this.textBlock.calculateDimensions(g2);
final double w = this.interiorGap.extendWidth(d1.getWidth());
final double h = this.interiorGap.extendHeight(d1.getHeight());
final Size2D d2 = new Size2D(w, h);
final Rectangle2D bounds
= RectangleAnchor.createRectangle(d2, x, y, anchor);
double xx = bounds.getX();
double yy = bounds.getY();
if (this.shadowPaint != null) {
final Rectangle2D shadow = new Rectangle2D.Double(
xx + this.shadowXOffset, yy + this.shadowYOffset,
bounds.getWidth(), bounds.getHeight());
g2.setPaint(this.shadowPaint);
g2.fill(shadow);
}
if (this.backgroundPaint != null) {
g2.setPaint(this.backgroundPaint);
g2.fill(bounds);
}
if (this.outlinePaint != null && this.outlineStroke != null) {
g2.setPaint(this.outlinePaint);
g2.setStroke(this.outlineStroke);
g2.draw(bounds);
}
this.textBlock.draw(g2,
(float) (xx + this.interiorGap.calculateLeftInset(w)),
(float) (yy + this.interiorGap.calculateTopInset(h)),
TextBlockAnchor.TOP_LEFT);
}
示例2: draw
import org.jfree.ui.RectangleAnchor; //導入方法依賴的package包/類
/**
* Draws the background to the specified graphics device. If the dial
* frame specifies a window, the clipping region will already have been
* set to this window before this method is called.
*
* @param g2 the graphics device (<code>null</code> not permitted).
* @param plot the plot (ignored here).
* @param frame the dial frame (ignored here).
* @param view the view rectangle (<code>null</code> not permitted).
*/
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
Rectangle2D view) {
// work out the anchor point
Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius,
this.radius);
Arc2D arc = new Arc2D.Double(f, this.angle, 0.0, Arc2D.OPEN);
Point2D pt = arc.getStartPoint();
// calculate the bounds of the template value
FontMetrics fm = g2.getFontMetrics(this.font);
String s = this.formatter.format(this.templateValue);
Rectangle2D tb = TextUtilities.getTextBounds(s, g2, fm);
// align this rectangle to the frameAnchor
Rectangle2D bounds = RectangleAnchor.createRectangle(new Size2D(
tb.getWidth(), tb.getHeight()), pt.getX(), pt.getY(),
this.frameAnchor);
// add the insets
Rectangle2D fb = this.insets.createOutsetRectangle(bounds);
// draw the background
g2.setPaint(this.backgroundPaint);
g2.fill(fb);
// draw the border
g2.setStroke(this.outlineStroke);
g2.setPaint(this.outlinePaint);
g2.draw(fb);
// now find the text anchor point
double value = plot.getValue(this.datasetIndex);
String valueStr = this.formatter.format(value);
Point2D pt2 = RectangleAnchor.coordinates(bounds, this.valueAnchor);
g2.setPaint(this.paint);
g2.setFont(this.font);
TextUtilities.drawAlignedString(valueStr, g2, (float) pt2.getX(),
(float) pt2.getY(), this.textAnchor);
}
示例3: draw
import org.jfree.ui.RectangleAnchor; //導入方法依賴的package包/類
/**
* Draws the background to the specified graphics device. If the dial
* frame specifies a window, the clipping region will already have been
* set to this window before this method is called.
*
* @param g2 the graphics device (<code>null</code> not permitted).
* @param plot the plot (ignored here).
* @param frame the dial frame (ignored here).
* @param view the view rectangle (<code>null</code> not permitted).
*/
@Override
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
Rectangle2D view) {
// work out the anchor point
Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius,
this.radius);
Arc2D arc = new Arc2D.Double(f, this.angle, 0.0, Arc2D.OPEN);
Point2D pt = arc.getStartPoint();
// the indicator bounds is calculated from the templateValue (which
// determines the minimum size), the maxTemplateValue (which, if
// specified, provides a maximum size) and the actual value
FontMetrics fm = g2.getFontMetrics(this.font);
double value = plot.getValue(this.datasetIndex);
String valueStr = this.formatter.format(value);
Rectangle2D valueBounds = TextUtilities.getTextBounds(valueStr, g2, fm);
// calculate the bounds of the template value
String s = this.formatter.format(this.templateValue);
Rectangle2D tb = TextUtilities.getTextBounds(s, g2, fm);
double minW = tb.getWidth();
double minH = tb.getHeight();
double maxW = Double.MAX_VALUE;
double maxH = Double.MAX_VALUE;
if (this.maxTemplateValue != null) {
s = this.formatter.format(this.maxTemplateValue);
tb = TextUtilities.getTextBounds(s, g2, fm);
maxW = Math.max(tb.getWidth(), minW);
maxH = Math.max(tb.getHeight(), minH);
}
double w = fixToRange(valueBounds.getWidth(), minW, maxW);
double h = fixToRange(valueBounds.getHeight(), minH, maxH);
// align this rectangle to the frameAnchor
Rectangle2D bounds = RectangleAnchor.createRectangle(new Size2D(w, h),
pt.getX(), pt.getY(), this.frameAnchor);
// add the insets
Rectangle2D fb = this.insets.createOutsetRectangle(bounds);
// draw the background
g2.setPaint(this.backgroundPaint);
g2.fill(fb);
// draw the border
g2.setStroke(this.outlineStroke);
g2.setPaint(this.outlinePaint);
g2.draw(fb);
// now find the text anchor point
Shape savedClip = g2.getClip();
g2.clip(fb);
Point2D pt2 = RectangleAnchor.coordinates(bounds, this.valueAnchor);
g2.setPaint(this.paint);
g2.setFont(this.font);
TextUtilities.drawAlignedString(valueStr, g2, (float) pt2.getX(),
(float) pt2.getY(), this.textAnchor);
g2.setClip(savedClip);
}
示例4: draw
import org.jfree.ui.RectangleAnchor; //導入方法依賴的package包/類
/**
* Draws the background to the specified graphics device. If the dial
* frame specifies a window, the clipping region will already have been
* set to this window before this method is called.
*
* @param g2 the graphics device (<code>null</code> not permitted).
* @param plot the plot (ignored here).
* @param frame the dial frame (ignored here).
* @param view the view rectangle (<code>null</code> not permitted).
*/
@Override
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
Rectangle2D view) {
// work out the anchor point
Rectangle2D f = DialPlot.rectangleByRadius(frame, getRadius(),
this.getRadius());
Arc2D arc = new Arc2D.Double(f, this.getAngle(), 0.0, Arc2D.OPEN);
Point2D pt = arc.getStartPoint();
// calculate the bounds of the template value
FontMetrics fm = g2.getFontMetrics(this.getFont());
String s = this.getNumberFormat().format(this.getTemplateValue());
Rectangle2D tb = TextUtilities.getTextBounds(s, g2, fm);
// align this rectangle to the frameAnchor
Rectangle2D bounds = RectangleAnchor.createRectangle(new Size2D(
tb.getWidth(), tb.getHeight()), pt.getX(), pt.getY(),
this.getFrameAnchor());
// add the insets
Rectangle2D fb = this.getInsets().createOutsetRectangle(bounds);
// draw the background
g2.setPaint(this.getBackgroundPaint());
g2.fill(fb);
// draw the border
g2.setStroke(this.getOutlineStroke());
g2.setPaint(this.getOutlinePaint());
g2.draw(fb);
// now find the text anchor point
String valueStr = this.getNumberFormat().format(ChartThemesUtilities.getScaledValue(plot.getValue(this.getDatasetIndex()), scale));
Point2D pt2 = RectangleAnchor.coordinates(bounds, this.getValueAnchor());
g2.setPaint(this.getPaint());
g2.setFont(this.getFont());
TextUtilities.drawAlignedString(valueStr, g2, (float) pt2.getX(),
(float) pt2.getY(), this.getTextAnchor());
}