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


Java Rectangle2D.Double方法代码示例

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


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

示例1: testJava2DToValue

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Test the translation of Java2D values to data values.
 */
public void testJava2DToValue() {
    DateAxis axis = new DateAxis();
    axis.setRange(50.0, 100.0); 
    Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0);
    double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT);  
    assertTrue(same(y1, 95.8333333, 1.0)); 
    double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT);   
    assertTrue(same(y2, 95.8333333, 1.0)); 
    double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP);   
    assertTrue(same(x1, 58.125, 1.0)); 
    double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM);   
    assertTrue(same(x2, 58.125, 1.0)); 
    axis.setInverted(true);
    double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT);  
    assertTrue(same(y3, 54.1666667, 1.0)); 
    double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT);   
    assertTrue(same(y4, 54.1666667, 1.0)); 
    double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP);   
    assertTrue(same(x3, 91.875, 1.0)); 
    double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM);   
    assertTrue(same(x4, 91.875, 1.0));   
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:DateAxisTests.java

示例2: doPaint

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public void doPaint(Graphics2D g2d) {
    BufferedImage patternImage = new BufferedImage(2,2,BufferedImage.TYPE_INT_ARGB);
    Graphics gImage = patternImage.getGraphics();
    gImage.setColor(Color.WHITE);
    gImage.drawLine(0,1,1,0);
    gImage.setColor(Color.BLACK);
    gImage.drawLine(0,0,1,1);
    gImage.dispose();

    Rectangle2D.Double shape = new Rectangle2D.Double(0,0,DIM*6/5, DIM*8/5);
    g2d.setPaint(new TexturePaint(patternImage, new Rectangle2D.Double(0,0,
                 DIM*6/50, DIM*8/50)));
    g2d.fill(shape);
    g2d.setPaint(Color.BLACK);
    g2d.draw(shape);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:TexturePaintPrintingTest.java

示例3: drawUtilizationMulti

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private void drawUtilizationMulti(double U, Color startC, Color border, boolean gradientFill, Graphics2D g2d, int cpu) {

		double x = getProcessorXY().x, y = getProcessorXY().y;
		try {
			occupiedRect = new Rectangle2D.Double(x + PROC_RAD / 2 + ELEMS_GAP / 2, y + cpu * (PROC_RAD - ELEMS_GAP) + ELEMS_GAP * cpu * 3
					- ELEMS_GAP / 2, PROC_RAD - ELEMS_GAP, (PROC_RAD - ELEMS_GAP) * (1 - U / nCpu));
		} catch (Exception e) {
			occupiedRect = new Rectangle2D.Double(x + PROC_RAD / 2 + ELEMS_GAP / 2, y + cpu * (PROC_RAD - ELEMS_GAP) + ELEMS_GAP * cpu * 3
					- ELEMS_GAP / 2, PROC_RAD - ELEMS_GAP, 0);
		}
		occupiedEll = new Ellipse2D.Double(x + PROC_RAD / 2 + ELEMS_GAP / 2, y + cpu * (PROC_RAD - ELEMS_GAP) + ELEMS_GAP * cpu * 3 - ELEMS_GAP / 2,
				PROC_RAD - ELEMS_GAP, PROC_RAD - ELEMS_GAP);
		if (gradientFill) {
			GradientPaint gp = new GradientPaint((float) x, (float) y, startC.brighter(), (float) x, (float) (y + 2 * PROC_RAD), startC.darker(),
					false);
			g2d.setPaint(gp);
		} else {
			g2d.setPaint(startC);
		}
		occupiedArea = new Area(occupiedEll);
		occupiedArea.subtract(new Area(occupiedRect));
		g2d.fill(occupiedArea);
		g2d.setPaint(Color.BLACK);
		g2d.draw(occupiedArea);

	}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:27,代码来源:QueueDrawer.java

示例4: createBodyShape

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private Rectangle2D createBodyShape() {
   double x = 0;
   double y = SF * TITLE_BAR_HEIGHT;
   double w = sw - 1;
   double h = sh - y - 1;
   return new Rectangle2D.Double(x, y, w, h);
}
 
开发者ID:eric-roberts,项目名称:JavaPPTX,代码行数:8,代码来源:PPWindowImage.java

示例5: createProcessAnnotation

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
@Override
public ProcessAnnotation createProcessAnnotation(ExecutionUnit process) {
	Rectangle2D frame = getLocation();
	AnnotationStyle style = getStyle().clone();
	// process annotations are always yellow by default
	if (!wasColored()) {
		style.setAnnotationColor(AnnotationColor.YELLOW);
	}
	return new ProcessAnnotation(getComment(), style, process, false, wasColored(), new Rectangle2D.Double(frame.getX(),
			frame.getY(), frame.getWidth(), Math.max(ProcessAnnotation.MIN_HEIGHT, frame.getHeight())));
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:12,代码来源:OperatorAnnotation.java

示例6: fillBackground

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private void fillBackground(Graphics2D g) {
   Graphics2D g2 = (Graphics2D) g.create();
   Rectangle2D window = new Rectangle2D.Double(0, 0, sw, sh);
   g2.setComposite(AlphaComposite.Clear);
   g2.fill(window);
   g2.dispose();
}
 
开发者ID:eric-roberts,项目名称:JavaPPTX,代码行数:8,代码来源:PPWindowImage.java

示例7: createIntersection

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * @since 1.2
 */
public Rectangle2D createIntersection(Rectangle2D r) {
    if (r instanceof Rectangle) {
        return intersection((Rectangle) r);
    }
    Rectangle2D dest = new Rectangle2D.Double();
    Rectangle2D.intersect(this, r, dest);
    return dest;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:Rectangle.java

示例8: getBoundingBox

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Returns the bounding rectangle (with 2*xfluff added to the width, and
 * 2*yfluff added to the height)
 */
Rectangle2D getBoundingBox(int xfluff, int yfluff) {
	if (updown < 0)
		calcBounds();
	return new Rectangle2D.Double(x() - side - xfluff, y() - updown - yfluff, side + side + xfluff + xfluff,
			updown + updown + yfluff + yfluff);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:11,代码来源:GraphNode.java

示例9: 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

示例10: getCaretRectangle

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
Rectangle2D getCaretRectangle(Rectangle2D r) {
    int d = 3;
    double cx = r.getX() - d;
    double cy = r.getY();
    double cw = 2 * d;
    double ch = r.getHeight();
    return new Rectangle2D.Double(cx, cy, cw, ch);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:CaretFloatingPointAPITest.java

示例11: getTileBoundingBox

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public static Rectangle2D getTileBoundingBox(final Point tile) {
  if (Game.getEnvironment() == null || Game.getEnvironment().getMap() == null) {
    return new Rectangle2D.Double();
  }

  return getTileBoundingBox(Game.getEnvironment().getMap(), tile);
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:8,代码来源:MapUtilities.java

示例12: drawToolTip

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private void drawToolTip(Graphics2D g) {
	if (currentToolTip != null) {
		g.setFont(LABEL_FONT);
		Rectangle2D stringBounds = LABEL_FONT.getStringBounds(currentToolTip, g.getFontRenderContext());
		g.setColor(TOOLTIP_COLOR);
		Rectangle2D bg = new Rectangle2D.Double(toolTipX - stringBounds.getWidth() / 2 - 4, toolTipY
				- stringBounds.getHeight() / 2 - 2, stringBounds.getWidth() + 5, Math.abs(stringBounds.getHeight()) + 3);
		g.fill(bg);
		g.setColor(Color.black);
		g.draw(bg);
		g.drawString(currentToolTip, (float) (toolTipX - stringBounds.getWidth() / 2) - 2, (float) (toolTipY + 3));
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:BoundDiagram.java

示例13: drawWeightRectangle

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
protected void drawWeightRectangle(Graphics2D newSpace, DataTable dataTable, int column, double maxWeight,
		int plotterSize) {
	if (dataTable.isSupportingColumnWeights()) {
		newSpace.setColor(getWeightColor(dataTable.getColumnWeight(column), maxWeight));
		Rectangle2D weightRect = new Rectangle2D.Double(1, 1, plotterSize - 2, plotterSize - 2);
		newSpace.fill(weightRect);
		newSpace.setColor(Color.WHITE);
		int weightBorder = WEIGHT_BORDER_WIDTH + 1;
		weightRect = new Rectangle2D.Double(weightBorder, weightBorder, plotterSize - 2 * weightBorder, plotterSize - 2
				* weightBorder);
		newSpace.fill(weightRect);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:PlotterAdapter.java

示例14: drawSymbolicGridLinesVertical

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Draws the symbolic grid lines.
 * <P>
 * The colors are consecutively the color specified by
 * <CODE>symbolicGridPaint<CODE>
 * (<CODE>DEFAULT_SYMBOLIC_GRID_LINE_PAINT</CODE> by default) and white.
 * or if <CODE>firstGridLineIsDark</CODE> is <CODE>true</CODE> white and
 * the color specified by <CODE>symbolicGridPaint<CODE>.
 *
 * @param g2  the graphics device.
 * @param drawArea  the area within which the chart should be drawn.
 * @param plotArea  the area within which the plot should be drawn (a
 *                  subset of the drawArea).
 * @param firstGridLineIsDark   True: the first symbolic grid line take the
 *      color of <CODE>symbolicGridPaint<CODE>.
 *      False: the first symbolic grid line is white.
 * @param ticks  a list of ticks.
 */
public void drawSymbolicGridLinesVertical(Graphics2D g2, Rectangle2D drawArea,
                                          Rectangle2D plotArea, boolean firstGridLineIsDark,
                                          List ticks) {

    this.symbolicGridLineList = new Vector(ticks.size());
    boolean currentGridLineIsDark = firstGridLineIsDark;
    double xx = plotArea.getX();
    double yy1, yy2;

    //gets the outline stroke width of the plot
    double outlineStrokeWidth;
    if (getPlot().getOutlineStroke() != null) {
        outlineStrokeWidth = ((BasicStroke) getPlot().getOutlineStroke()).getLineWidth();
    }
    else {
        outlineStrokeWidth = 1d;
    }

    Iterator iterator = ticks.iterator();
    ValueTick tick;
    Rectangle2D symbolicGridLine;
    while (iterator.hasNext()) {
        tick = (ValueTick) iterator.next();
        yy1 = valueToJava2D(tick.getValue() + 0.5d, plotArea, RectangleEdge.LEFT);
        yy2 = valueToJava2D(tick.getValue() - 0.5d, plotArea, RectangleEdge.LEFT);
        if (currentGridLineIsDark) {
            g2.setPaint(this.symbolicGridPaint);
            //g2.setXORMode((Color) getSymbolicGridPaint());
        }
        else {
            g2.setPaint(Color.white);
            //g2.setXORMode(Color.white);
        }
        symbolicGridLine = new Rectangle2D.Double(xx + outlineStrokeWidth,
            yy1, plotArea.getMaxX() - xx - outlineStrokeWidth, yy2 - yy1);
        g2.fill(symbolicGridLine);
        this.symbolicGridLineList.add(symbolicGridLine);
        currentGridLineIsDark = !currentGridLineIsDark;
    }
    g2.setPaintMode();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:60,代码来源:SymbolicAxis.java

示例15: getShape

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Returns a Shape that can be used in plotting data. Used in CategoryPlots.
 *
 * @param series  the index of the series.
 * @param category  the category.
 * @param x  x-coordinate of the category.
 * @param y  y-coordinate of the category.
 * @param scale  the size.
 *
 * @return a Shape that can be used in plotting data.
 */
public Shape getShape(int series, Object category, double x, double y, double scale) {

    double delta = 0.5 * scale;
    int index = series % SHAPE_COUNT;
    int[] xpoints = null;
    int[] ypoints = null;
    switch (index) {
    case 0:
        // Square
        return new Rectangle2D.Double(x - delta, y - delta, scale, scale);
    case 1:
        // Circle
        return new Ellipse2D.Double(x - delta, y - delta, scale, scale);
    case 2:
        // Up-pointing triangle
        xpoints = intArray(x, x + delta, x - delta);
        ypoints = intArray(y - delta, y + delta, y + delta);
        return new Polygon(xpoints, ypoints, 3);
    case 3:
        // Diamond
        xpoints = intArray(x, x + delta, x, x - delta);
        ypoints = intArray(y - delta, y, y + delta, y);
        return new Polygon(xpoints, ypoints, 4);
    case 4:
        // Horizontal rectangle
        return new Rectangle2D.Double(x - delta, y - delta / 2, scale, scale / 2);
    case 5:
        // Down-pointing triangle
        xpoints = intArray(x - delta, x + delta, x);
        ypoints = intArray(y - delta, y - delta, y + delta);
        return new Polygon(xpoints, ypoints, 3);
    case 6:
        // Horizontal ellipse
        return new Ellipse2D.Double(x - delta, y - delta / 2, scale, scale / 2);
    case 7:
        // Right-pointing triangle
        xpoints = intArray(x - delta, x + delta, x - delta);
        ypoints = intArray(y - delta, y, y + delta);
        return new Polygon(xpoints, ypoints, 3);
    case 8:
        // Vertical rectangle
        return new Rectangle2D.Double(x - delta / 2, y - delta, scale / 2, scale);
    case 9:
        // Left-pointing triangle
        xpoints = intArray(x - delta, x + delta, x + delta);
        ypoints = intArray(y, y - delta, y + delta);
        return new Polygon(xpoints, ypoints, 3);
    default:
        // Vertical ellipse
        return new Ellipse2D.Double(x - delta / 2, y - delta, scale / 2, scale);
    }

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


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