Java 类java.awt.geom.RoundRectangle2D 实例源码

项目:rapidminer    文件:CompositeButtonPainter.java   
/**
 * 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);
}
项目:incubator-netbeans    文件:VMDNodeBorder.java   
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);
}
项目:JavaPPTX    文件:PPWindowImage.java   
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();
}
项目:ramus    文件:DFDSRole.java   
@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);

}
项目:aya-lang    文件:FXGraphics2D.java   
/**
 * 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();
    }
}
项目:hiervis    文件:StringRenderer.java   
/**
 * 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;
    }
}
项目:ccu-historian    文件:FXGraphics2D.java   
/**
 * 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();
    }
}
项目:Code-Glosser    文件:Toast.java   
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);
}
项目:eSDK_EC_SDK_Java    文件:MyButton.java   
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())));

}
项目:eSDK_EC_SDK_Java    文件:MyButton.java   
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())));

}
项目:eSDK_EC_SDK_Java    文件:MyButton.java   
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())));

}
项目:eSDK_EC_SDK_Java    文件:CTDFrame.java   
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())));

}
项目:eSDK_EC_SDK_Java    文件:MyButton.java   
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())));

}
项目:PhET    文件:WaterTowerControlPanel.java   
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();
                }
            } );
        }};
    }
项目:PhET    文件:ProbeNode.java   
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 );
}
项目:intellij-ce-playground    文件:ColorComponent.java   
@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);
  }
}
项目:PhET    文件:PSWTPath.java   
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);
    }
}
项目:PhET    文件:EnergyLegend.java   
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();
}
项目:PhET    文件:NuclearDecayProportionChart.java   
/**
 * 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() ) );

}
项目:PhET    文件:SingleNucleusAlphaDecayTimeChart.java   
TimeDisplayNode() {
    _readoutWidth = _usableWidth * 0.22;   // Somewhat arbitrary default values, size is expected to be set through method.
    _readoutHeight = _usableHeight * 0.2;  // Somewhat arbitrary default values, size is expected to be set through method.
    _backgroundShape = new RoundRectangle2D.Double( 0, 0, _readoutWidth, _readoutHeight, 8, 8 );
    _background = new PPath( _backgroundShape );
    _background.setPaint( BACKGROUND_COLOR );
    addChild( _background );
    _timeText = new HTMLNode();
    _timeText.setFont( TIME_FONT );
    addChild( _timeText );
    _spaceText = new PText( " " );
    _spaceText.setFont( TIME_FONT );
    addChild( _spaceText );
    _unitsText = new HTMLNode();
    _unitsText.setFont( TIME_FONT );
    addChild( _unitsText );
    _dummyTextNormal = new HTMLNode( _timeFormatterNoDecimals.format( 9999 ) );
    _dummyTextNormal.setFont( TIME_FONT );
    _dummyTextExponential = new HTMLNode( _trillionsFormatter.format( 999E12 ) );
    _dummyTextExponential.setFont( TIME_FONT );
}
项目:PhET    文件:TimeDisplayNode.java   
/**
    * Constructor.
    * 
    * @param width
    * @param height
    */
public TimeDisplayNode(double width, double height){
    _width = width;
    _height = height;
    _backgroundShape = new RoundRectangle2D.Double(0, 0, _width, _height, _width / 10, _width / 10);
    _background = new PPath(_backgroundShape);
    _background.setPaint(BACKGROUND_COLOR);
    _background.setStroke(new BasicStroke(BORDER_STROKE_SIZE));
    addChild(_background);
    _timeText = new HTMLNode();
    _timeText.setFont(TIME_FONT);
    addChild(_timeText);
    _spaceText = new PText(" ");
    _spaceText.setFont(TIME_FONT);
    addChild(_spaceText);
    _unitsText = new HTMLNode();
    _unitsText.setFont(TIME_FONT);
    addChild(_unitsText);
    _dummyTextNormal = new HTMLNode(_timeFormatterNoDecimals.format(9999));
    _dummyTextNormal.setFont(TIME_FONT);
    _dummyTextExponential = new HTMLNode(_trillionsFormatter.format(999E12));
    _dummyTextExponential.setFont(TIME_FONT);
}
项目:Push2Display    文件:SVGShape.java   
/**
 * @param shape Shape object to be converted
 */
