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


Java RoundRectangle2D类代码示例

本文整理汇总了Java中java.awt.geom.RoundRectangle2D的典型用法代码示例。如果您正苦于以下问题:Java RoundRectangle2D类的具体用法?Java RoundRectangle2D怎么用?Java RoundRectangle2D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: paintComponent

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
/**
 * Draws the component background.
 *
 * @param g
 *            the graphics context
 */
void paintComponent(Graphics g) {
	RectangularShape rectangle;
	int radius = RapidLookAndFeel.CORNER_DEFAULT_RADIUS;
	switch (position) {
		case SwingConstants.LEFT:
			rectangle = new RoundRectangle2D.Double(0, 0, button.getWidth() + radius, button.getHeight(), radius,
					radius);
			break;
		case SwingConstants.CENTER:
			rectangle = new Rectangle2D.Double(0, 0, button.getWidth(), button.getHeight());
			break;
		default:
			rectangle = new RoundRectangle2D.Double(-radius, 0, button.getWidth() + radius, button.getHeight(), radius,
					radius);
			break;
	}
	RapidLookTools.drawButton(button, g, rectangle);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:25,代码来源:CompositeButtonPainter.java

示例2: paint

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
public void paint (Graphics2D gr, Rectangle bounds) {
    Shape previousClip = gr.getClip ();
    gr.clip (new RoundRectangle2D.Float (bounds.x, bounds.y, bounds.width, bounds.height, 4, 4));

    drawGradient (gr, bounds, color1, color2, 0f, 0.3f);
    drawGradient (gr, bounds, color2, color3, 0.3f, 0.764f);
    drawGradient (gr, bounds, color3, color4, 0.764f, 0.927f);
    drawGradient (gr, bounds, color4, color5, 0.927f, 1f);

    gr.setColor (colorBorder);
    Stroke previousStroke = gr.getStroke ();
    gr.setStroke (stroke);
    gr.draw (new RoundRectangle2D.Float (bounds.x + 0.5f, bounds.y + 0.5f, bounds.width - 1, bounds.height - 1, 4, 4));
    gr.setStroke (previousStroke);

    gr.setClip (previousClip);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:VMDNodeBorder.java

示例3: drawTitleBar

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
private void drawTitleBar(Graphics2D g) {
   Graphics2D g2 = (Graphics2D) g.create();
   RoundRectangle2D titleBar = createTitleBarShape();
   double h = SF * (TITLE_BAR_HEIGHT + CORNER_RADIUS) + 1;
   g2.setPaint(new GradientPaint(0, 0, grayColor(GRAY_TOP),
                                 0, (float) h, grayColor(GRAY_BOTTOM)));
   g2.fill(titleBar);
   g2.setColor(Color.DARK_GRAY);
   g2.draw(titleBar);
   g2.setColor(Color.BLACK);
   int scaledSize = (int) Math.round(SF * TITLE_FONT_SIZE);
   g2.setFont(Font.decode(TITLE_FONT_FAMILY + "-" + scaledSize));
   FontMetrics fm = g2.getFontMetrics();
   int x = (int) Math.round((sw - fm.stringWidth(title)) / 2);
   int y = (int) Math.round(SF * (TITLE_BAR_HEIGHT / 2 + TITLE_DY));
   g2.drawString(title, x, y);
   drawBall(g2, RED_BALL, 0);
   drawBall(g2, AMBER_BALL, 1);
   drawBall(g2, GREEN_BALL, 2);
   g2.dispose();
}
 
开发者ID:eric-roberts,项目名称:JavaPPTX,代码行数:22,代码来源:PPWindowImage.java

示例4: paint

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
@Override
public void paint(Graphics2D g) {

    g.setColor(function.getBackground());
    final Rectangle2D rect = movingArea.getBounds(getBounds());

    RoundRectangle2D.Double rec = new RoundRectangle2D.Double(rect.getX(),
            rect.getY(), rect.getWidth(), rect.getHeight(),
            movingArea.getIDoubleOrdinate(4),
            movingArea.getIDoubleOrdinate(4));

    g.fill(rec);
    g.setFont(function.getFont());
    paintText(g);

    paintBorder(g);

    final Stroke tmp = g.getStroke();
    g.draw(rec);
    g.setStroke(tmp);
    paintTringle(g);

}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:24,代码来源:DFDSRole.java

示例5: fill

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
/**
 * Fills the specified shape with the current {@code paint}.  There is
 * direct handling for {@code RoundRectangle2D}, 
 * {@code Rectangle2D}, {@code Ellipse2D} and {@code Arc2D}.  
 * All other shapes are mapped to a path outline and then filled.
 * 
 * @param s  the shape ({@code null} not permitted). 
 * 
 * @see #draw(java.awt.Shape) 
 */
@Override
public void fill(Shape s) {
    if (s instanceof RoundRectangle2D) {
        RoundRectangle2D rr = (RoundRectangle2D) s;
        this.gc.fillRoundRect(rr.getX(), rr.getY(), rr.getWidth(), 
                rr.getHeight(), rr.getArcWidth(), rr.getArcHeight());
    } else if (s instanceof Rectangle2D) {
        Rectangle2D r = (Rectangle2D) s;
        this.gc.fillRect(r.getX(), r.getY(), r.getWidth(), r.getHeight());
    } else if (s instanceof Ellipse2D) {
        Ellipse2D e = (Ellipse2D) s;
        this.gc.fillOval(e.getX(), e.getY(), e.getWidth(), e.getHeight());
    } else if (s instanceof Arc2D) {
        Arc2D a = (Arc2D) s;
        this.gc.fillArc(a.getX(), a.getY(), a.getWidth(), a.getHeight(), 
                a.getAngleStart(), a.getAngleExtent(), 
                intToArcType(a.getArcType()));
    } else {
        shapeToPath(s);
        this.gc.fill();
    }
}
 
开发者ID:nick-paul,项目名称:aya-lang,代码行数:33,代码来源:FXGraphics2D.java

示例6: setRoundedCorner

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
/**
 * Rounds the corners of the bounding rectangle in which the text
 * string is rendered. This will only be seen if either the stroke
 * or fill color is non-transparent.
 * 
 * @param arcWidth
 *            the width of the curved corner
 * @param arcHeight
 *            the height of the curved corner
 */
public void setRoundedCorner( int arcWidth, int arcHeight )
{
	if ( ( arcWidth == 0 || arcHeight == 0 ) &&
		!( m_bbox instanceof Rectangle2D ) ) {
		m_bbox = new Rectangle2D.Double();
	}
	else {
		if ( !( m_bbox instanceof RoundRectangle2D ) )
			m_bbox = new RoundRectangle2D.Double();
		( (RoundRectangle2D)m_bbox )
			.setRoundRect( 0, 0, 10, 10, arcWidth, arcHeight );
		m_arcWidth = arcWidth;
		m_arcHeight = arcHeight;
	}
}
 
开发者ID:kartoFlane,项目名称:hiervis,代码行数:26,代码来源:StringRenderer.java

示例7: createGUI

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
private void createGUI(){
    setLayout(new GridBagLayout());
    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            setShape(new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), WINDOW_RADIUS, WINDOW_RADIUS));
        }
    });
    
    setAlwaysOnTop(true);
    setUndecorated(true);
    setFocusableWindowState(false);
    setModalityType(ModalityType.MODELESS);
    setSize(mText.length() * CHARACTER_LENGTH_MULTIPLIER, 25);
    getContentPane().setBackground(mBackgroundColor);
    
    JLabel label = new JLabel(mText);
    label.setForeground(mForegroundColor);
    add(label);
}
 
