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


Java Graphics2D.drawRoundRect方法代码示例

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


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

示例1: paintBorder

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the border of the combobox.
 */
private void paintBorder(Graphics g, JComponent c) {
	int w = c.getWidth();
	int h = c.getHeight();
	if (w <= 0 || h <= 0) {
		return;
	}

	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	boolean hasFocus = comboBox.isEditable() ? c.isFocusOwner()
			|| ((JComboBox) c).getEditor().getEditorComponent().isFocusOwner() : c.isFocusOwner();
			if (c.isEnabled()) {
				if (hasFocus) {
					g2.setColor(Colors.COMBOBOX_BORDER_FOCUS);
				} else {
					g2.setColor(Colors.COMBOBOX_BORDER);
				}
			} else {
				g2.setColor(Colors.COMBOBOX_BORDER_DISABLED);
			}

			g2.drawRoundRect(0, 0, w - 1, h - 1, RapidLookAndFeel.CORNER_DEFAULT_RADIUS, RapidLookAndFeel.CORNER_DEFAULT_RADIUS);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:ComboBoxUI.java

示例2: paintBorder

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	g2.translate(x, y);

	if (c.isEnabled()) {
		if (c.isFocusOwner()) {
			g2.setColor(Colors.TEXTFIELD_BORDER_FOCUS);
		} else {
			g2.setColor(Colors.TEXTFIELD_BORDER);
		}
	} else {
		g2.setColor(Colors.TEXTFIELD_BORDER_DISABLED);
	}

	g2.drawRoundRect(0, 0, w - 1, h - 1, RapidLookAndFeel.CORNER_DEFAULT_RADIUS, RapidLookAndFeel.CORNER_DEFAULT_RADIUS);

	g2.translate(-x, -y);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:22,代码来源:TextFieldBorder.java

示例3: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
    int borderWidth = 3;
    int x = borderWidth;
    int y = borderWidth;
    int w = getWidth() - (2 * borderWidth);
    int h = getHeight() - (2 * borderWidth);
    int arc = 30;

    Graphics2D g2 = (Graphics2D) g.create();
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);

    g2.setColor(Color.WHITE);
    g2.fillRoundRect(x, y, w, h, arc, arc);

    g2.setStroke(new BasicStroke(borderWidth));
    g2.setColor(new Color(40, 40, 40));
    g2.drawRoundRect(x, y, w, h, arc, arc);

    g2.dispose();
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:23,代码来源:RoundedJPanel.java

示例4: paintBorder

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the component border.
 *
 * @param graphics
 *            the graphics context
 */