public Element toSVG(Shape shape){
    if(shape instanceof Polygon)
        return svgPolygon.toSVG((Polygon)shape);
    else if(shape instanceof Rectangle2D)
        return svgRectangle.toSVG((Rectangle2D)shape);
    else if(shape instanceof RoundRectangle2D)
        return svgRectangle.toSVG((RoundRectangle2D)shape);
    else if(shape instanceof Ellipse2D)
        return svgEllipse.toSVG((Ellipse2D)shape);
    else if(shape instanceof Line2D)
        return svgLine.toSVG((Line2D)shape);
    else if(shape instanceof Arc2D)
        return svgArc.toSVG((Arc2D)shape);
    else
        return svgPath.toSVG(shape);
}
项目:PhET    文件:PipeGraphic.java   
/**
 * Sets the location, relative to the upper-left corner of the bounding box
 * that encloses all of the pipe segements.
 * 
 * @param location the location
 */
public void setLocation( Point location ) {
    int dx = location.x - _location.x;
    int dy = location.y - _location.y;

    _location = location;

    RoundRectangle2D.Double r;
    for( int i = 0; i < _pipes.size(); i++ ) {
        r = (RoundRectangle2D.Double) _pipes.get( i );
        r.x += dx;
        r.y += dy;
    }

    updateShape();
}
项目:PhET    文件:RealMoleculesControlPanel.java   
public MoleculeKit( final RealMoleculesTab module, final Dimension anticipatedDimension, final RealMoleculeShape... shapes ) {
            // stub, will have content added later
            super( new PNode() );
            this.shapes = shapes;

            moleculeOptions = new Property<RealMoleculeShape>( shapes[0] );
            moleculeOptions.addObserver( new ChangeObserver<RealMoleculeShape>() {
                public void update( RealMoleculeShape newValue, RealMoleculeShape oldValue ) {
                    module.switchToMolecule( newValue );
                }
            } );
            final Property<Double> y = new Property<Double>( 0.0 );
            for ( RealMoleculeShape shape : shapes ) {
                PropertyRadioButtonNode<RealMoleculeShape> radioButtonNode = createRadioButton( shape, moleculeOptions );
                radioButtonNode.setOffset( 0, y.get() );
                y.set( radioButtonNode.getFullBounds().getMaxY() );
                content.addChild( radioButtonNode );
            }

            double padding = 5;
            double round = 10;

//            content.addChild( 0, new PhetPPath( new RoundRectangle2D.Double( -padding, -padding, anticipatedDimension.getWidth() + padding * 2, anticipatedDimension.getHeight() + padding * 2, round, round ), Color.WHITE ) );
            content.addChild( 0, new PhetPPath( new RoundRectangle2D.Double( -padding, -padding, content.getFullBounds().getWidth() + padding * 2, content.getFullBounds().getHeight() + padding * 2, round, round ), Color.WHITE ) );
        }
