本文整理汇总了Java中java.awt.Graphics.clipRect方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.clipRect方法的具体用法?Java Graphics.clipRect怎么用?Java Graphics.clipRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Graphics
的用法示例。
在下文中一共展示了Graphics.clipRect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintConstraints
import java.awt.Graphics; //导入方法依赖的package包/类
/**
* Paints additional information about component constraints.
*
* @param g graphics to use for painting.
*/
private void paintConstraints(Graphics g) {
Point shift = fromComponentPane(new Point());
Graphics gClip = g.create();
Rectangle paneRect = fromComponentPane(new Rectangle(new Point(), componentPane.getSize()));
gClip.clipRect(paneRect.x, paneRect.y, paneRect.width, paneRect.height);
gClip.translate(shift.x, shift.y);
for (Component comp : componentPane.getComponents()) {
if (GridUtils.isPaddingComponent(comp)) {
continue;
}
boolean selected = selection.contains(comp);
gridInfo.paintConstraints(gClip, comp, selected);
}
gClip.dispose();
}
示例2: paintBackground
import java.awt.Graphics; //导入方法依赖的package包/类
/**
*
*/
protected void paintBackground(Graphics g)
{
Rectangle clip = g.getClipBounds();
Rectangle rect = paintBackgroundPage(g);
if (isPageVisible())
{
g.clipRect(rect.x + 1, rect.y + 1, rect.width - 1, rect.height - 1);
}
// Paints the clipped background image
paintBackgroundImage(g);
// Paints the grid directly onto the graphics
paintGrid(g);
g.setClip(clip);
}
示例3: paintBackground
import java.awt.Graphics; //导入方法依赖的package包/类
/**
*
*/
protected void paintBackground(Graphics g) {
Rectangle clip = g.getClipBounds();
Rectangle rect = paintBackgroundPage(g);
if (isPageVisible()) {
g.clipRect(rect.x + 1, rect.y + 1, rect.width - 1, rect.height - 1);
}
// Paints the clipped background image
paintBackgroundImage(g);
// Paints the grid directly onto the graphics
paintGrid(g);
g.setClip(clip);
}
示例4: renderFirstChar
import java.awt.Graphics; //导入方法依赖的package包/类
private static BufferedImage renderFirstChar(String s) {
BufferedImage image = new BufferedImage(IMAGE_WIDTH, IMAGE_HEIGHT, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
g.setColor(Color.black);
g.setFont(FONT);
FontMetrics metrics = g.getFontMetrics();
g.clipRect(0, 0, metrics.charWidth(s.charAt(0)), IMAGE_HEIGHT);
g.drawString(s, 0, metrics.getAscent());
g.dispose();
return image;
}
示例5: paint
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paint(Graphics g) {
super.paint(g);
//Color bkp = g.getColor();
Rectangle r = this.getBounds();
g.setColor(Color.BLACK);
int re = 0;
String bonito = "?";
if (getAcaoTipo() == TipoDeAcao.tpAcaoDlgCor || getAcaoTipo() == TipoDeAcao.tpReadOnlyCor) {
g.setColor(Color.BLACK);
g.fillRect(3, 3, r.height - 7, r.height - 7);
try {
Color c = util.Utilidades.StringToColor(getTexto());
g.setColor(c);
bonito = getTexto();
} catch (Exception e) {
}
g.fillRect(4, 4, r.height - 8, r.height - 8);
//g.setColor(Color.BLACK);
//g.drawRect(3, 3, r.height - 7, r.height - 7);
re = r.height - 1;
} else {
bonito = getTexto().replaceAll("\n", " | ");
}
//g.setColor(bkp);
Rectangle obkp = g.getClipBounds();
g.setColor(Color.DARK_GRAY);
g.setFont(new Font(this.getFont().getFontName(), Font.BOLD, getFont().getSize()));
g.clipRect(re, 0, r.width - r.height -re - (re == 0? 4: 8), r.height);
g.drawString(bonito, re + 2, (int) (r.height * 0.72) + 1);
g.drawLine(0, 0, 0, getHeight());
g.setClip(obkp);
}
示例6: paintComponent
import java.awt.Graphics; //导入方法依赖的package包/类
/**
* Paints the component.
*/
@Override protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
int width = getWidth();
int height = getHeight();
if (width - BORDER_W > 0 && height - BORDER_H > 0) {
startTimerIfNecessary();
updateCacheIfNecessary(width, height);
paintCachedBackground(g2, width, height);
g.translate(1, 2);
if (containsMouse) {
g.clipRect(1, 0, width - 4, height - 4);
}
else {
g.clipRect(0, 0, width - 2, height - 4);
}
int innerW = width - BORDER_W;
int innerH = height - BORDER_H;
if (heapGrowTimer != null) {
// Render the heap growing animation.
Composite lastComposite = ((Graphics2D)g).getComposite();
float percent = 1f - heapGrowTimer.getPercent();
((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, percent));
g.drawImage(heapGrowTimer.image, 0, 0, null);
((Graphics2D)g).setComposite(lastComposite);
}
paintTicks(g2, innerW, innerH);
if (getTickStyle() == STYLE_OVERLAY) {
g2.drawImage(getGridOverlayImage(), 0, 0, null);
}
if (getShowText()) {
if (getShowDropShadow()) {
paintDropShadowText(g, innerW, innerH);
} else {
g.setColor(textColor);
paintText(g, innerW, innerH);
}
}
g.translate(-1, -2);
} else {
stopTimerIfNecessary();
// To honor opaque contract, fill in the background
g.setColor(getBackground());
g.fillRect(0, 0, width, height);
}
}