当前位置: 首页>>代码示例>>Java>>正文


Java Graphics.drawRoundRect方法代码示例

本文整理汇总了Java中java.awt.Graphics.drawRoundRect方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.drawRoundRect方法的具体用法?Java Graphics.drawRoundRect怎么用?Java Graphics.drawRoundRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Graphics的用法示例。


在下文中一共展示了Graphics.drawRoundRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawOverflowIndicator

import java.awt.Graphics; //导入方法依赖的package包/类
/**
 * Draws indicator in case the expression text overflows on the y axis.
 *
 * @param g
 *            the graphics context to draw upon
 * @param maxX
 *            maximal width
 */
private void drawOverflowIndicator(final Graphics g, int maxX) {

	int width = 25;
	int height = 10;
	int xOffset = 10;
	int stepSize = width / 5;
	int dotSize = 3;
	int x = maxX - width - xOffset;
	int y = button.getSize().height - height;
	g.setColor(LIGHTER_GRAY);

	g.fillRect(x, y, width, width);

	g.setColor(Color.GRAY);
	g.drawRoundRect(x, y, width, width, 5, 5);

	g.setColor(Color.BLACK);
	g.fillOval(x + stepSize, y + 4, dotSize, dotSize);
	g.fillOval(x + stepSize * 2, y + 4, dotSize, dotSize);
	g.fillOval(x + stepSize * 3, y + 4, dotSize, dotSize);

	g.dispose();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:32,代码来源:ExpressionValueCellEditor.java

示例2: 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);
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:26,代码来源:LinesRectsOvalsJPanel.java

示例3: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
/**
 * Overrides the super method to set the stroke first.
 * @param c the component for which this border is being painted
 * @param g the paint graphics
 * @param x the x position of the painted border
 * @param y the y position of the painted border
 * @param width the width of the painted border
 * @param height the height of the painted border
 */
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width,
        int height) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setStroke(this.stroke);

    Color oldColor = g.getColor();
    int i = this.thickness / 2;
    g.setColor(this.lineColor);
    if (!this.roundedCorners) {
        g.drawRect(x + i, y + i, width - i - i - 1, height - i - i - 1);
    } else {
        g.drawRoundRect(x + i, y + i, width - i - i - 1,
            height - i - i - 1, this.thickness, this.thickness);
    }
    g.setColor(oldColor);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:27,代码来源:StrokedLineBorder.java

示例4: 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);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:26,代码来源:NotGate.java

示例5: drawRoundRect

import java.awt.Graphics; //导入方法依赖的package包/类
/**
 * 绘制圆形
 */
private void drawRoundRect(Point st, Point ed, Color c, Graphics g) {
    g.setColor(c);
    int w = Math.abs(st.x - ed.x);
    int h = Math.abs(st.y - ed.y);
    g.drawRoundRect(Math.min(st.x, ed.x), Math.min(st.y, ed.y), w, h, w, h);
}
 
开发者ID:ajtdnyy,项目名称:ScreenCut,代码行数:10,代码来源:ScreenCut.java

示例6: 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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:8,代码来源:ColorIcon.java

示例7: 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);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:47,代码来源:FastGraph.java

示例8: paintInstance

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
	Bounds bds = painter.getBounds();
	int x = bds.getX() + 30;
	int y = bds.getY() + 15;

	Graphics g = painter.getGraphics();
	painter.drawRoundBounds(Color.WHITE);
	g.drawRoundRect(x - 27, y - 12, 24, 24, 5, 5);
	drawBall(g, x - 15, y, painter.getAttributeValue(Io.ATTR_COLOR), painter.shouldDrawColor());
	painter.drawPorts();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:13,代码来源:Joystick.java

示例9: paintGhost

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintGhost(InstancePainter painter) {
	Bounds bds = painter.getBounds();
	int x = bds.getX();
	int y = bds.getY();
	Graphics g = painter.getGraphics();
	GraphicsUtil.switchToWidth(g, 2);
	g.drawRoundRect(x, y, 30, 30, 8, 8);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:10,代码来源:Joystick.java

示例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);
	g.fillRoundRect(x + 2, y + 2, width - 3, height - 3, 1, 1);
}
 
开发者ID:equella,项目名称:Equella,代码行数:8,代码来源:FlatterIcons.java

示例11: drawGhost

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void drawGhost(ComponentDrawContext context, Color color, int x, int y, AttributeSet attrs) {
	Graphics g = context.getGraphics();
	Bounds bds = getOffsetBounds(attrs);
	g.setColor(color);
	GraphicsUtil.switchToWidth(g, 2);
	g.drawRoundRect(x + bds.getX(), y + bds.getY(), bds.getWidth(), bds.getHeight(), 10, 10);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:9,代码来源:AbstractComponentFactory.java

示例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);
}
 
开发者ID:cccssw,项目名称:enigma-vk,代码行数:15,代码来源:BoxHighlightPainter.java

示例13: paintGhost

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintGhost(InstancePainter painter) {
	Graphics g = painter.getGraphics();
	GraphicsUtil.switchToWidth(g, 2);
	Bounds bds = painter.getBounds();
	g.drawRoundRect(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight(), 10, 10);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:8,代码来源:Tty.java

示例14: paint

import java.awt.Graphics; //导入方法依赖的package包/类
/**
 * 
 */
public void paint(Graphics g) {
  if (first != null && current != null) {
    ((Graphics2D) g).setStroke(new BasicStroke(lineWidth));
    g.setColor(lineColor);
    Rectangle rect = current.getRectangle();

    if (rounded) {
      g.drawRoundRect(rect.x, rect.y, rect.width, rect.height, 8, 8);
    } else {
      g.drawRect(rect.x, rect.y, rect.width, rect.height);
    }
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:17,代码来源:mxInsertHandler.java

示例15: paintGhost

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintGhost(InstancePainter painter) {
	Bounds bds = painter.getBounds();
	Graphics g = painter.getGraphics();
	GraphicsUtil.switchToWidth(g, 2);
	g.drawRoundRect(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight(), border, border);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:8,代码来源:DigitalOscilloscope.java


注:本文中的java.awt.Graphics.drawRoundRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。