项目:PhET    文件:PHMeterNode.java   
public DisplayNode() {
    super();

    valueNode = new PText();
    valueNode.setFont( DISPLAY_FONT );
    setValue( new Double( 15 ) ); // initialize before layout

    PComposite parentNode = new PComposite();
    parentNode.addChild( valueNode );
    valueNode.setOffset( 0, 0 );

    PBounds pb = parentNode.getFullBoundsReference();
    Shape backgroundShape = new RoundRectangle2D.Double( 0, 0, pb.getWidth() + 2 * DISPLAY_BORDER_MARGIN, pb.getHeight() + 2 * DISPLAY_BORDER_MARGIN, 10, 10 );
    PPath backgroundNode = new PPath( backgroundShape );
    addChild( backgroundNode );
    backgroundNode.setPaint( DISPLAY_BACKGROUND );
    backgroundNode.setStroke( new BasicStroke( (float) DISPLAY_BORDER_WIDTH ) );
    backgroundNode.setStrokePaint( DISPLAY_BORDER_COLOR );
    backgroundNode.addChild( parentNode );
    parentNode.setOffset( DISPLAY_BORDER_MARGIN, DISPLAY_BORDER_MARGIN );
}
项目:pumpernickel    文件:TextBlock.java   
/** This defines width, height and body and may make other adjustments to prepare this
 * TextBlock to be rendered/measured. This should be called in a synchronized block.
 */
public void revalidate() {
    Rectangle2D stringBounds = getStringBounds();
    Insets insets = getInsets();
    Insets textInsets = getTextInsets();
    int curveWidth = getCurveWidth();
    RoundRectangle2D roundRect = new RoundRectangle2D.Double( 
            insets.left, insets.top,
            stringBounds.getWidth()+textInsets.left+textInsets.right, 
            stringBounds.getHeight()+textInsets.top+textInsets.bottom,
            curveWidth, curveWidth);
    body.reset();
    body.append(roundRect, false);
    width = MathG.ceilInt(roundRect.getWidth() + insets.left + insets.right);
    height = MathG.ceilInt(roundRect.getHeight() + insets.top + insets.bottom);
}
项目:flowable-engine    文件:DefaultProcessDiagramCanvas.java   
public void drawExpandedSubProcess(String name, GraphicInfo graphicInfo, boolean isTriggeredByEvent, double scaleFactor) {
    RoundRectangle2D rect = new RoundRectangle2D.Double(graphicInfo.getX(), graphicInfo.getY(),
            graphicInfo.getWidth(), graphicInfo.getHeight(), 8, 8);

    // Use different stroke (dashed)
    if (isTriggeredByEvent) {
        Stroke originalStroke = g.getStroke();
        g.setStroke(EVENT_SUBPROCESS_STROKE);
        g.draw(rect);
        g.setStroke(originalStroke);
    } else {
        Paint originalPaint = g.getPaint();
        g.setPaint(SUBPROCESS_BOX_COLOR);
        g.fill(rect);
        g.setPaint(SUBPROCESS_BORDER_COLOR);
        g.draw(rect);
        g.setPaint(originalPaint);
    }

    if (scaleFactor == 1.0 && name != null && !name.isEmpty()) {
        String text = fitTextToWidth(name, (int) graphicInfo.getWidth());
        g.drawString(text, (int) graphicInfo.getX() + 10, (int) graphicInfo.getY() + 15);
    }
}
项目:PhET    文件:PHProbeNode.java   
public DisplayNode() {
    super();

    PText labelNode = new PText( AABSStrings.LABEL_PH );
    labelNode.setFont( DISPLAY_FONT );

    _valueNode = new PText( "XXX.XX" );
    _valueNode.setFont( DISPLAY_FONT );

    PComposite parentNode = new PComposite();
    parentNode.addChild( labelNode );
    parentNode.addChild( _valueNode );
    labelNode.setOffset( 0, 0 );
    _valueNode.setOffset( labelNode.getFullBoundsReference().getWidth() + DISPLAY_X_SPACING, 0 );

    PBounds pb = parentNode.getFullBoundsReference();
    Shape backgroundShape = new RoundRectangle2D.Double( 0, 0, pb.getWidth() + 2 * DISPLAY_BORDER_MARGIN, pb.getHeight() + 2 * DISPLAY_BORDER_MARGIN, 10, 10 );
    PPath backgroundNode = new PPath( backgroundShape );
    addChild( backgroundNode );
    backgroundNode.setPaint( DISPLAY_BACKGROUND );
    backgroundNode.setStroke( new BasicStroke( (float) DISPLAY_BORDER_WIDTH ) );
    backgroundNode.setStrokePaint( DISPLAY_BORDER_COLOR );
    backgroundNode.addChild( parentNode );
    parentNode.setOffset( DISPLAY_BORDER_MARGIN, DISPLAY_BORDER_MARGIN );
}
项目:incubator-netbeans    文件:RoundedBorder.java   
public void paint (Graphics2D gr, Rectangle bounds) {
    if (fillColor != null) {
        gr.setColor (fillColor);
        gr.fill (new RoundRectangle2D.Float (bounds.x, bounds.y, bounds.width, bounds.height, arcWidth, arcHeight));
    }
    if (drawColor != null) {
        gr.setColor (drawColor);
        gr.draw (new RoundRectangle2D.Float (bounds.x + 0.5f, bounds.y + 0.5f, bounds.width - 1, bounds.height - 1, arcWidth, arcHeight));
    }
}
项目:rapidminer    文件:RapidLookTools.java   
/**
 * Creates the default {@link Shape} for the given button.
 *
 * @param b
 *            the button to create the shape for
 * @return the shape instance
 */
