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


Java Rectangle2D.setRect方法代码示例

本文整理汇总了Java中java.awt.geom.Rectangle2D.setRect方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle2D.setRect方法的具体用法?Java Rectangle2D.setRect怎么用?Java Rectangle2D.setRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.geom.Rectangle2D的用法示例。


在下文中一共展示了Rectangle2D.setRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawCenteredText

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private Rectangle2D drawCenteredText(String s, Color c, double centerX, double centerY, Graphics2D g2d, boolean draw) {
	Rectangle2D txtBounds;
	double x, y;
	double gap = dCst.getElementsGap();
	g2d.setFont(dCst.getFont());
	txtBounds = dCst.getFont().getStringBounds(s, g2d.getFontRenderContext());
	x = centerX - txtBounds.getWidth() / 2.0;
	y = centerY - txtBounds.getY() - txtBounds.getHeight() / 2;
	txtBounds.setRect(x - gap, y - txtBounds.getHeight() / 2.0 - gap, txtBounds.getWidth() + 2 * gap, txtBounds.getHeight() + 2 * gap);
	Color ctmp = g2d.getColor();
	g2d.setColor(c);
	if (draw) {
		g2d.drawString(s, (float) x, (float) y);
	}
	g2d.setColor(ctmp);
	return txtBounds;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:18,代码来源:JobsDrawer.java

示例2: getGlyphOutlineBounds

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
Rectangle2D getGlyphOutlineBounds(int glyphID, float x, float y) {
    Rectangle2D result = null;
    if (sgv.invdtx == null) {
        result = new Rectangle2D.Float();
        result.setRect(strike.getGlyphOutlineBounds(glyphID)); // don't mutate cached rect
    } else {
        GeneralPath gp = strike.getGlyphOutline(glyphID, 0, 0);
        gp.transform(sgv.invdtx);
        result = gp.getBounds2D();
    }
    /* Since x is the logical advance of the glyph to this point.
     * Because of the way that Rectangle.union is specified, this
     * means that subsequent unioning of a rect including that
     * will be affected, even if the glyph is empty. So skip such
     * cases. This alone isn't a complete solution since x==0
     * may also not be what is wanted. The code that does the
     * unioning also needs to be aware to ignore empty glyphs.
     */
    if (!result.isEmpty()) {
        result.setRect(result.getMinX() + x + dx,
                       result.getMinY() + y + dy,
                       result.getWidth(), result.getHeight());
    }
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:StandardGlyphVector.java

示例3: drawNeedle

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Draws the needle.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param rotate  the rotation point.
 * @param angle  the angle.
 */
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, 
                          Point2D rotate, double angle) {

    super.drawNeedle(g2, plotArea, rotate, angle);
    if ((rotate != null) && (plotArea != null)) {

        int spacing = getSize() * 3;
        Rectangle2D newArea = new Rectangle2D.Double();

        Point2D newRotate = rotate;
        newArea.setRect(plotArea.getMinX() - spacing, plotArea.getMinY(),
                plotArea.getWidth(), plotArea.getHeight());
        super.drawNeedle(g2, newArea, newRotate, angle);

        newArea.setRect(plotArea.getMinX() + spacing, 
                plotArea.getMinY(), plotArea.getWidth(), 
                plotArea.getHeight());
        super.drawNeedle(g2, newArea, newRotate, angle);

    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:WindNeedle.java

示例4: getBounds

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Returns the bounds of this <code>TextLayout</code>.
 * The bounds are in standard coordinates.
 * <p>Due to rasterization effects, this bounds might not enclose all of the
 * pixels rendered by the TextLayout.</p>
 * It might not coincide exactly with the ascent, descent,
 * origin or advance of the <code>TextLayout</code>.
 * @return a {@link Rectangle2D} that is the bounds of this
 *        <code>TextLayout</code>.
 */
public Rectangle2D getBounds() {
    ensureCache();

    if (boundsRect == null) {
        Rectangle2D vb = textLine.getVisualBounds();
        if (dx != 0 || dy != 0) {
            vb.setRect(vb.getX() - dx,
                       vb.getY() - dy,
                       vb.getWidth(),
                       vb.getHeight());
        }
        boundsRect = vb;
    }

    Rectangle2D bounds = new Rectangle2D.Float();
    bounds.setRect(boundsRect);

    return bounds;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:TextLayout.java

示例5: getGlyphMetrics

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:StandardGlyphVector.java

示例6: getGlyphMetrics

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
@Override
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length()) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
    		strike.getGlyphMetrics( glyphs.charAt( ix ) );
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                      (byte)0);
    return gm;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:StandardGlyphVector.java

示例7: modelToView

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public Shape modelToView(GlyphView v, int pos, Position.Bias bias,
                         Shape a) throws BadLocationException {
    int offs = pos - v.getStartOffset();
    Rectangle2D alloc = a.getBounds2D();
    TextHitInfo hit = (bias == Position.Bias.Forward) ?
        TextHitInfo.afterOffset(offs) : TextHitInfo.beforeOffset(offs);
    float[] locs = layout.getCaretInfo(hit);

    // vertical at the baseline, should use slope and check if glyphs
    // are being rendered vertically.
    alloc.setRect(alloc.getX() + locs[0], alloc.getY(), 1, alloc.getHeight());
    return alloc;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:GlyphPainter2.java

示例8: shrink

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Shrinks an area by the space attributes.
 * 
 * @param area  the area to shrink.
 * @param result  an optional carrier for the result.
 * 
 * @return The result.
 */
public Rectangle2D shrink(Rectangle2D area, Rectangle2D result) {
    if (result == null) {
        result = new Rectangle2D.Double();
    }
    result.setRect(
        area.getX() + this.left, 
        area.getY() + this.top,
        area.getWidth() - this.left - this.right,
        area.getHeight() - this.top - this.bottom
    );
    return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:AxisSpace.java

示例9: getVisualBounds

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Return the union of the visual bounds of all the components.
 * This incorporates the path.  It does not include logical
 * bounds (used by carets).
 */
public Rectangle2D getVisualBounds() {
    Rectangle2D result = null;

    for (int i = 0, n = 0; i < fComponents.length; i++, n += 2) {
        TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];
        Rectangle2D r = tlc.getVisualBounds();

        Point2D.Float pt = new Point2D.Float(locs[n], locs[n+1]);
        if (lp == null) {
            r.setRect(r.getMinX() + pt.x, r.getMinY() + pt.y,
                      r.getWidth(), r.getHeight());
        } else {
            lp.pathToPoint(pt, false, pt);

            AffineTransform at = tlc.getBaselineTransform();
            if (at != null) {
                AffineTransform tx = AffineTransform.getTranslateInstance
                    (pt.x - at.getTranslateX(), pt.y - at.getTranslateY());
                tx.concatenate(at);
                r = tx.createTransformedShape(r).getBounds2D();
            } else {
                r.setRect(r.getMinX() + pt.x, r.getMinY() + pt.y,
                          r.getWidth(), r.getHeight());
            }
        }

        if (result == null) {
            result = r;
        } else {
            result.add(r);
        }
    }

    if (result == null) {
        result = new Rectangle2D.Float(Float.MAX_VALUE, Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
    }

    return result;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:45,代码来源:TextLine.java

示例10: draw

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Draws the border by filling in the reserved space.
 * 
 * @param g2  the graphics device.
 * @param area  the area.
 */
public void draw(Graphics2D g2, Rectangle2D area) {
    // this default implementation will just fill the available
    // border space with a single color
    double t = this.insets.calculateTopInset(area.getHeight());
    double b = this.insets.calculateBottomInset(area.getHeight());
    double l = this.insets.calculateLeftInset(area.getWidth());
    double r = this.insets.calculateRightInset(area.getWidth());
    double x = area.getX();
    double y = area.getY();
    double w = area.getWidth();
    double h = area.getHeight();
    g2.setPaint(this.paint);
    Rectangle2D rect = new Rectangle2D.Double();
    if (t > 0.0) {
        rect.setRect(x, y, w, t);
        g2.fill(rect);
    }
    if (b > 0.0) {
        rect.setRect(x, y + h - b, w, b);
        g2.fill(rect);
    }
    if (l > 0.0) {
        rect.setRect(x, y, l, h);
        g2.fill(rect);
    }
    if (r > 0.0) {
        rect.setRect(x + w - r, y, r, h);
        g2.fill(rect);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:37,代码来源:BlockBorder.java

示例11: draw

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Draws the wafermap view.
 * 
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param state  the plot state.
 * @param info  the plot rendering info.
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, PlotState state, PlotRenderingInfo info) {

    // if the plot area is too small, just return...
    boolean b1 = (plotArea.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
    boolean b2 = (plotArea.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
    if (b1 || b2) {
        return;
    }

    // record the plot area...
    if (info != null) {
        info.setPlotArea(plotArea);
    }

    // adjust the drawing area for the plot insets (if any)...
    Insets insets = getInsets();
    if (insets != null) {
        plotArea.setRect(plotArea.getX() + insets.left,
                         plotArea.getY() + insets.top,
                         plotArea.getWidth() - insets.left - insets.right,
                         plotArea.getHeight() - insets.top - insets.bottom);
    }

    drawChipGrid(g2, plotArea);       
    drawWaferEdge(g2, plotArea);
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:36,代码来源:WaferMapPlot.java

示例12: getCharBounds

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public Rectangle2D getCharBounds(int logicalIndex) {

        if (logicalIndex < 0) {
            throw new IllegalArgumentException("Negative logicalIndex.");
        }

        int tlcStart = 0;

        for (int i=0; i < fComponents.length; i++) {

            int tlcLimit = tlcStart + fComponents[i].getNumCharacters();
            if (tlcLimit > logicalIndex) {

                TextLineComponent tlc = fComponents[i];
                int indexInTlc = logicalIndex - tlcStart;
                Rectangle2D chBounds = tlc.getCharVisualBounds(indexInTlc);

                        int vi = getComponentVisualIndex(i);
                chBounds.setRect(chBounds.getX() + locs[vi * 2],
                                 chBounds.getY() + locs[vi * 2 + 1],
                                 chBounds.getWidth(),
                                 chBounds.getHeight());
                return chBounds;
            }
            else {
                tlcStart = tlcLimit;
            }
        }

        throw new IllegalArgumentException("logicalIndex too large.");
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:TextLine.java

示例13: copyUserData

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
@Override
public UserData<Object> copyUserData(Object newParent) {
	Rectangle2D newRect = new Rectangle2D.Double();
	newRect.setRect(this.rect);
	return new Rectangle2DWrapper(newRect);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:7,代码来源:GUIProcessXMLFilter.java

示例14: draw

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a printer).
 *
 * @param g2  the graphics device.
 * @param plotArea  the area within which the plot should be drawn.
 * @param parentState  the state from the parent plot, if there is one.
 * @param info  collects info about the drawing (<code>null</code> permitted).
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, PlotState parentState,
                 PlotRenderingInfo info) {

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Entering draw() method, plot area = " + plotArea.toString());   
    }

    // adjust for insets...
    Insets insets = getInsets();
    if (insets != null) {
        plotArea.setRect(plotArea.getX() + insets.left,
            plotArea.getY() + insets.top,
            plotArea.getWidth() - insets.left - insets.right,
            plotArea.getHeight() - insets.top - insets.bottom
        );
    }

    if (info != null) {
        info.setPlotArea(plotArea);
        info.setDataArea(plotArea);
    }

    drawBackground(g2, plotArea);
    drawOutline(g2, plotArea);

    Shape savedClip = g2.getClip();
    g2.clip(plotArea);

    Composite originalComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha()));

    if (!DatasetUtilities.isEmptyOrNull(this.dataset)) {
        drawPie(g2, plotArea, info);
    }
    else {
        drawNoDataMessage(g2, plotArea);
    }

    g2.setClip(savedClip);
    g2.setComposite(originalComposite);

    drawOutline(g2, plotArea);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:53,代码来源:PiePlot.java

示例15: draw

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Draws the axis on a Java 2D graphics device (such as the screen or a printer).
 *
 * @param g2  the graphics device (<code>null</code> not permitted).
 * @param cursor  the cursor location.
 * @param plotArea  the area within which the axis should be drawn (<code>null</code> not
                    permitted).
 * @param dataArea  the area within which the plot is being drawn (<code>null</code> not 
 *                  permitted).
 * @param edge  the location of the axis (<code>null</code> not permitted).
 * @param plotState  collects information about the plot (<code>null</code> permitted).
 * 
 * @return the axis state (never <code>null</code>).
 */
public AxisState draw(Graphics2D g2, 
                      double cursor,
                      Rectangle2D plotArea, 
                      Rectangle2D dataArea, 
                      RectangleEdge edge,
                      PlotRenderingInfo plotState) {

    // if the axis is not visible, don't draw it...
    if (!isVisible()) {
        return new AxisState(cursor);
    }

    // calculate the adjusted data area taking into account the 3D effect...
    // this assumes that there is a 3D renderer, all this 3D effect is a bit of an
    // ugly hack...
    CategoryPlot plot = (CategoryPlot) getPlot();

    Rectangle2D adjustedDataArea = new Rectangle2D.Double();
    if (plot.getRenderer() instanceof Effect3D) {
        Effect3D e3D = (Effect3D) plot.getRenderer();
        double adjustedX = dataArea.getMinX();
        double adjustedY = dataArea.getMinY();
        double adjustedW = dataArea.getWidth() - e3D.getXOffset();
        double adjustedH = dataArea.getHeight() - e3D.getYOffset();

        if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) {
            adjustedY += e3D.getYOffset();
        }
        else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) {
            adjustedX += e3D.getXOffset();
        }
        adjustedDataArea.setRect(adjustedX, adjustedY, adjustedW, adjustedH);
    }
    else {
        adjustedDataArea.setRect(dataArea);   
    }

    // draw the category labels and axis label
    AxisState state = new AxisState(cursor);
    state = drawCategoryLabels(g2, plotArea, adjustedDataArea, edge, state, plotState);
    state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state);

    return state;
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:60,代码来源:CategoryAxis3D.java


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