当前位置: 首页>>代码示例>>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;未经允许,请勿转载。