public static Shape createShapeForButton(AbstractButton b) {
    int w = b.getWidth();
    int h = b.getHeight();

    return new RoundRectangle2D.Double(1, 1, w - 2, h - 2, RapidLookAndFeel.CORNER_DEFAULT_RADIUS,
            RapidLookAndFeel.CORNER_DEFAULT_RADIUS);
}
项目:rapidminer    文件:RapidLookTools.java   
/**
 * Creates the border {@link Shape} for the given button.
 *
 * @param b
 *            the button to create the border shape for
 * @return the border shape instance
 */
public static Shape createBorderShapeForButton(AbstractButton b) {
    int w = b.getWidth();
    int h = b.getHeight();

    return new RoundRectangle2D.Double(0, 0, w - 1, h - 1, RapidLookAndFeel.CORNER_DEFAULT_RADIUS,
            RapidLookAndFeel.CORNER_DEFAULT_RADIUS);
}
项目:rapidminer    文件:RoundTitledBorder.java   
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    Graphics2D g2d = (Graphics2D) g.create();
    g2d.setRenderingHints(ProcessDrawer.HI_QUALITY_HINTS);
    g2d.setStroke(new BasicStroke(2f));

    // clear edges, otherwise they will be in the color of the component background
    if (drawRoundFrame && !c.getBackground().equals(c.getParent().getBackground())) {
        Shape frame = new Rectangle2D.Float(x + 2, y + 2, width - 4, height - 4);
        g2d.setPaint(c.getParent().getBackground());
        g2d.draw(frame);
    }

    g2d.setPaint(paint);
    g2d.setFont(new Font("Dialog", Font.BOLD, 21));

    if (drawRoundFrame) {
        Shape roundFrame = new RoundRectangle2D.Float(x + 2, y + 2, width - 4, height - 4, 10, 10);
        g2d.draw(roundFrame);
    }

    if (number > 0) {
        Shape circle = new Ellipse2D.Float(20, 20, 34, 34);
        g2d.fill(circle);
        g2d.setPaint(Color.WHITE);
        g2d.drawString(String.valueOf(number), 29, 44);
    }

    if (key != null) {
        g2d.setPaint(paint);
        g2d.drawString(key, 60, 44);
    }

    g2d.dispose();
}
项目:rapidminer    文件:ProcessDrawer.java   
/**
 * Draws the operator background (white round rectangle).
 *
 * @param operator
 *            the operator to draw the background for
 * @param g2
 *            the graphics context to draw upon
 */
