当前位置: 首页>>代码示例>>Java>>正文


Java RectangleAnchor.createRectangle方法代码示例

本文整理汇总了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);

}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:45,代码来源:TextBox.java

示例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);
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:53,代码来源:DialValueIndicator.java

示例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);

}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:74,代码来源:DialValueIndicator.java

示例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());

}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:53,代码来源:ScaledDialValueIndicator.java


注:本文中的org.jfree.ui.RectangleAnchor.createRectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。