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


Java Shape.getBounds2D方法代码示例

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


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

示例1: modelToView

import java.awt.Shape; //导入方法依赖的package包/类
static Rectangle2D modelToView(JTextComponent tc, int pos, Position.Bias bias) throws BadLocationException {
Document doc = tc.getDocument();
if (doc instanceof AbstractDocument) {
    ((AbstractDocument)doc).readLock();
}
try {
    Rectangle alloc = getVisibleEditorRect(tc);
    if (alloc != null) {
               View rootView = tc.getUI().getRootView(tc);
	rootView.setSize(alloc.width, alloc.height);
	Shape s = rootView.modelToView(pos, alloc, bias);
	if (s != null) {
	  return s.getBounds2D();
	}
    }
} finally {
    if (doc instanceof AbstractDocument) {
	((AbstractDocument)doc).readUnlock();
    }
}
return null;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:Utilities.java

示例2: getLabelEnclosure

import java.awt.Shape; //导入方法依赖的package包/类
/**
 * Returns a rectangle that encloses the axis label.  This is typically 
 * used for layout purposes (it gives the maximum dimensions of the label).
 *
 * @param g2  the graphics device.
 * @param edge  the edge of the plot area along which the axis is measuring.
 *
 * @return The enclosing rectangle.
 */
protected Rectangle2D getLabelEnclosure(Graphics2D g2, RectangleEdge edge) {

    Rectangle2D result = new Rectangle2D.Double();
    String axisLabel = getLabel();
    if (axisLabel != null && !axisLabel.equals("")) {
        FontMetrics fm = g2.getFontMetrics(getLabelFont());
        Rectangle2D bounds = TextUtilities.getTextBounds(axisLabel, g2, fm);
        RectangleInsets insets = getLabelInsets();
        bounds = insets.createOutsetRectangle(bounds);
        double angle = getLabelAngle();
        if (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT) {
            angle = angle - Math.PI / 2.0;
        }
        double x = bounds.getCenterX();
        double y = bounds.getCenterY();
        AffineTransform transformer 
            = AffineTransform.getRotateInstance(angle, x, y);
        Shape labelBounds = transformer.createTransformedShape(bounds);
        result = labelBounds.getBounds2D();
    }

    return result;

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

示例3: paintPage

import java.awt.Shape; //导入方法依赖的package包/类
private void paintPage(Graphics grphcs) {
    Rectangle2D tmp = null;
    Graphics2D gx = (Graphics2D) grphcs;
    gx.setStroke(BS18);
    gx.setColor(Color.RED.darker());
    for (Shape s : lastmatch) {
        if ((int) indexVal.getValue() == lastmatch.indexOf(s)) {
            tmp = s.getBounds2D();
        }
        gx.draw(s);
    }
    gx.setColor(Color.GREEN);
    shapes.forEach(gx::draw);
    if (tmp != null) {
        gx.setStroke(BS24);
        gx.setColor(Color.RED.brighter());
        gx.draw(tmp);
        paintOffset(tmp, gx);
    }
    gx.dispose();
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:22,代码来源:PropertyEditor.java

示例4: setOffsetMarker

import java.awt.Shape; //导入方法依赖的package包/类
private void setOffsetMarker(MouseEvent e) {
    Rectangle2D tmp = null;
    for (Shape s : lastmatch) {
        if ((int) indexVal.getValue() == lastmatch.indexOf(s)) {
            tmp = s.getBounds2D();
            break;
        }
    }
    if (tmp != null) {
        Rectangle2D r2d = tmp;
        int x = (int) (e.getX() - r2d.getCenterX());
        int y = (int) (e.getY() - r2d.getCenterY());
        tempObject.setOffset(x + "," + y);
        offestVal.setText(getOffsetText(tempObject.getOffset()));
        referenceLabel.repaint();
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:18,代码来源:PropertyEditor.java

示例5: transformLinearGradient

import java.awt.Shape; //导入方法依赖的package包/类
public static Paint transformLinearGradient(LinearGradientPaint paint, Shape target) {
	Rectangle2D bounds = target.getBounds2D();
	float left = (float) bounds.getMinX();
	float right = (float) bounds.getMaxX();
	LinearGradientPaint newPaint = new LinearGradientPaint(left, 0, right, 0, paint.getFractions(), paint.getColors());
	return newPaint;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:8,代码来源:SmartLegendTitle.java

示例6: getLabelEnclosure

import java.awt.Shape; //导入方法依赖的package包/类
/**
 * Returns a rectangle that encloses the axis label.  This is typically used for layout
 * purposes (it gives the maximum dimensions of the label).
 *
 * @param g2  the graphics device.
 * @param edge  the edge of the plot area along which the axis is measuring.
 *
 * @return The enclosing rectangle.
 */
protected Rectangle2D getLabelEnclosure(Graphics2D g2, RectangleEdge edge) {

    // calculate the width of the axis label...
    Rectangle2D result = new Rectangle2D.Double();
    String axisLabel = getLabel();
    if (axisLabel != null) {
        FontMetrics fm = g2.getFontMetrics(getLabelFont());
        Rectangle2D bounds = TextUtilities.getTextBounds(axisLabel, g2, fm);
        Insets insets = getLabelInsets();
        bounds.setRect(bounds.getX(), bounds.getY(),
                       bounds.getWidth() + insets.left + insets.right,
                       bounds.getHeight() + insets.top + insets.bottom);
        double angle = getLabelAngle();
        if (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT) {
            angle = angle - Math.PI / 2.0;
        }
        double x = bounds.getCenterX();
        double y = bounds.getCenterY();
        AffineTransform transformer = AffineTransform.getRotateInstance(angle, x, y);
        Shape labelBounds = transformer.createTransformedShape(bounds);
        result = labelBounds.getBounds2D();
    }

    return result;

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

示例7: labelVertex

import java.awt.Shape; //导入方法依赖的package包/类
/**
 * Labels the specified vertex with the specified label. Uses the font specified by this
 * instance's <code>VertexFontFunction</code>. (If the font is unspecified, the existing font
 * for the graphics context is used.) If vertex label centering is active, the label is centered
 * on the position of the vertex; otherwise the label is offset slightly.
 */
@Override
public void labelVertex(RenderContext<V, E> rc, Layout<V, E> layout, V v, String label) {
	Graph<V, E> graph = layout.getGraph();
	if (rc.getVertexIncludePredicate().evaluate(Context.<Graph<V, E>, V> getInstance(graph, v)) == false) {
		return;
	}
	Point2D pt = layout.transform(v);
	pt = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, pt);

	float x = (float) pt.getX();
	float y = (float) pt.getY();

	Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), label, rc.getPickedVertexState().isPicked(v),
			v);
	GraphicsDecorator g = rc.getGraphicsContext();
	Dimension d = component.getPreferredSize();
	AffineTransform xform = AffineTransform.getTranslateInstance(x, y);

	Shape shape = rc.getVertexShapeTransformer().transform(v);
	shape = xform.createTransformedShape(shape);
	if (rc.getGraphicsContext() instanceof TransformingGraphics) {
		BidirectionalTransformer transformer = ((TransformingGraphics) rc.getGraphicsContext()).getTransformer();
		if (transformer instanceof ShapeTransformer) {
			ShapeTransformer shapeTransformer = (ShapeTransformer) transformer;
			shape = shapeTransformer.transform(shape);
		}
	}
	Rectangle2D bounds = shape.getBounds2D();

	Point p = null;
	if (position == Position.AUTO) {
		Dimension vvd = rc.getScreenDevice().getSize();
		if (vvd.width == 0 || vvd.height == 0) {
			vvd = rc.getScreenDevice().getPreferredSize();
		}
		p = getAnchorPoint(bounds, d, positioner.getPosition(x, y, vvd));
	} else {
		p = getAnchorPoint(bounds, d, position);
	}

	if (graphCreator.isLeaf((String) v)) {
		p.setLocation(p.x, p.y + LABEL_OFFSET_Y);
	}
	g.draw(component, rc.getRendererPane(), p.x, p.y, d.width, d.height, true);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:52,代码来源:TreeModelNodeLabelRenderer.java

示例8: addDrawingRect

import java.awt.Shape; //导入方法依赖的package包/类
/**
 * Add the rectangle 'rect' to the area representing
 * the part of the page which is drawn into.
 */
private void addDrawingRect(Rectangle2D rect) {

    /*  For testing purposes the following line can be uncommented.
        When uncommented it causes the entire page to be rasterized
        thus eliminating errors caused by a faulty bounding box
        calculation.
    */
    //mDrawingArea.addInfinite();



    AffineTransform matrix = getTransform();

    Shape transShape = matrix.createTransformedShape(rect);

    Rectangle2D transRect = transShape.getBounds2D();

    mDrawingArea.add((float) transRect.getMinY(),
                     (float) transRect.getMaxY());


}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:PeekGraphics.java

示例9: currentClippingPath

import java.awt.Shape; //导入方法依赖的package包/类
public Rectangle2D currentClippingPath() {
    Shape clippingPath = this.getGraphicsState().getCurrentClippingPath();
    Shape transformedClippingPath = this.getPageTransform().createTransformedShape(clippingPath);

    return transformedClippingPath.getBounds2D();
}
 
开发者ID:redmyers,项目名称:484_P7_1-Java,代码行数:7,代码来源:ObjectExtractorStreamEngine.java


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