java.awt.Graphics2D.getClipBounds()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(192)

本文整理了Java中java.awt.Graphics2D.getClipBounds()方法的一些代码示例,展示了Graphics2D.getClipBounds()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics2D.getClipBounds()方法的具体详情如下:
包路径:java.awt.Graphics2D
类名称:Graphics2D
方法名:getClipBounds

Graphics2D.getClipBounds介绍

暂无

代码示例

代码示例来源:origin: chewiebug/GCViewer

public void paintComponent(Graphics2D g2d) {
  // make sure that we ignore the AntiAliasing flag as it does not make sense for vertical lines
  g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
  double scaleFactor = getModelChart().getScaleFactor();
  Rectangle clipBounds = g2d.getClipBounds();
  int minX = clipBounds.x;
  int maxX = clipBounds.x+clipBounds.width;
  int height = getHeight();
  int lastScaledTimestamp = Integer.MIN_VALUE;
  for (Iterator<GCEvent> i = getModelChart().getModel().getFullGCEvents(); i.hasNext();) {
    GCEvent event = i.next();
    int scaledTimestamp = (int)(scaleFactor * (event.getTimestamp() - getModelChart().getModel().getFirstPauseTimeStamp()));
    if (scaledTimestamp != lastScaledTimestamp && scaledTimestamp >= minX && scaledTimestamp <= maxX) {
      g2d.drawLine(scaledTimestamp, 0, scaledTimestamp, height);
      lastScaledTimestamp = scaledTimestamp;
    }
  }
}

代码示例来源:origin: chewiebug/GCViewer

int lastY = Integer.MIN_VALUE;
Rectangle clip = g2d.getClipBounds();
int leftBoundary = clip.x;
int rightBoundary = clip.x + clip.width;

代码示例来源:origin: apache/geode

public void paint(Graphics2D g, StateColorMap colorMap) {
 Rectangle boundary = g.getClipBounds();
 if (x > boundary.getMaxX() || x + width < boundary.getMinX()) {
  // no need to paint if this line isn't displayed
  return;
 }
 // TODO - we need to clip these to the visible states
 for (LifelineState state : states) {
  state.paint(g, colorMap);
 }
}

代码示例来源:origin: apache/geode

public void paint(Graphics2D g, StateColorMap colorMap) {
 Rectangle bounds = g.getClipBounds();
 if (startY > bounds.getMaxY() || startY + height < bounds.getMinY()) {
  return;
 }
 int x = line.getX();
 int width = line.getWidth();
 Color color = colorMap.getColor(stateName);
 g.setColor(color);
 g.fillRoundRect(x, startY, width, height, ARC_SIZE, ARC_SIZE);
 g.setColor(Color.BLACK);
}

代码示例来源:origin: apache/pdfbox

@Override
public Rectangle getClipBounds()
{
  return groupG2D.getClipBounds();
}

代码示例来源:origin: geotools/geotools

public Rectangle getClipBounds() {
  return delegate.getClipBounds();
}

代码示例来源:origin: geotools/geotools

public Rectangle getClipBounds(Rectangle r) {
  return delegate.getClipBounds(r);
}

代码示例来源:origin: apache/geode

public void highlight(Graphics2D g) {
 Rectangle bounds = g.getClipBounds();
 if (startY > bounds.getMaxY() || startY + height < bounds.getMinY()) {
  return;
 }
 int x = line.getX();
 int width = line.getWidth();
 g.drawRoundRect(x, startY, width, height, ARC_SIZE, ARC_SIZE);
}

代码示例来源:origin: apache/geode

public void paint(Graphics2D g) {
 Rectangle boundary = g.getClipBounds();
 int y = endingState.getStartY();
 // don't paint if we're not in the clip area
 if (y + ARROW_WIDTH < boundary.getMinY() || y - ARROW_WIDTH > boundary.getMaxY()) {
  return;
 }
 // TODO - we need to clip by X coordinate as well.
 boolean isReflexsive = getStartingLine() == getEndingLine();
 if (isReflexsive) {
  paintReflexive(g);
 } else {
  paintNormal(g);
 }
}

