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


Java Rectangle2D.setFrame方法代码示例

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


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

示例1: getSizeForString

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Returns an <mxRectangle> with the size (width and height in pixels) of the given string.
 * 
 * @param text String whose size should be returned.
 * @param font Font to be used for the computation.
 */
public static mxRectangle getSizeForString(String text, Font font, double scale) {
  FontRenderContext frc = new FontRenderContext(null, false, false);
  font = font.deriveFont((float) (font.getSize2D() * scale));
  FontMetrics metrics = null;

  if (fontGraphics != null) {
    metrics = fontGraphics.getFontMetrics(font);
  }

  double lineHeight = mxConstants.LINESPACING;

  if (metrics != null) {
    lineHeight += metrics.getHeight();
  } else {
    lineHeight += font.getSize2D() * 1.27;
  }

  String[] lines = text.split("\n");

  Rectangle2D boundingBox = null;

  if (lines.length == 0) {
    boundingBox = font.getStringBounds("", frc);
  } else {
    for (int i = 0; i < lines.length; i++) {
      Rectangle2D bounds = font.getStringBounds(lines[i], frc);

      if (boundingBox == null) {
        boundingBox = bounds;
      } else {
        boundingBox.setFrame(0, 0, Math.max(boundingBox.getWidth(), bounds.getWidth()),
            boundingBox.getHeight() + lineHeight);
      }
    }
  }

  return new mxRectangle(boundingBox);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:45,代码来源:mxUtils.java

示例2: drawCenteredText

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * 
 * @param s
 * @param c
 * @param centerX
 * @param centerY
 */
private Rectangle2D drawCenteredText(String s, Color fg, Color bg, double centerX, double centerY, Graphics2D g2d, boolean drawBorder,
		boolean draw) {
	double x, y;
	Color ctmp = g2d.getColor();
	Rectangle2D bordersR = new Rectangle2D.Float();
	g2d.setFont(f);
	txtBounds = f.getStringBounds(s, g2d.getFontRenderContext());
	x = centerX - txtBounds.getWidth() / 2.0;
	y = centerY - txtBounds.getY() - txtBounds.getHeight() / 2;
	txtBounds.setRect(x - ELEMS_GAP, y - txtBounds.getHeight() / 2.0 - ELEMS_GAP, txtBounds.getWidth() + 2 * ELEMS_GAP, txtBounds.getHeight() + 2
			* ELEMS_GAP);

	if (draw) {
		if (drawBorder) {
			bordersR.setFrame(centerX - txtBounds.getWidth() / 2.0, centerY - txtBounds.getHeight() / 2.0, txtBounds.getWidth(), txtBounds
					.getHeight());
			g2d.setColor(bg);
			g2d.fill(bordersR);
			g2d.setColor(fg);
			g2d.draw(bordersR);
		}
		g2d.setColor(fg);
		g2d.drawString(s, (float) x, (float) y);

	}
	g2d.setColor(ctmp);
	return txtBounds;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:36,代码来源:QueueDrawer.java

示例3: showAllInNewMap

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private void showAllInNewMap() {
    // when the OpenStreetMap is used, only zoom on existing points and
    // do not show the entire OSM map.
    if (manager.isUsingOpenStreetMap()
            && manager.getNewPointsGeoSet().getNumberOfChildren() > 1) {
        Rectangle2D bounds = manager.getNewPointsGeoSet().getBounds2D();
        double w = bounds.getWidth();
        double h = bounds.getHeight();
        bounds.setFrame(bounds.getMinX() - w / 4, bounds.getMinY() - h / 4, 1.5 * w, 1.5 * h);
        newMapComponent.zoomOnRectangle((Rectangle2D.Double) bounds);
    } else {
        // OSM is not used, zoom on all existing data.
        newMapComponent.showAll();
    }
}
 
开发者ID:berniejenny,项目名称:MapAnalyst,代码行数:16,代码来源:MainWindow.java

示例4: updateAutoSize

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Overwritten to freeze nodes to their center on
 * size changes.
 */
@Override
public void updateAutoSize(CellView view) {
    if (view != null && !isEditing()) {
        Rectangle2D bounds =
            (view.getAttributes() != null) ? GraphConstants.getBounds(view.getAttributes())
                : null;
        AttributeMap attrs = getModel().getAttributes(view.getCell());
        if (bounds == null) {
            bounds = GraphConstants.getBounds(attrs);
        }
        if (bounds != null) {
            boolean autosize = GraphConstants.isAutoSize(view.getAllAttributes());
            boolean resize = GraphConstants.isResize(view.getAllAttributes());
            if (autosize || resize) {
                Dimension2D d = getPreferredSize(view);
                int inset = 2 * GraphConstants.getInset(view.getAllAttributes());
                // adjust the x,y corner so that the center stays in place
                double shiftX = (bounds.getWidth() - d.getWidth() - inset) / 2;
                double shiftY = (bounds.getHeight() - d.getHeight() - inset) / 2;
                bounds.setFrame(bounds.getX() + shiftX, bounds.getY() + shiftY, d.getWidth(),
                    d.getHeight());
                // Remove resize attribute
                snap(bounds);
                if (resize) {
                    if (view.getAttributes() != null) {
                        view.getAttributes().remove(GraphConstants.RESIZE);
                    }
                    attrs.remove(GraphConstants.RESIZE);
                }
                view.refresh(getGraphLayoutCache(), getGraphLayoutCache(), false);
            }
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:39,代码来源:JGraph.java

示例5: getSizeForString

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Returns an <mxRectangle> with the size (width and height in pixels) of
 * the given string.
 * 
 * @param text
 *            String whose size should be returned.
 * @param font
 *            Font to be used for the computation.
 */
public static mxRectangle getSizeForString(String text, Font font,
		double scale)
{
	FontRenderContext frc = new FontRenderContext(null, false, false);
	font = font.deriveFont((float) (font.getSize2D() * scale));
	FontMetrics metrics = null;

	if (fontGraphics != null)
	{
		metrics = fontGraphics.getFontMetrics(font);
	}

	double lineHeight = mxConstants.LINESPACING;

	if (metrics != null)
	{
		lineHeight += metrics.getHeight();
	}
	else
	{
		lineHeight += font.getSize2D() * 1.27;
	}

	String[] lines = text.split("\n");

	Rectangle2D boundingBox = null;

	if (lines.length == 0)
	{
		boundingBox = font.getStringBounds("", frc);
	}
	else
	{
		for (int i = 0; i < lines.length; i++)
		{
			Rectangle2D bounds = font.getStringBounds(lines[i], frc);

			if (boundingBox == null)
			{
				boundingBox = bounds;
			}
			else
			{
				boundingBox
						.setFrame(
								0,
								0,
								Math.max(boundingBox.getWidth(),
										bounds.getWidth()),
								boundingBox.getHeight() + lineHeight);
			}
		}
	}

	return new mxRectangle(boundingBox);
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:66,代码来源:mxUtils.java

示例6: drawChipGrid

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Calculates and draws the chip locations on the wafer.
 * 
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 */
private void drawChipGrid(Graphics2D g2, Rectangle2D plotArea) {
    
    Shape savedClip = g2.getClip();
    g2.setClip(getWaferEdge(plotArea));
    Rectangle2D chip = new Rectangle2D.Double();
    int xchips = 35;
    int ychips = 20;
    double space = 1d;
    if (this.dataset != null) {
        xchips = this.dataset.getMaxChipX() + 2;
        ychips = this.dataset.getMaxChipY() + 2;
        space = this.dataset.getChipSpace();
    }
    double startX = plotArea.getX();
    double startY = plotArea.getY();
    double chipWidth = 1d;
    double chipHeight = 1d;
    if (plotArea.getWidth() != plotArea.getHeight()) {
        double major = 0d;
        double minor = 0d;
        if (plotArea.getWidth() > plotArea.getHeight()) {
            major = plotArea.getWidth();
            minor = plotArea.getHeight();
        } 
        else {
            major = plotArea.getHeight();
            minor = plotArea.getWidth();
        } 
        //set upperLeft point
        if (plotArea.getWidth() == minor) { // x is minor
            startY += (major - minor) / 2;
            chipWidth = (plotArea.getWidth() - (space * xchips - 1)) / xchips;
            chipHeight = (plotArea.getWidth() - (space * ychips - 1)) / ychips;
        }
        else { // y is minor
            startX += (major - minor) / 2;
            chipWidth = (plotArea.getHeight() - (space * xchips - 1)) / xchips;
            chipHeight = (plotArea.getHeight() - (space * ychips - 1)) / ychips;
        }
    }
    
    for (int x = 1; x <= xchips; x++) {
        double upperLeftX = (startX - chipWidth) + (chipWidth * x) + (space * (x - 1));
        for (int y = 1; y <= ychips; y++) {
            double upperLeftY = (startY - chipHeight) + (chipHeight * y) + (space * (y - 1));
            chip.setFrame(upperLeftX, upperLeftY, chipWidth, chipHeight);
            g2.setColor(Color.white);
            if (this.dataset.getChipValue(x - 1, ychips - y - 1) != null) {
                g2.setPaint(
                    this.renderer.getChipColor(this.dataset.getChipValue(x - 1, ychips - y - 1))
                );
            } 
            g2.fill(chip);
            g2.setColor(Color.lightGray);
            g2.draw(chip);
        }
    }
    g2.setClip(savedClip);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:66,代码来源:WaferMapPlot.java

示例7: drawChipGrid

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Calculates and draws the chip locations on the wafer.
 * 
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 */
protected void drawChipGrid(Graphics2D g2, Rectangle2D plotArea) {
    
    Shape savedClip = g2.getClip();
    g2.setClip(getWaferEdge(plotArea));
    Rectangle2D chip = new Rectangle2D.Double();
    int xchips = 35;
    int ychips = 20;
    double space = 1d;
    if (this.dataset != null) {
        xchips = this.dataset.getMaxChipX() + 2;
        ychips = this.dataset.getMaxChipY() + 2;
        space = this.dataset.getChipSpace();
    }
    double startX = plotArea.getX();
    double startY = plotArea.getY();
    double chipWidth = 1d;
    double chipHeight = 1d;
    if (plotArea.getWidth() != plotArea.getHeight()) {
        double major = 0d;
        double minor = 0d;
        if (plotArea.getWidth() > plotArea.getHeight()) {
            major = plotArea.getWidth();
            minor = plotArea.getHeight();
        } 
        else {
            major = plotArea.getHeight();
            minor = plotArea.getWidth();
        } 
        //set upperLeft point
        if (plotArea.getWidth() == minor) { // x is minor
            startY += (major - minor) / 2;
            chipWidth = (plotArea.getWidth() - (space * xchips - 1)) 
                / xchips;
            chipHeight = (plotArea.getWidth() - (space * ychips - 1)) 
                / ychips;
        }
        else { // y is minor
            startX += (major - minor) / 2;
            chipWidth = (plotArea.getHeight() - (space * xchips - 1)) 
                / xchips;
            chipHeight = (plotArea.getHeight() - (space * ychips - 1)) 
                / ychips;
        }
    }
    
    for (int x = 1; x <= xchips; x++) {
        double upperLeftX = (startX - chipWidth) + (chipWidth * x) 
            + (space * (x - 1));
        for (int y = 1; y <= ychips; y++) {
            double upperLeftY = (startY - chipHeight) + (chipHeight * y) 
                + (space * (y - 1));
            chip.setFrame(upperLeftX, upperLeftY, chipWidth, chipHeight);
            g2.setColor(Color.white);
            if (this.dataset.getChipValue(x - 1, ychips - y - 1) != null) {
                g2.setPaint(
                    this.renderer.getChipColor(
                        this.dataset.getChipValue(x - 1, ychips - y - 1)
                    )
                );
            } 
            g2.fill(chip);
            g2.setColor(Color.lightGray);
            g2.draw(chip);
        }
    }
    g2.setClip(savedClip);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:74,代码来源:WaferMapPlot.java


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