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