Java Code Examples for java.awt.Graphics.fillRoundRect()

The following are Jave code examples for showing how to use fillRoundRect() of the java.awt.Graphics class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: game2048_tetris   File: ClassicPanel.java   View Source Code Vote up 7 votes
/**画分数等显示信息*/
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);
}
 
Example 2
Project: javase   File: PaintFillColor.java   View Source Code Vote up 6 votes
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);
}
 
Example 3
Project: LivroJavaComoProgramar10Edicao   File: LinesRectsOvalsJPanel.java   View Source Code Vote up 6 votes
@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);
}
 
Example 4
Project: game2048_tetris   File: DropPanel.java   View Source Code Vote up 6 votes
/**画背景*/
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);
		}
	}
}
 
Example 5
Project: Logisim   File: NotGate.java   View Source Code Vote up 6 votes
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);
}
 
Example 6
Project: rapidminer   File: ColorIcon.java   View Source Code Vote up 5 votes
@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);
}
 
Example 7
Project: jmt   File: FastGraph.java   View Source Code Vote up 5 votes
/**
 * 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);
}
 
Example 8
Project: Invasion   File: MaterialButtonUI.java   View Source Code Vote up 5 votes
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
}
 
Example 9
Project: Equella   File: FlatterIcons.java   View Source Code Vote up 5 votes
@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);
	}
}
 
Example 10
Project: Equella   File: FlatterIcons.java   View Source Code Vote up 5 votes
@Override
public void paintIcon(Component c, Graphics g, int x, int y)
{
	setColor(c, g);
	g.drawRoundRect(x, y, width, height, 2, 2);
	g.fillRoundRect(x + 2, y + 2, width - 3, height - 3, 1, 1);
}
 
Example 11
Project: Logisim   File: ProjectExplorer.java   View Source Code Vote up 5 votes
@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);
	}
}
 
Example 12
Project: enigma-vk   File: BoxHighlightPainter.java   View Source Code Vote up 5 votes
@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);
}
 
Example 13
Project: COE1186   File: MaterialButtonUI.java   View Source Code Vote up 5 votes
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
}
 
Example 14
Project: AquamarineLake   File: MaterialButtonUI.java   View Source Code Vote up 5 votes
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
}
 
Example 15
Project: game2048_tetris   File: ClassicPanel.java   View Source Code Vote up 5 votes
/**画方格区的背景*/
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);
				}
				
			}
		}
	
}
 
Example 16
Project: Logisim   File: RoundRectangle.java   View Source Code Vote up 5 votes
@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);
}
 
Example 17
Project: COE1186   File: MaterialButtonUI.java   View Source Code Vote up 5 votes
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
}
 
Example 18
Project: Logisim   File: Constant.java   View Source Code Vote up 5 votes
@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);
}
 
Example 19
Project: Logisim   File: Constant.java   View Source Code Vote up 5 votes
@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();
}
 
Example 20
Project: VASSAL-src   File: ShapeItem.java   View Source Code Vote up 4 votes
public void draw(Graphics g, GamePieceImage defn) {

    ShapeItemInstance si = null;
    if (defn != null) {
      si = defn.getShapeInstance(getConfigureName());
    }
    if (si == null) {
      si = new ShapeItemInstance();
    }

    Color fg = si.getFgColor().getColor();
    Color bg = si.getBorderColor().getColor();

    Point origin = layout.getPosition(this);
    Rectangle r = new Rectangle(origin.x, origin.y, getWidth(), getHeight());

    if (isAntialias()) {
      ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
    }
    else {
      ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
    }

    if (fg != null) {
      g.setColor(fg);
      if (shape.equals(RECT)) {
        g.fillRect(r.x, r.y, r.width, r.height);
      }
      else if (shape.equals(RRECT)) {
        g.fillRoundRect(r.x, r.y, r.width, r.height, bevel*2, bevel*2);
      }
      else if (shape.equals(OVAL)) {
        g.fillOval(r.x, r.y, r.width, r.height);
      }
    }

    if (bg != null) {
      g.setColor(bg);
      if (shape.equals(RECT)) {
        g.drawRect(r.x, r.y, r.width, r.height);
      }
      else if (shape.equals(RRECT)) {
        g.drawRoundRect(r.x, r.y, r.width, r.height, bevel*2, bevel*2);
      }
      else if (shape.equals(OVAL)) {
        g.drawOval(r.x, r.y, r.width, r.height);
      }
    }
  }