private void renderOperatorBackground(final Operator operator, final Graphics2D g2) {
    Rectangle2D frame = model.getOperatorRect(operator);
    // the first paint can come before any of the operator register listeners fire
    // thus we need to check the rect for null and set it here once
    // all subsequent calls will then have a valid rect
    if (frame == null) {
        return;
    }

    RoundRectangle2D background = new RoundRectangle2D.Double(frame.getX() - 7, frame.getY() - 3, frame.getWidth() + 14,
            frame.getHeight() + 11, OPERATOR_BG_CORNER, OPERATOR_BG_CORNER);
    g2.setColor(Color.WHITE);
    g2.fill(background);

    // if name is wider than operator, extend white background for header
    Rectangle2D nameBounds = OPERATOR_FONT.getStringBounds(operator.getName(), g2.getFontRenderContext());
    if (nameBounds.getWidth() > frame.getWidth()) {
        double relevantWidth = Math.min(nameBounds.getWidth(), frame.getWidth() * MAX_HEADER_RATIO);
        double offset = (frame.getWidth() - relevantWidth) / 2;
        int x = (int) (frame.getX() + offset);

        int padding = 5;
        RoundRectangle2D nameBackground = new RoundRectangle2D.Double(
                (int) Math.min(frame.getX() - padding, x - padding), frame.getY() - 3, relevantWidth + 2 * padding,
                ProcessRendererModel.HEADER_HEIGHT + 3, OPERATOR_BG_CORNER, OPERATOR_BG_CORNER);
        g2.fill(nameBackground);
    }

    // render ports
    renderPortsBackground(operator.getInputPorts(), g2);
    renderPortsBackground(operator.getOutputPorts(), g2);
}
项目:rapidminer    文件:ProcessDrawer.java   
/**
 * Draws the drag border.
 *
 * @param process
 *            the process for which to render the background
 * @param g2
 *            the graphics context to draw upon
 */
private void drawDragBorder(final ExecutionUnit process, final Graphics2D g2) {
    double width = model.getProcessWidth(process);
    double height = model.getProcessHeight(process);
    Shape dragFrame = new RoundRectangle2D.Double(DRAG_BORDER_PADDING, DRAG_BORDER_PADDING, width - 2
            * DRAG_BORDER_PADDING, height - 2 * DRAG_BORDER_PADDING, DRAG_BORDER_CORNER, DRAG_BORDER_CORNER);
    g2.setColor(BORDER_DRAG_COLOR);
    g2.setStroke(BORDER_DRAG_STROKE);
    g2.draw(dragFrame);
}
项目:jmt    文件:QueueDrawer.java   
private RoundRectangle2D drawViewButton(double x, double y, Graphics2D g2d, boolean draw, boolean clicked) {
    Rectangle2D dvR;
    RoundRectangle2D dvRR;
    Color tmp;
    Color fg = Color.BLACK;
    Color bg = Color.LIGHT_GRAY;

    if (clicked) {
        tmp = fg;
        fg = bg;
        bg = tmp;
    }

    if (nCpu > 2) {
        fg = Color.DARK_GRAY.brighter().brighter();
        bg = Color.LIGHT_GRAY;
    }

    dvR = drawCenteredText("change view", fg, bg, x, y, g2d, false, false);
    dvRR = new RoundRectangle2D.Double(x, y, dvR.getWidth(), dvR.getHeight(), 5.0, 5.0);
    if (draw) {
        tmp = g2d.getColor();
        g2d.setColor(bg);
        g2d.fill(dvRR);
        g2d.setColor(fg);
        g2d.draw(dvRR);
        drawCenteredText("change view", fg, bg, x + dvR.getWidth() / 2.0, y + dvR.getHeight() / 2.0, g2d, false, true);
        g2d.setColor(tmp);
    }
    return dvRR;
}
项目:framework    文件:QRCodeUtils.java   
/**
 * 插入LOGO
 *
 * @param size         二维码尺寸
 * @param source       二维码图片
 * @param logoPath     LOGO图片地址
 * @param needCompress 是否压缩
 * @throws Exception
 */