开发者ID:LouisJenkinsCS,项目名称:Code-Glosser,代码行数:21,代码来源:Toast.java

示例8: paintButton

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
private void paintButton(Graphics g, Color[] colors) {
	
	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	int width = this.getWidth();
	int height = this.getHeight();

	Point2D center = new Point2D.Float(width / 2, height / 2);
	float radius = width / 2;
	float[] dist = { 0.0f, 0.8f };
	RadialGradientPaint paint = new RadialGradientPaint(center, radius, dist, colors);
	g2.setPaint(paint);
	shape = new RoundRectangle2D.Double(0, 0, width, height, height, height);
	g2.fill(shape);

	Font defaultFont = getFont();
	g2.setFont(defaultFont);
	g2.setColor(Color.BLACK);
	Rectangle2D rect = defaultFont.getStringBounds(text, g2.getFontRenderContext());
	LineMetrics lineMetrics = defaultFont.getLineMetrics(text, g2.getFontRenderContext());
	g2.drawString(text, (float) (width / 2 - rect.getWidth() / 2), (float) ((height / 2)
			+ ((lineMetrics.getAscent() + lineMetrics.getDescent()) / 2 - lineMetrics.getDescent())));

}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:25,代码来源:MyButton.java

示例9: paintButton

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
private void paintButton(Graphics g, Color[] colors)
{
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    int width = this.getWidth();
    int height = this.getHeight();

    Point2D center = new Point2D.Float(width / 2, height / 2);
    float radius = width / 2;
    float[] dist = {0.0f, 0.8f};
    RadialGradientPaint paint = new RadialGradientPaint(center, radius, dist, colors);
    g2.setPaint(paint);
    shape = new RoundRectangle2D.Double(0, 0, width, height, height, height);
    g2.fill(shape);

    Font defaultFont = getFont();
    g2.setFont(defaultFont);
    g2.setColor(Color.BLACK);
    Rectangle2D rect = defaultFont.getStringBounds(text, g2.getFontRenderContext());
    LineMetrics lineMetrics = defaultFont.getLineMetrics(text, g2.getFontRenderContext());
    g2.drawString(text,
        (float)(width / 2 - rect.getWidth() / 2),
        (float)((height / 2) + ((lineMetrics.getAscent() + lineMetrics.getDescent()) / 2 - lineMetrics.getDescent())));

}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:26,代码来源:CTDFrame.java