代码示例来源:origin: nodebox/nodebox

@Override
  public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    if (selected) {
      Rectangle clip = g2.getClipBounds();
      g2.setColor(new java.awt.Color(224, 224, 224));
      g2.fillRect(clip.x, clip.y, clip.width, clip.height);
    }
    g2.setFont(Theme.SMALL_FONT);
    g2.setColor(Color.BLACK);
    g2.drawString(text, 15, 18);
  }
}

代码示例来源:origin: nodebox/nodebox

@Override
  public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    if (selected) {
      Rectangle clip = g2.getClipBounds();
      g2.setColor(Theme.NODE_ATTRIBUTES_PARAMETER_COLOR);
      g2.fillRect(clip.x, clip.y, clip.width, clip.height);
    }
    g2.setFont(Theme.SMALL_FONT);
    if (selected) {
      g2.setColor(Color.WHITE);
    } else {
      g2.setColor(Color.BLACK);
    }
    g2.drawString(text, 15, 18);
  }
}

代码示例来源:origin: knowm/XChart

void prepare(Graphics2D g) {
 if (!styler.isToolTipsEnabled()) {
  return;
 }
 // clear lists
 dataPointList.clear();
 Rectangle clipBounds = g.getClipBounds();
 leftEdge = clipBounds.getX() + MARGIN;
 rightEdge = clipBounds.getMaxX() - MARGIN * 2;
 topEdge = clipBounds.getY() + MARGIN;
 bottomEdge = clipBounds.getMaxY() - MARGIN * 2;
}

代码示例来源:origin: knowm/XChart

Rectangle clipBounds = g.getClipBounds();

代码示例来源:origin: org.apache.pdfbox/pdfbox

@Override
public Rectangle getClipBounds()
{
  return groupG2D.getClipBounds();
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/napkinlaf

/** {@inheritDoc} */
@Override
public Rectangle getClipBounds(Rectangle r) {
  return g2d.getClipBounds(r);
}

代码示例来源:origin: robo-code/robocode

@Override
@Deprecated
public Rectangle getClipRect() {
  return g.getClipBounds(); // Must use getClipBounds() instead of the deprecated getClipRect() method
}

代码示例来源:origin: raydac/netbeans-mmd-plugin

@Override
@Nullable
public Rectangle getClipBounds() {
 return this.context.getClipBounds();
}

代码示例来源:origin: undera/jmeter-plugins

private void paintAd(Graphics2D g) {
  Font oldFont = g.getFont();
  g.setFont(g.getFont().deriveFont(10F));
  g.setColor(axisColor);
  Composite oldComposite = g.getComposite();
  g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
  g.drawString(AD_TEXT,
      g.getClipBounds().width - g.getFontMetrics().stringWidth(AD_TEXT) - spacing,
      g.getFontMetrics().getHeight() - spacing + 1);
  g.setComposite(oldComposite);
  g.setFont(oldFont);
}

代码示例来源:origin: kg.apc/jmeter-plugins-cmn-jmeter

private void paintAd(Graphics2D g) {
  Font oldFont = g.getFont();
  g.setFont(g.getFont().deriveFont(10F));
  g.setColor(axisColor);
  Composite oldComposite = g.getComposite();
  g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
  g.drawString(AD_TEXT,
      g.getClipBounds().width - g.getFontMetrics().stringWidth(AD_TEXT) - spacing,
      g.getFontMetrics().getHeight() - spacing + 1);
  g.setComposite(oldComposite);
  g.setFont(oldFont);
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public void draw(Graphics2D g) {
  Rectangle2D clipBounds = g.getClipBounds();
  if (clipBounds != null) {
    Collection<Figure> c = quadTree.findIntersects(clipBounds);
    Collection<Figure> toDraw = sort(c);
    draw(g, toDraw);
  } else {
    draw(g, children);
  }
}

相关文章

Graphics2D类方法