private static void insertImage(int size, BufferedImage source, String logoPath, boolean needCompress) throws Exception {
    int logoWidth = size / 5; //设置logo图片宽度为二维码图片的五分之一
    int logoHeight = size / 5; //设置logo图片高度为二维码图片的五分之一

    Image src = ImageIO.read(new URL(logoPath));
    int width = src.getWidth(null);
    int height = src.getHeight(null);
    if (needCompress) { // 压缩LOGO
        if (width > logoWidth) {
            width = logoWidth;
        }
        if (height > logoHeight) {
            height = logoHeight;
        }
        Image image = src.getScaledInstance(width, height, Image.SCALE_SMOOTH);
        BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics g = tag.getGraphics();
        g.drawImage(image, 0, 0, null); // 绘制缩小后的图
        g.dispose();
        src = image;
    }
    // 插入LOGO
    Graphics2D graph = source.createGraphics();
    int x = (size - width) / 2;
    int y = (size - height) / 2;
    graph.drawImage(src, x, y, width, height, null);
    Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);
    graph.setStroke(new BasicStroke(3f));
    graph.draw(shape);
    graph.dispose();
}
项目:jNotifyOSD    文件:DesktopNotify.java   
private void setBorderType() {
    switch (ev.getBorder()) {
    case ROUNDED:
        if (gDevice.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
            addComponentListener(new ComponentAdapter() {
                    @Override
                    public void componentResized(ComponentEvent e) {
                        setShape(new RoundRectangle2D.Double(0,0,getWidth(),getHeight(), 15, 15));
                    }
                });
        } else {
            if (NotifyConfig.getDebug()) {
                System.out.println(CLASS_NAME+": Your System don't support this Border feature.");

            }
        }
        break;
    case RAISED:
        panel.setBorder(BorderFactory.createRaisedBevelBorder());
        break;
    case ETCHED:
        panel.setBorder(BorderFactory.createEtchedBorder());
        break;
    default: // NONE
        // do nothing
    }
}
项目:QN-ACTR-Release    文件:QueueDrawer.java   
private RoundRectangle2D drawViewButton(double x, double y, Graphics2D g2d, boolean draw, boolean clicked) {
    Rectangle2D dvR;
    RoundRectangle2D dvRR;
    Color tmp;
    Color fg = Color.BLACK;
    Color bg = Color.LIGHT_GRAY;

    if (clicked) {
        tmp = fg;
        fg = bg;
        bg = tmp;
    }

    if (nCpu > 2) {
        fg = Color.darkGray.brighter().brighter();
        bg = Color.LIGHT_GRAY;
    }

    dvR = drawCenteredText("change view", fg, bg, x, y, g2d, false, false);
    dvRR = new RoundRectangle2D.Double(x, y, dvR.getWidth(), dvR.getHeight(), 5.0, 5.0);
    if (draw) {
        tmp = g2d.getColor();
        g2d.setColor(bg);
        g2d.fill(dvRR);
        g2d.setColor(fg);
        g2d.draw(dvRR);
        drawCenteredText("change view", fg, bg, x + dvR.getWidth() / 2.0, y + dvR.getHeight() / 2.0, g2d, false, true);
        g2d.setColor(tmp);
    }
    return dvRR;
}
项目:lemon    文件:CustomProcessDiagramGenerator.java   
/**
 * 绘制任务
 */
protected static void drawTask(int x, int y, int width, int height,
        Graphics2D graphics) {
    RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width,
            height, OFFSET_TASK, OFFSET_TASK);
    graphics.draw(rect);
}
项目:lemon    文件:CustomProcessDiagramGenerator.java   
/**
 * 绘制子流程
 */
protected static void drawSubProcess(int x, int y, int width, int height,
        Graphics2D graphics) {
    RoundRectangle2D rect = new RoundRectangle2D.Double(x + 1, y + 1,
            width - 2, height - 2, OFFSET_SUBPROCESS, OFFSET_SUBPROCESS);
    graphics.draw(rect);
}