void paintBorder(Graphics graphics) {
	Graphics2D g = (Graphics2D) graphics.create();
	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	g.setColor(Colors.BUTTON_BORDER);

	int radius = RapidLookAndFeel.CORNER_DEFAULT_RADIUS;
	switch (position) {
		case SwingConstants.LEFT:
			g.drawRoundRect(0, 0, button.getWidth() + radius, button.getHeight() - 1, radius, radius);
			break;
		case SwingConstants.CENTER:
			g.drawRect(0, 0, button.getWidth() + radius, button.getHeight() - 1);
			break;
		default:
			g.drawRoundRect(-radius, 0, button.getWidth() + radius - 1, button.getHeight() - 1, radius, radius);
			g.drawLine(0, 0, 0, button.getHeight());
			break;
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:CompositeButtonPainter.java

示例5: highlight

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void highlight(Graphics2D g) {
  Rectangle bounds = g.getClipBounds();
  if (startY > bounds.getMaxY() || startY + height < bounds.getMinY()) {
    return;
  }

  int x = line.getX();
  int width = line.getWidth();

  g.drawRoundRect(x, startY, width, height, ARC_SIZE, ARC_SIZE);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:12,代码来源:LifelineState.java

示例6: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paintComponent(final Graphics g) {
	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	int x = 0;
	int y = 0;
	int width = (int) getSize().getWidth();
	int height = (int) getSize().getHeight();

	// draw background depending special roles and hovering
	g2.setPaint(AttributeGuiTools.getColorForAttributeRole(mapAttributeRoleName(),
			hovered ? ColorScope.HOVER : ColorScope.BACKGROUND));

	g2.fillRoundRect(x, y, width, height, RapidLookAndFeel.CORNER_DEFAULT_RADIUS,
			RapidLookAndFeel.CORNER_DEFAULT_RADIUS);

	// draw background depending special roles and hovering
	g2.setPaint(AttributeGuiTools.getColorForAttributeRole(mapAttributeRoleName(), ColorScope.BORDER));
	if (hovered) {
		g2.setStroke(new BasicStroke(1.0f));
	} else {
		g2.setStroke(new BasicStroke(0.5f));
	}
	g2.drawRoundRect(x, y, width - 1, height - 1, RapidLookAndFeel.CORNER_DEFAULT_RADIUS,
			RapidLookAndFeel.CORNER_DEFAULT_RADIUS);

	// let Swing draw its components
	super.paintComponent(g2);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:30,代码来源:AttributeStatisticsPanel.java

示例7: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paint(Graphics g1) 
{
	Graphics2D g = (Graphics2D) g1;
	if (model.isArmed() && model.isPressed())
		g.setColor(colors.pressed);
	else if (model.isRollover())
		g.setColor(colors.hover);
	else
		g.setColor(colors.background);
	
	g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 5, 5);
	g.setColor(Color.BLACK);
	g.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 5, 5);
	
	// cheap way to draw icon/text with nice spacing
	if (currentState < 0)
	{
		stamp.setText("");
		stamp.setIcon(null);
	}
	else
	{
	    stamp.setText(getText() + currentState);
		stamp.setIcon(timerOn);
	}
	
	stamp.setForeground(colors.foreground);
	stamp.setFont(getFont());	
	stamp.setBounds(getBounds());
	stamp.paint(g1);
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:33,代码来源:FocusButton.java

示例8: drawFlagImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void drawFlagImage(Graphics2D g) {
  final int tabHeight = 15;
  final int tabWidth = 10;
  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  g.setColor(background);
  g.fillRoundRect(-tabWidth, 0, 2*tabWidth, tabHeight, 6, 6);
  g.setColor(foreground);
  g.drawRoundRect(-tabWidth, 0, 2*tabWidth-1, tabHeight-1, 6, 6);
  g.setFont(new Font("Dialog", Font.PLAIN, 9));
  Rectangle2D r = g.getFontMetrics().getStringBounds(name, g);
  g.drawString(name, tabWidth/2 - (int) (r.getWidth()/2.0) - 1, 11);
  g.setBackground(new Color(0,0,0,0));
  g.clearRect(-tabWidth, 0, tabWidth, tabHeight);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:16,代码来源:ADC2Module.java

示例9: paintBorder

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    Dimension arcs = new Dimension(40, 40);
    Graphics2D graphics = (Graphics2D) g;
    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    graphics.setColor(new Color(106, 117, 144));
    graphics.fillRoundRect(0, 0, width - 1, height - 1, arcs.width, arcs.height);//paint background

    graphics.setClip(null);
    graphics.drawRoundRect(0, 0, width - 1, height - 1, arcs.width, arcs.height);//paint border
}
 
开发者ID:PanagiotisDrakatos,项目名称:EasyDragDrop,代码行数:13,代码来源:MainFrame.java

示例10: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paintComponent(Graphics g2) {
	Graphics2D g = (Graphics2D) g2;
	
	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	
	int padding = 0;
	int osxBottomFix = System.getProperty("os.name").toLowerCase().contains("mac") ? 3 : 0;
	
	g.setColor(key.getValue());
	g.fillRoundRect(padding, padding, getWidth()-2*padding, getHeight()-2*padding-osxBottomFix, 10, 10);
	g.setColor(key.getValue().darker());
	g.drawRoundRect(padding, padding, getWidth()-2*padding, getHeight()-2*padding-osxBottomFix, 10, 10);
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:15,代码来源:ColorInterpolator.java

示例11: PaintGradiente

import java.awt.Graphics2D; //导入方法依赖的package包/类
protected void PaintGradiente(Graphics2D g, boolean round) {
    int dist = 0;
    int w = getWidth() - dist;
    int h = getHeight() - dist;
    int L = getLeft();
    int T = getTop();
    boolean dv = getGDirecao() == VERTICAL;

    //Composite originalComposite = g.getComposite();
    //g.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OVER, alfa));
    GradientPaint GP = new GradientPaint(L, T, getGradienteStartColor(), dv ? L : L + w, dv ? T + h : T, getGradienteEndColor(), true);
    //g.setPaint(GP);

    g.setPaint(getForeColor());
    if (round) {
        g.drawRoundRect(L, T, w - 1, h - 1, roundRectSize, roundRectSize);
        g.setPaint(GP);
        g.fillRoundRect(L + 1, T + 1, w - 2, h - 2, roundRectSize, roundRectSize);
        g.setPaint(isDisablePainted()? disabledColor : Color.WHITE);
        g.drawRoundRect(L + 1, T + 1, w - 3, h - 3, roundRectSize, roundRectSize);
    } else {
        g.drawRect(L, T, w - 1, h - 1);
        g.setPaint(GP);
        g.fillRect(L + 1, T + 1, w - 2, h - 2);
        g.setPaint(isDisablePainted()? disabledColor : Color.WHITE);
        g.drawRect(L + 1, T + 1, w - 3, h - 3);
    }
    if (isGradientePinteDetalhe()) {
        g.setPaint(getGradienteCorDetalhe());
        GeneralPath path = new GeneralPath();
        path.moveTo(L + 2, T + 2);
        path.quadTo(L + w / 2 + 1, T + h / 2 + 1, L + w - 1, T + 2);
        path.closePath();
        g.fill(path);
    }
    //g.setComposite(originalComposite);

}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:39,代码来源:PreTexto.java

示例12: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void paintComponent(Graphics graphics) 
{
	int h = getHeight();
	int w =  getWidth();
	
	if (h < GRADIENT_EXTENT + 1) 
	{
		super.paintComponent(graphics);
		return;
	}
	
	float percentageOfGradient = (float) GRADIENT_EXTENT / h;
	
	if (percentageOfGradient > 0.49f)
	{
		percentageOfGradient = 0.49f;
	}
	
	Graphics2D graphics2D = (Graphics2D) graphics;
	
	float fractions[] = new float[] 
	{ 
		0, percentageOfGradient, 1 - percentageOfGradient, 1f 
	};
	
	Color colors[] = new Color[] 
	{ 
		colorLow, colorHigh, colorHigh, colorLow 
	};
	
	LinearGradientPaint paint = new LinearGradientPaint(0, 0, 0, h - 1, fractions, colors);
	
	graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	graphics2D.setPaint(paint);
	graphics2D.fillRoundRect(0, 0, w - 1, h - 1, GRADIENT_EXTENT, GRADIENT_EXTENT);
	graphics2D.setColor(colorBorder);
	graphics2D.setStroke(edgeStroke);
	graphics2D.drawRoundRect(0, 0, w - 1, h - 1, GRADIENT_EXTENT, GRADIENT_EXTENT);
}
 
开发者ID:ca333,项目名称:komodoGUI,代码行数:40,代码来源:PresentationPanel.java

示例13: drawCursor

import java.awt.Graphics2D; //导入方法依赖的package包/类
/** dessine un cursseur dont le centre en X est centerX, et le centre en Y est centerY */
protected void drawCursor(final Graphics2D g2, final Color fillColor, final Color drawColor, final int centerX, final int centerY) {
    g2.setColor(fillColor);
    g2.fillRoundRect(centerX - CURSOR_W / 2, centerY - CURSOR_H / 2, CURSOR_W, CURSOR_H, ARC_SIZE, ARC_SIZE);

    g2.setColor(drawColor);
    g2.drawRoundRect(centerX - CURSOR_W / 2, centerY - CURSOR_H / 2, CURSOR_W, CURSOR_H, ARC_SIZE, ARC_SIZE);
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:9,代码来源:AbstractSliderComponent.java

示例14: drawCursor

import java.awt.Graphics2D; //导入方法依赖的package包/类
/** dessine un cursseur dont le centre en X est centerX, et le centre en Y est centerY */
public static void drawCursor(final Graphics2D g, final Color fillColor, final Color drawColor, final int centerX, final int centerY) {
    Graphics2D g2 = (Graphics2D) g.create();
    g2.setColor(fillColor);
    g2.fillRoundRect(centerX - CURSOR_W / 2, centerY - CURSOR_H / 2, CURSOR_W, CURSOR_H, ARC_SIZE, ARC_SIZE);

    g2.setColor(drawColor);
    g2.drawRoundRect(centerX - CURSOR_W / 2, centerY - CURSOR_H / 2, CURSOR_W, CURSOR_H, ARC_SIZE, ARC_SIZE);
    g2.dispose();
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:11,代码来源:AbstractSliderComponentForTimeSlider.java

示例15: paintBorder

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        Graphics2D g2 = (Graphics2D)g;

        g2.setPaint(fillColor);
        // NOTE: fillRoundRect seems to have poor performance on Linux
//            g2.fillRoundRect(x + halfBorderStrokeWidth, y + halfBorderStrokeWidth,
//                             width - borderStrokeWidth, height - borderStrokeWidth,
//                             arcRadius * 2, arcRadius * 2);

        int arcRadius2 = arcRadius * 2;
        int arcRadius2p1 = arcRadius2 + 1;

        g2.fillArc(x, y, arcRadius2, arcRadius2, 90, 90);
        g2.fillArc(x + width - arcRadius2p1, y, arcRadius2, arcRadius2, 0, 90);
        g2.fillArc(x, y + height - arcRadius2p1, arcRadius2, arcRadius2, 180, 90);
        g2.fillArc(x + width - arcRadius2p1, y + height - arcRadius2p1, arcRadius2, arcRadius2, 270, 90);

        g2.fillRect(x + arcRadius, y, width - arcRadius2p1, height);
        g2.fillRect(x, y + arcRadius, arcRadius, height - arcRadius2p1);
        g2.fillRect(x + width - arcRadius - 1, y + arcRadius, arcRadius, height - arcRadius2p1);

        Object aa = null;
        Object sc = null;
        if (!forceSpeed) {
            aa = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
            sc = g2.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
        }

        g2.setStroke(borderStroke);
        g2.setPaint(lineColor);
        g2.drawRoundRect(x + halfBorderStrokeWidth, y + halfBorderStrokeWidth,
                         width - borderStrokeWidth, height - borderStrokeWidth,
                         arcRadius * 2, arcRadius * 2);

        if (!forceSpeed) {
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aa);
            g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, sc);
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:RoundBorder.java


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