當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。