示例10: HoseIcon

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
private JLabel HoseIcon( final WaterTowerModule module ) {
        final int width = 60;
        final int height = 14;
        PNode node = new PNode() {{
            final PhetPPath hosePart = new PhetPPath( new RoundRectangle2D.Double( 0, 0, width, height, 10, 10 ), Color.green, new BasicStroke( 1 ), Color.darkGray ) {{
                //workaround the "edges get cut off in toImage" problem
                setBounds( -1, -1, width + 2, height + 2 );
            }};
            addChild( hosePart );
            addChild( new PImage( BufferedImageUtils.multiScaleToHeight( getRotatedImage( Images.NOZZLE, Math.PI / 2 ), (int) ( hosePart.getFullBounds().getHeight() + 4 ) ) ) {{
                setOffset( hosePart.getFullBounds().getMaxX() - getFullBounds().getWidth() + 15, hosePart.getFullBounds().getCenterY() - getFullBounds().getHeight() / 2 );
            }} );
        }};
        final ImageIcon imageIcon = new ImageIcon( node.toImage() );

        //restore
//        module.model.hose.enabled.set( enabled );
        return new JLabel( imageIcon ) {{
            addMouseListener( new MouseAdapter() {
                @Override public void mousePressed( final MouseEvent e ) {
                    SimSharingManager.sendUserMessage( hoseCheckBoxIcon, icon, pressed, parameterSet( isSelected, !module.model.hose.enabled.get() ) );
                    module.model.hose.enabled.toggle();
                }
            } );
        }};
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:WaterTowerControlPanel.java

示例11: TipNode

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
public TipNode() {
    super();
    
    // rounded corners at top
    Shape roundRect = new RoundRectangle2D.Float( 0f, 0f, 1f, 1.5f, 0.4f, 0.4f );
    
    // mask out rounded corners at bottom
    Shape rect = new Rectangle2D.Float( 0f, 0.5f, 1f, 1f );
    
    // point at the bottom
    GeneralPath triangle = new GeneralPath();
    triangle.moveTo( 0f, 1.5f );
    triangle.lineTo( 0.5f, 2.5f );
    triangle.lineTo( 1f, 1.5f );
    triangle.closePath();
    
    // constructive area geometry
    Area area = new Area( roundRect );
    area.add( new Area( rect ) );
    area.add( new Area( triangle ) );
    
    setPathTo( area );
    setPaint( TIP_COLOR );
    setStroke( null );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:ProbeNode.java

示例12: paintIcon

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
  if (myColor.getAlpha() != 0xff) {
    final RoundRectangle2D.Double clip =
      new RoundRectangle2D.Double(x, y, myCellSize, myCellSize, ARC_SIZE, ARC_SIZE);
    GraphicsUtil.paintCheckeredBackground(g, clip);
  }

  g.setColor(myColor);
  g.fillRoundRect(x, y, myCellSize, myCellSize, ARC_SIZE, ARC_SIZE);

  myColor.getRGBComponents(myRgbaArray);
  if (Math.pow(1.0 - myRgbaArray[0], 2) + Math.pow(1.0 - myRgbaArray[1], 2) + Math.pow(1.0 - myRgbaArray[2], 2) < THRESHOLD_SQUARED_DISTANCE) {
    // Drawing a border to avoid displaying white boxes on a white background
    g.setColor(Gray._239);
    g.drawRoundRect(x, y, myCellSize, myCellSize - 1, ARC_SIZE, ARC_SIZE);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ColorComponent.java

示例13: fillShape

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
private void fillShape(final SWTGraphics2D g2) {
    final double lineWidth = g2.getTransformedLineWidth();
    if (shape instanceof Rectangle2D) {
        g2.fillRect(shapePts[0] + lineWidth / 2, shapePts[1] + lineWidth / 2, shapePts[2] - lineWidth, shapePts[3]
                - lineWidth);
    }
    else if (shape instanceof Ellipse2D) {
        g2.fillOval(shapePts[0] + lineWidth / 2, shapePts[1] + lineWidth / 2, shapePts[2] - lineWidth, shapePts[3]
                - lineWidth);
    }
    else if (shape instanceof Arc2D) {
        g2.fillArc(shapePts[0] + lineWidth / 2, shapePts[1] + lineWidth / 2, shapePts[2] - lineWidth, shapePts[3]
                - lineWidth, shapePts[4], shapePts[5]);
    }
    else if (shape instanceof RoundRectangle2D) {
        g2.fillRoundRect(shapePts[0] + lineWidth / 2, shapePts[1] + lineWidth / 2, shapePts[2] - lineWidth,
                shapePts[3] - lineWidth, shapePts[4], shapePts[5]);
    }
    else {
        g2.fill(shape);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:PSWTPath.java

示例14: EnergyLegend

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
public EnergyLegend( final Property<Boolean> visible ) {
    addChild( new PText( "Kinetic Energy" ) {{
        setTextPaint( PhetColorScheme.KINETIC_ENERGY );
        setFont( new PhetFont( 20, true ) );
    }} );
    addChild( new PText( "Potential Energy" ) {{
        setTextPaint( PhetColorScheme.POTENTIAL_ENERGY );
        setFont( new PhetFont( 20, true ) );
        setOffset( 0, EnergyLegend.this.getFullBounds().getHeight() );
    }} );
    addChild( new PText( "Thermal Energy" ) {{
        setTextPaint( PhetColorScheme.HEAT_THERMAL_ENERGY );
        setFont( new PhetFont( 20, true ) );
        setOffset( 0, EnergyLegend.this.getFullBounds().getHeight() );
    }} );
    visible.addObserver( new SimpleObserver() {
        public void update() {
            setVisible( visible.get() );
        }
    } );
    double inset = 4;
    final PhetPPath child = new PhetPPath( new RoundRectangle2D.Double( -inset, -inset, getFullBounds().getWidth() + inset * 2, getFullBounds().getHeight() + inset * 2, 10, 10 ), Color.white, new BasicStroke( 1 ), Color.darkGray );
    addChild( child );
    child.moveToBack();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:EnergyLegend.java

示例15: updateLayout

import java.awt.geom.RoundRectangle2D; //导入依赖的package包/类
/**
 * Update the layout of this node.
 *
 * @param topRectWidth      - Width of the rectangular readout portion of this node.
 * @param topRectHeight     - Height of the rectangular readout portion of this node.
 * @param topOfGraphPosY    - Y position of the top of the graph.  The readout sits above this and the
 *                          tail is below.
 * @param bottomOfGraphPosY - Y position of the bottom of the graph, which will also be the bottom
 *                          of the tail.
 */
public void updateLayout( int topRectWidth, int topRectHeight, int topOfGraphPosY, int bottomOfGraphPosY ) {

    // Size the readout rectangle, but don't position it yet.
    _readoutRect.setPathTo( new RoundRectangle2D.Double( 0, 0, topRectWidth, topRectHeight, 10, 10 ) );

    // Resize and position the readout text.
    updateReadoutText();
    updateReadoutTextLayout();

    // Set the position of the readout rectangle.
    // TODO: Need to work out how to do initial horizontal positioning.
    _readoutRect.setOffset( 200, _chart._usableAreaRect.getX() );

    // Set the size and position of the indicator line.
    _indicatorLine.setPathTo( new Line2D.Double( 0, 0, 0, bottomOfGraphPosY - topOfGraphPosY ) );
    _indicatorLine.setOffset( _readoutRect.getOffset().getX() + _readoutRect.getWidth() / 2,
                              _readoutRect.getOffset().getY() + _readoutRect.getHeight() );

    // Set the position of the handle.
    _indicatorHandle.setOffset(
            _readoutRect.getOffset().getX() + _readoutRect.getWidth() / 2 - _indicatorHandle.getWidth() / 2,
            _readoutRect.getFullBoundsReference().getMaxY() + ( 0.5 * _indicatorHandle.getFullBoundsReference().getHeight() ) );

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:35,代码来源:NuclearDecayProportionChart.java


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