本文整理了Java中java.awt.Graphics2D.fillRoundRect()
方法的一些代码示例,展示了Graphics2D.fillRoundRect()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics2D.fillRoundRect()
方法的具体详情如下:
包路径:java.awt.Graphics2D
类名称:Graphics2D
方法名:fillRoundRect
暂无
代码示例来源:origin: pentaho/pentaho-kettle
public void fillRoundRectangle( int x, int y, int width, int height, int circleWidth, int circleHeight ) {
switchForegroundBackgroundColors();
gc.fillRoundRect( x + xOffset, y + yOffset, width, height, circleWidth, circleHeight );
switchForegroundBackgroundColors();
}
代码示例来源:origin: pentaho/pentaho-kettle
public void fillRoundRectangle( int x, int y, int width, int height, int circleWidth, int circleHeight ) {
switchForegroundBackgroundColors();
gc.fillRoundRect( x + xOffset, y + yOffset, width, height, circleWidth, circleHeight );
switchForegroundBackgroundColors();
}
代码示例来源:origin: bonnyfone/vectalign
graphics.fillRoundRect(
graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, arcs.width, arcs.height);
graphics.setColor(getForeground());
graphics.setStroke(new BasicStroke(strokeSize));
代码示例来源:origin: sarxos/webcam-capture
g2.fillRoundRect(cx, cy, 70, 40, 10, 10);
g2.setColor(Color.WHITE);
g2.fillOval(cx + 5, cy + 5, 30, 30);
g2.setColor(Color.WHITE);
g2.fillOval(cx + 12, cy + 12, 16, 16);
g2.fillRoundRect(cx + 50, cy + 5, 15, 10, 5, 5);
g2.fillRect(cx + 63, cy + 25, 7, 2);
g2.fillRect(cx + 63, cy + 28, 7, 2);
代码示例来源:origin: jphp-group/jphp
@Signature
public void roundRect(int x, int y, int width, int height, int arcWidth, int arcHeight, DrawOptions options) {
applyOptions(options);
if (options.isOutline()) {
gc.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
} else {
gc.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
}
}
代码示例来源: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 void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
{
groupG2D.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
alphaG2D.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
}
代码示例来源:origin: geotools/geotools
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
delegate.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
}
代码示例来源:origin: tomighty/tomighty
private void paintButton(Graphics g, Dimension size, Color startColor, Color endColor) {
Graphics2D g2d = createGraphics(g);
try {
g2d.setPaint(new GradientPaint(0, 0, startColor, 0, size.height, endColor));
g2d.fillRoundRect(0, 0, size.width-1, size.height-1, 9, 9);
} finally {
g2d.dispose();
}
}
代码示例来源:origin: nodebox/nodebox
private static void paintTooltip(Graphics2D g, Point2D point, String text) {
FontMetrics fontMetrics = g.getFontMetrics();
int textWidth = fontMetrics.stringWidth(text);
int verticalOffset = 10;
Rectangle r = new Rectangle((int) point.getX(), (int) point.getY() + verticalOffset, textWidth, fontMetrics.getHeight());
r.grow(4, 3);
g.setColor(TOOLTIP_STROKE_COLOR);
g.drawRoundRect(r.x, r.y, r.width, r.height, 8, 8);
g.setColor(TOOLTIP_BACKGROUND_COLOR);
g.fillRoundRect(r.x, r.y, r.width, r.height, 8, 8);
g.setColor(TOOLTIP_TEXT_COLOR);
g.drawString(text, (float) point.getX(), (float) point.getY() + fontMetrics.getAscent() + verticalOffset);
}
代码示例来源:origin: nodebox/nodebox
private static void drawColor(Graphics2D g, Color c, int x, int y) {
g.setColor(java.awt.Color.WHITE);
g.fillRoundRect(x, y, COLOR_SIZE + 6, COLOR_SIZE + 6, 3, 3);
g.setColor(java.awt.Color.LIGHT_GRAY);
g.drawRoundRect(x, y, COLOR_SIZE + 6, COLOR_SIZE + 6, 3, 3);
g.setColor(c.getAwtColor());
g.fillRect(x + 3, y + 3, COLOR_SIZE, COLOR_SIZE);
}
代码示例来源:origin: stackoverflow.com
JPanel p = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Dimension arcs = new Dimension(15,15); //Border corners arcs {width,height}, change this to whatever you want
int width = getWidth();
int height = getHeight();
Graphics2D graphics = (Graphics2D) g;
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
//Draws the rounded panel with borders.
graphics.setColor(getBackground());
graphics.fillRoundRect(0, 0, width-1, height-1, arcs.width, arcs.height);//paint background
graphics.setColor(getForeground());
graphics.drawRoundRect(0, 0, width-1, height-1, arcs.width, arcs.height);//paint border
}
};
代码示例来源:origin: geotools/geotools
/**
* Icon for generic Geometry or Geometry Collection.
*
* @param color
* @param fill
* @return Icon
*/
public static BufferedImage geometry(final Color color, final Color fill) {
BufferedImage bi =
new BufferedImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, BufferedImage.TYPE_INT_ARGB);
Graphics2D gc = (Graphics2D) bi.getGraphics();
gc.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Stroke stroke = new BasicStroke(1);
gc.setStroke(stroke);
Color c = color;
Color f = fill;
if (c == null) c = Color.BLACK;
if (f == null) f = Color.LIGHT_GRAY;
gc.setColor(f);
gc.fillRoundRect(2, 1, 13, 13, 2, 2);
gc.setColor(c);
gc.drawRoundRect(2, 1, 13, 13, 2, 2);
return bi;
}
代码示例来源:origin: tomighty/tomighty
private void paintButton(Graphics g, Dimension size, Range<Color> grandientColors) {
Graphics2D g2d = createGraphics(g);
try {
g2d.setPaint(new GradientPaint(0, 0, grandientColors.start(), 0, size.height, grandientColors.end()));
g2d.fillRoundRect(0, 0, size.width-1, size.height-1, Border.RADIUS, Border.RADIUS);
} finally {
g2d.dispose();
}
}
代码示例来源:origin: magefree/mage
private static BufferedImage createShadowImage(ShadowKey key) {
int w = key.width;
int h = key.height;
int arc = 10;
int shadowSize = 50;
BufferedImage base = GraphicsUtilities.createCompatibleTranslucentImage(w, h);
Graphics2D g2 = base.createGraphics();
g2.setColor(Color.WHITE);
g2.fillRoundRect(0, 0, w, h, arc, arc);
g2.dispose();
ShadowRenderer renderer = new ShadowRenderer(shadowSize, 0.5f,
Color.GRAY);
return renderer.createShadow(base);
}
代码示例来源:origin: vsch/flexmark-java
g2.fillRoundRect(outerBorderWidth, outerBorderWidth, imgW - 2 * outerBorderWidth, imgH - 2 * outerBorderWidth, outerCornerRadius, outerCornerRadius);
} else {
g2.fillRect(outerBorderWidth, outerBorderWidth, imgW - 2 * outerBorderWidth, imgH - 2 * outerBorderWidth);
代码示例来源:origin: magefree/mage
g.fillRoundRect(0, 0, cardWidth, cardHeight, cornerRadius, cornerRadius);
代码示例来源:origin: stackoverflow.com
JFrame f = new JFrame();
f.setLayout(null);
f.setDefaultCloseOperation(3);
f.setSize(500, 500);
JPanel p = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Dimension arcs = new Dimension(15,15);
int width = getWidth();
int height = getHeight();
Graphics2D graphics = (Graphics2D) g;
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
//Draws the rounded opaque panel with borders.
graphics.setColor(getBackground());
graphics.fillRoundRect(0, 0, width-1, height-1, arcs.width, arcs.height);//paint background
graphics.setColor(getForeground());
graphics.drawRoundRect(0, 0, width-1, height-1, arcs.width, arcs.height);//paint border
}
};
p.setBounds(10,10,100,30);
p.setOpaque(false);
f.getContentPane().setBackground(Color.red);
f.add(p);
f.show();
代码示例来源:origin: magefree/mage
g2.fillRoundRect(x, y, w, h, arc, arc);
代码示例来源:origin: winder/Universal-G-Code-Sender
@Override
protected void paintComponent(Graphics gfx) {
super.paintComponent(gfx);
Dimension arcs = new Dimension(radius, radius);
Graphics2D gfx2d = (Graphics2D) gfx;
gfx2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
gfx2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
// background
Color background = getBackground();
if (!isEnabled() && backgroundDisabled != null) {
background = backgroundDisabled;
} else if (mousePressed && pressedBackground != null && isEnabled()) {
background = pressedBackground;
} else if (mouseOver && hoverBackground != null && isEnabled()) {
background = hoverBackground;
}
Color foreground = getForeground();
if (!isEnabled() && foregroundDisabled != null) {
foreground = foregroundDisabled;
}
gfx2d.setColor(background);
gfx2d.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arcs.width, arcs.height);
// border
gfx2d.setColor(foreground);
gfx2d.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arcs.width, arcs.height);
}
内容来源于网络,如有侵权,请联系作者删除!