本文整理汇总了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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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: 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);
}
示例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);
}
}
}
示例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);
}