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


Java Point.move方法代码示例

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


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

示例1: forceDraw

import java.awt.Point; //导入方法依赖的package包/类
/** Draw the grid even if not marked visible */
public void forceDraw(Graphics g, Rectangle bounds, Rectangle visibleRect, double scale, boolean reversed) {
  if (!bounds.intersects(visibleRect) || color == null) {
    return;
  }

  Graphics2D g2d = (Graphics2D) g;
  g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                       RenderingHints.VALUE_ANTIALIAS_ON);

  Rectangle region = bounds.intersection(visibleRect);

  Shape oldClip = g2d.getClip();
  if (oldClip != null) {
    Area clipArea = new Area(oldClip);
    clipArea.intersect(new Area(region));
    g2d.setClip(clipArea);
  }

  double deltaX = scale * dx;
  double deltaY = scale * dy;

  double xmin = reversed ? bounds.x + scale * origin.x + bounds.width - deltaX * round((bounds.x + scale * origin.x + bounds.width - region.x) / deltaX) + deltaX / 2
      : bounds.x + scale * origin.x + deltaX * round((region.x - bounds.x - scale * origin.x) / deltaX) + deltaX / 2;
  double xmax = region.x + region.width;
  double ymin = reversed ? bounds.y + scale * origin.y + bounds.height - deltaY * round((bounds.y + scale * origin.y + bounds.height - region.y) / deltaY) + deltaY / 2
      : bounds.y + scale * origin.y + deltaY * round((region.y - bounds.y - scale * origin.y) / deltaY) + deltaY / 2;
  double ymax = region.y + region.height;

  Point p1 = new Point();
  Point p2 = new Point();
  g2d.setColor(color);
  // x is the location of a vertical line
  for (double x = xmin; x < xmax; x += deltaX) {
    p1.move((int) round(x), region.y);
    p2.move((int) round(x), region.y + region.height);
    g2d.drawLine(p1.x, p1.y, p2.x, p2.y);
  }
  for (double y = ymin; y < ymax; y += deltaY) {
    g2d.drawLine(region.x, (int) round(y), region.x + region.width, (int) round(y));
  }
  if (dotsVisible) {
    xmin = reversed ? bounds.x + scale * origin.x + bounds.width - deltaX * round((bounds.x + scale * origin.x + bounds.width - region.x) / deltaX)
        : bounds.x + scale * origin.x + deltaX * round((region.x - bounds.x - scale * origin.x) / deltaX);
    ymin = reversed ? bounds.y + scale * origin.y + bounds.height - deltaY * round((bounds.y + scale * origin.y + bounds.height - region.y) / deltaY)
        : bounds.y + scale * origin.y + deltaY * round((region.y - bounds.y - scale * origin.y) / deltaY);
    for (double x = xmin; x < xmax; x += deltaX) {
      for (double y = ymin; y < ymax; y += deltaY) {
        p1.move((int) round(x - 0.5), (int) round(y - 0.5));
        g2d.fillRect(p1.x, p1.y, 2, 2);
      }
    }
  }
  g2d.setClip(oldClip);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:56,代码来源:SquareGrid.java


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