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