當前位置: 首頁>>代碼示例>>Java>>正文


Java Rectangle2D.isEmpty方法代碼示例

本文整理匯總了Java中java.awt.geom.Rectangle2D.isEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle2D.isEmpty方法的具體用法?Java Rectangle2D.isEmpty怎麽用?Java Rectangle2D.isEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.geom.Rectangle2D的用法示例。


在下文中一共展示了Rectangle2D.isEmpty方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getVisualBounds

import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
public Rectangle2D getVisualBounds() {
    Rectangle2D result = null;
    for (int i = 0; i < glyphs.length; ++i) {
        Rectangle2D glyphVB = getGlyphVisualBounds(i).getBounds2D();
        if (!glyphVB.isEmpty()) {
            if (result == null) {
                result = glyphVB;
            } else {
                Rectangle2D.union(result, glyphVB, result);
            }
        }
    }
    if (result == null) {
        result = new Rectangle2D.Float(0, 0, 0, 0);
    }
    return result;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:StandardGlyphVector.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:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,代碼來源:StandardGlyphVector.java

示例3: getDefaultScaleAtPoint

import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
 * Gets the default point to scale at for zooming.
 * @return the default scale at point
 */
private Point2D getDefaultScaleAtPoint() {
	Rectangle2D rectVis = this.getVisualizationViewer().getVisibleRect();
	if (rectVis.isEmpty()==false) {
		this.defaultScaleAtPoint = new Point2D.Double(rectVis.getCenterX(), rectVis.getCenterY());
	}
	return defaultScaleAtPoint;
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:12,代碼來源:BasicGraphGui.java

示例4: zoomSetInitialScalingAndMovement

import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
 * Sets the initial scaling for the graph on the VisualizationViewer.
 */
private void zoomSetInitialScalingAndMovement(VisualizationViewer<GraphNode, GraphEdge> visViewer) {
	
	if (this.allowInitialScaling == false) return;

	Graph<GraphNode, GraphEdge> currGraph = visViewer.getGraphLayout().getGraph();
	Rectangle2D rectGraph = GraphGlobals.getGraphSpreadDimension(currGraph);
	Rectangle2D rectVis = visViewer.getVisibleRect();
	if (rectVis.isEmpty()) return;

	Point2D scaleAt = new Point2D.Double(0, 0);
	this.setDefaultScaleAtPoint(scaleAt);

	// --- Calculate the scaling --------------------------------
	double graphWidth = rectGraph.getWidth() + 2 * this.graphMargin;
	double graphHeight = rectGraph.getHeight() + 2 * this.graphMargin;
	double visWidth = rectVis.getWidth();
	double visHeight = rectVis.getHeight();

	float scaleX = (float) (visWidth / graphWidth);
	float scaleY = (float) (visHeight / graphHeight);
	if (scaleX > 1) scaleX = 1;
	if (scaleY > 1) scaleY = 1;

	float scale = scaleX;
	if (scaleX > scaleY) {
		scale = scaleY;
	}

	// --- Calculate the movement in the view -------------------
	double moveX = 0;
	double moveY = 0;
	if (rectGraph.getX() != 0) {
		moveX = rectGraph.getX() * (-1) + this.graphMargin;
	}
	if (rectGraph.getY() != 0) {
		moveY = rectGraph.getY() * (-1) + this.graphMargin;
	}

	// --- Set movement -----------
	visViewer.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).translate(moveX, moveY);

	// --- Set scaling ------------
	if (scale != 0 && scale != 1) {
		this.scalingControl.scale(visViewer, scale, scaleAt);
	}
	this.allowInitialScaling = false;

}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:52,代碼來源:BasicGraphGui.java

示例5: adjustBounds

import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
@Override
public void adjustBounds(Rectangle2D bb) {
   if (bb.isEmpty()) {
      bb.setRect(x, y, 0, 0);
   }
}
 
開發者ID:eric-roberts,項目名稱:JavaPPTX,代碼行數:7,代碼來源:PPPath.java

示例6: RadialGradientPaint

import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
 * Constructs a {@code RadialGradientPaint} with a default
 * {@code SRGB} color space.
 * The gradient circle of the {@code RadialGradientPaint} is defined
 * by the given bounding box.
 * <p>
 * This constructor is a more convenient way to express the
 * following (equivalent) code:<br>
 *
 * <pre>
 *     double gw = gradientBounds.getWidth();
 *     double gh = gradientBounds.getHeight();
 *     double cx = gradientBounds.getCenterX();
 *     double cy = gradientBounds.getCenterY();
 *     Point2D center = new Point2D.Double(cx, cy);
 *
 *     AffineTransform gradientTransform = new AffineTransform();
 *     gradientTransform.translate(cx, cy);
 *     gradientTransform.scale(gw / 2, gh / 2);
 *     gradientTransform.translate(-cx, -cy);
 *
 *     RadialGradientPaint gp =
 *         new RadialGradientPaint(center, 1.0f, center,
 *                                 fractions, colors,
 *                                 cycleMethod,
 *                                 ColorSpaceType.SRGB,
 *                                 gradientTransform);
 * </pre>
 *
 * @param gradientBounds the bounding box, in user space, of the circle
 *                       defining the outermost extent of the gradient
 * @param fractions numbers ranging from 0.0 to 1.0 specifying the
 *                  distribution of colors along the gradient
 * @param colors array of colors to use in the gradient.  The first color
 *               is used at the focus point, the last color around the
 *               perimeter of the circle.
 * @param cycleMethod either {@code NO_CYCLE}, {@code REFLECT},
 *                    or {@code REPEAT}
 *
 * @throws NullPointerException
 * if {@code gradientBounds} is null,
 * or {@code fractions} array is null,
 * or {@code colors} array is null,
 * or {@code cycleMethod} is null
 * @throws IllegalArgumentException
 * if {@code gradientBounds} is empty,
 * or {@code fractions.length != colors.length},
 * or {@code colors} is less than 2 in size,
 * or a {@code fractions} value is less than 0.0 or greater than 1.0,
 * or the {@code fractions} are not provided in strictly increasing order
 */
public RadialGradientPaint(Rectangle2D gradientBounds,
                           float[] fractions, Color[] colors,
                           CycleMethod cycleMethod)
{
    // gradient center/focal point is the center of the bounding box,
    // radius is set to 1.0, and then we set a scale transform
    // to achieve an elliptical gradient defined by the bounding box
    this(new Point2D.Double(gradientBounds.getCenterX(),
                            gradientBounds.getCenterY()),
         1.0f,
         new Point2D.Double(gradientBounds.getCenterX(),
                            gradientBounds.getCenterY()),
         fractions,
         colors,
         cycleMethod,
         ColorSpaceType.SRGB,
         createGradientTransform(gradientBounds));

    if (gradientBounds.isEmpty()) {
        throw new IllegalArgumentException("Gradient bounds must be " +
                                           "non-empty");
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:75,代碼來源:RadialGradientPaint.java


注:本文中的java.awt.geom.Rectangle2D.isEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。