本文整理汇总了Java中java.awt.Graphics.fillRoundRect方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.fillRoundRect方法的具体用法?Java Graphics.fillRoundRect怎么用?Java Graphics.fillRoundRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Graphics
的用法示例。
在下文中一共展示了Graphics.fillRoundRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintScore
import java.awt.Graphics; //导入方法依赖的package包/类
/**画分数等显示信息*/
public void paintScore(Graphics g) {
g.setColor(new Color(227, 179, 155));
//画当前分数框
g.fillRoundRect(180, 3, 110, 70, 11, 11);
//画最高分框
g.fillRoundRect(310, 3, 110, 70, 11, 11);
g.setColor(new Color(239, 198, 0));
//画图标
g.fillRoundRect(25, 3, 130, 120, 12, 12);
g.setColor(Color.white);
g.setFont(new Font("微软雅黑",Font.PLAIN,20));
g.drawString("当前分数", 195, 30);
g.drawString(""+score, 200, 57);
g.drawString("最高分", 335, 30);
g.drawString(""+mostScore, 335, 57);
g.setFont(new Font("Impact",Font.PLAIN,48));
g.drawString("2048", 40, 50);
g.setFont(new Font("Impact",Font.BOLD,36));
g.drawString("4 * 4", 50, 90);
}
示例2: paint
import java.awt.Graphics; //导入方法依赖的package包/类
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.blue);
g.setFont(new Font("宋体", Font.BOLD, 20));
g.drawRect(100, 300, 150, 100);
g.drawRoundRect(300, 200, 200, 200, 200, 200);
/*
* x - 要绘制矩形的 x 坐标。 y - 要绘制矩形的 y 坐标。 width - 要绘制矩形的宽度。 height -
* 要绘制矩形的高度。 arcWidth - 4 个角弧度的水平直径。 arcHeight - 4 个角弧度的垂直直径。
*/
g.setColor(Color.red);
g.fillRect(100, 100, 100, 100);
g.setColor(Color.green);
g.fillOval(200, 100, 150, 150);
// 填充夜色 圆形填充
g.fill3DRect(150, 450, 50, 50, false);
g.fillArc(200, 450, 50, 50, 50, 50);
g.fillRect(250, 450, 50, 50);
g.fillRoundRect(300, 450, 50, 50, 50, 50);
g.drawString("如果", 400, 150);
}
示例3: paintComponent
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintComponent(Graphics g)
{
super.paintComponent(g);
this.setBackground(Color.WHITE);
g.setColor(Color.RED);
g.drawLine(5, 30, 380, 30);
g.setColor(Color.BLUE);
g.drawRect(5, 40, 90, 55);
g.fillRect(100, 40, 90, 55);
g.setColor(Color.BLACK);
g.fillRoundRect(195, 40, 90, 55, 50, 50);
g.drawRoundRect(290, 40, 90, 55, 20, 20);
g.setColor(Color.GREEN);
g.draw3DRect(5, 100, 90, 55, true);
g.fill3DRect(100, 100, 90, 55, false);
g.setColor(Color.MAGENTA);
g.drawOval(195, 100, 90, 55);
g.fillOval(290, 100, 90, 55);
}
示例4: paintBG
import java.awt.Graphics; //导入方法依赖的package包/类
/**画背景*/
public void paintBG(Graphics g) {
g.setColor(new Color(181, 170 ,156));
//画提示下一个下落的方格背景
g.fillRect(193, 63, 59, 59);
//画当前分数框
g.fillRoundRect(30, 5, 110, 70, 11, 11);
//画最高分框
g.fillRoundRect(310, 5, 110, 70, 11, 11);
g.setColor(new Color(247, 247, 247));
g.setFont(new Font("微软雅黑", Font.PLAIN, 17));
g.drawString("当前分数", 49, 30);
g.drawString("" + nowScore, 53, 57);
g.drawString("最高分", 339, 30);
g.drawString("" + topScore, 339, 57);
//画游戏框的背景
g.setColor(new Color(181, 170 ,156));
g.fillRect(41, 140, 361, 481);
//画小方格的背景
g.setColor(new Color(206, 190, 181));
for(int i = 0; i<8; i++) {
for(int j = 0; j<6; j++) {
g.fillRect(42+j*60, 141+i*60, Cell.SIZE, Cell.SIZE);
}
}
}
示例5: paintRectangularBase
import java.awt.Graphics; //导入方法依赖的package包/类
private void paintRectangularBase(Graphics g, InstancePainter painter) {
GraphicsUtil.switchToWidth(g, 2);
if (painter.getAttributeValue(ATTR_SIZE) == SIZE_NARROW) {
if (AppPreferences.FILL_COMPONENT_BACKGROUND.getBoolean()) {
g.setColor(Color.WHITE);
g.fillRoundRect(-20, -9, 14, 18, 5, 5);
g.fillOval(-6, -3, 6, 6);
g.setColor(Color.BLACK);
}
g.drawRoundRect(-20, -9, 14, 18, 5, 5);
GraphicsUtil.drawCenteredText(g, RECT_LABEL, -13, -2);
g.drawOval(-6, -3, 6, 6);
} else {
if (AppPreferences.FILL_COMPONENT_BACKGROUND.getBoolean()) {
g.setColor(Color.WHITE);
g.fillRoundRect(-30, -9, 20, 18, 10, 10);
g.fillOval(-10, -5, 9, 9);
g.setColor(Color.BLACK);
}
g.drawRoundRect(-30, -9, 20, 18, 10, 10);
GraphicsUtil.drawCenteredText(g, RECT_LABEL, -20, -2);
g.drawOval(-10, -5, 9, 9);
}
GraphicsUtil.switchToWidth(g, 1);
}
示例6: paintInstance
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
Bounds bds = painter.getOffsetBounds();
BitWidth width = painter.getAttributeValue(StdAttr.WIDTH);
int intValue = painter.getAttributeValue(ATTR_VALUE).intValue();
Value v = Value.createKnown(width, intValue);
Location loc = painter.getLocation();
int x = loc.getX();
int y = loc.getY();
Graphics g = painter.getGraphics();
if (painter.shouldDrawColor()) {
g.setColor(BACKGROUND_COLOR);
g.fillRoundRect(x + bds.getX(), y + bds.getY(), bds.getWidth(), bds.getHeight(), 3, 3);
}
if (v.getWidth() == 1) {
if (painter.shouldDrawColor())
g.setColor(v.getColor());
GraphicsUtil.drawCenteredText(g, v.toString(), x + bds.getX() + bds.getWidth() / 2,
y + bds.getY() + bds.getHeight() / 2 - 2);
} else {
g.setColor(Color.BLACK);
GraphicsUtil.drawCenteredText(g, v.toHexString(), x + bds.getX() + bds.getWidth() / 2,
y + bds.getY() + bds.getHeight() / 2 - 2);
}
painter.drawPorts();
}
示例7: paintIcon
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(color);
g.fillRoundRect(x, y, getIconWidth() - 1, getIconHeight(), 2, 2);
g.setColor(borderColor);
g.drawRoundRect(x, y, getIconWidth() - 1, getIconHeight(), 2, 2);
}
示例8: paintSelectedValue
import java.awt.Graphics; //导入方法依赖的package包/类
/**
* Draws the selected value
* @param selectedValue the selected value to draw
* @param g the graphics object
* @param width the total chart width
* @param height the total chart height
* @param maxx the maximum X value (simulation time)
* @param maxy the maximum Y value
*/
private void paintSelectedValue(MeasureValue selectedValue, Graphics g, int width, int height, double maxx, double maxy) {
FontMetrics metric = g.getFontMetrics();
String x_str = simulationTimeFormat.format(selectedValue.getSimTime());
String m_str = formatNumber(selectedValue.getMeanValue());
String i_str = formatNumber(selectedValue.getLastIntervalAvgValue());
Dimension bounds = composeVerticalBounds(g, metric, POPUP_FULL_X_PREFIX + x_str, POPUP_FULL_X_PREFIX + m_str, POPUP_FULL_X_PREFIX + i_str);
int selectedValueX = getX(selectedValue.getSimTime());
int textX = (int)(selectedValueX - bounds.getWidth() / 2);
// Fix value out of chart for label
if (textX < 2) {
textX = 2;
} else if (textX + bounds.getWidth() + POPUP_MARGIN > width) {
textX = width - (int)bounds.getWidth() - POPUP_MARGIN;
}
int textY = getY(maxy / 2) + (int)bounds.getHeight() / 2;
g.setColor(COLOR_POPUP);
g.drawLine(selectedValueX, getY(0), selectedValueX, getY(selectedValue.getLastIntervalAvgValue()));
g.setColor(COLOR_POPUP_BG);
g.fillRoundRect(textX - POPUP_MARGIN, textY - (int)bounds.getHeight(), (int)bounds.getWidth() + POPUP_MARGIN * 2, (int)bounds.getHeight() + POPUP_MARGIN, 4, 4);
g.setColor(COLOR_POPUP);
g.drawRoundRect(textX - POPUP_MARGIN, textY - (int)bounds.getHeight(), (int)bounds.getWidth() + POPUP_MARGIN * 2, (int)bounds.getHeight() + POPUP_MARGIN, 4, 4);
// Draw squares
Rectangle2D prefixBounds = metric.getStringBounds(POPUP_X_PREFIX, g);
g.setColor(COLOR_DRAW);
g.fillRect(textX, textY - (int)prefixBounds.getHeight() - bounds.height / 3, (int)prefixBounds.getWidth(), (int)prefixBounds.getHeight());
g.setColor(COLOR_LAST_INTERVAL);
g.fillRect(textX, textY - (int)prefixBounds.getHeight(), (int)prefixBounds.getWidth(), (int)prefixBounds.getHeight());
// Draws texts
g.setColor(COLOR_AXIS);
g.drawString(POPUP_FULL_X_PREFIX + x_str, textX, textY - bounds.height * 2 / 3);
g.drawString(POPUP_MIDDLE + m_str, textX + (int)prefixBounds.getWidth(), textY - bounds.height / 3);
g.drawString(POPUP_MIDDLE + i_str, textX + (int)prefixBounds.getWidth(), textY);
}
示例9: paintBackground
import java.awt.Graphics; //导入方法依赖的package包/类
private void paintBackground (final Graphics g, final JComponent c) {
Dimension size = c.getSize();
Graphics2D g2 = (Graphics2D) g;
g2.addRenderingHints (new RenderingHints (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
g.setColor (c.getBackground ());
g.fillRoundRect (0, 0, size.width, size.height, 7, 7);//button
}
示例10: paintIcon
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(Component c, Graphics g, int x, int y)
{
setColor(c, g);
g.drawRoundRect(x, y, width, height, 2, 2);
if( ((AbstractButton) c).getModel().isSelected() )
{
g.fillRoundRect(x + 2, y + 2, width - 3, height - 3, 1, 1);
}
}
示例11: paintIcon
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(java.awt.Component c, Graphics g, int x, int y) {
// draw halo if appropriate
if (tool == haloedTool && AppPreferences.ATTRIBUTE_HALO.getBoolean()) {
g.setColor(Canvas.HALO_COLOR);
g.fillRoundRect(x, y, getIconWidth(), getIconHeight(), 5, 5);
g.setColor(Color.BLACK);
}
// draw tool icon
Graphics gIcon = g.create();
ComponentDrawContext context = new ComponentDrawContext(ProjectExplorer.this, null, null, g, gIcon);
tool.paintIcon(context, x, y);
gIcon.dispose();
// draw magnifying glass if appropriate
if (circ == proj.getCurrentCircuit()) {
int tx = x + 13;
int ty = y + 13;
int[] xp = { tx - 1, x + 18, x + 20, tx + 1 };
int[] yp = { ty + 1, y + 20, y + 18, ty - 1 };
g.setColor(MAGNIFYING_INTERIOR);
g.fillOval(x + 5, y + 5, 10, 10);
g.setColor(Color.darkGray);
g.drawOval(x + 5, y + 5, 10, 10);
g.fillPolygon(xp, yp, xp.length);
}
}
示例12: paint
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paint(Graphics g, int start, int end, Shape shape, JTextComponent text) {
Rectangle bounds = getBounds(text, start, end);
// fill the area
if (m_fillColor != null) {
g.setColor(m_fillColor);
g.fillRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 4, 4);
}
// draw a box around the area
g.setColor(m_borderColor);
g.drawRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 4, 4);
}
示例13: paintCellArea
import java.awt.Graphics; //导入方法依赖的package包/类
/**画方格区的背景*/
public void paintCellArea(Graphics g) {
//设置背景方格框颜色
g.setColor(new Color(227, 179, 155));
//画背景方格框
g.fillRect(11, 138, PANEL_WIDTH, PANEL_HEIGHT);
//设置背景小方格颜色
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 4; j++) {
g.setColor(new Color(243,223,214));
//画小方格背景
if(number[i][j]!=0){
cell= new Cell(number[i][j]);
g.setColor(cell.getColor());
g.fillRoundRect(15+i*105, 142+j*105, CELL_WIDTH, CELL_HEIGHT, 10, 10);
String str = "" + number[i][j];
g.setColor(Color.BLACK);
//数字大小
g.setFont(new Font("华文新魏", Font.PLAIN, 30));
int l = str.length();
g.drawString(str, 15+i*105+(5-l)*10,142+j*105+60);
}else{
g.fillRoundRect(15+i*105, 142+j*105, CELL_WIDTH, CELL_HEIGHT, 10, 10);
}
}
}
}
示例14: draw
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void draw(Graphics g, int x, int y, int w, int h) {
int diam = 2 * radius;
if (setForFill(g))
g.fillRoundRect(x, y, w, h, diam, diam);
if (setForStroke(g))
g.drawRoundRect(x, y, w, h, diam, diam);
}
示例15: paintIcon
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(InstancePainter painter) {
int w = painter.getAttributeValue(StdAttr.WIDTH).getWidth();
int pinx = 17;
int piny = 8;
Direction dir = painter.getAttributeValue(StdAttr.FACING);
if (dir == Direction.EAST) {
} // keep defaults
else if (dir == Direction.WEST) {
pinx = 0;
} else if (dir == Direction.NORTH) {
pinx = 8;
piny = 2;
} else if (dir == Direction.SOUTH) {
pinx = 8;
piny = 15;
}
Graphics g = painter.getGraphics();
g.setColor(BACKGROUND_COLOR);
g.fillRoundRect(2, 3, 16, 14, 3, 3);
g.setColor(Color.BLACK);
if (w == 1) {
int v = painter.getAttributeValue(ATTR_VALUE).intValue();
Value val = v == 1 ? Value.TRUE : Value.FALSE;
g.setColor(val.getColor());
GraphicsUtil.drawCenteredText(g, "" + v, 11, 8);
} else {
g.setFont(g.getFont().deriveFont(9.0f));
GraphicsUtil.drawCenteredText(g, "x" + w, 11, 8);
}
g.fillOval(pinx, piny, 3, 3);
}