Search in sources :

Example 16 with RoundRectangle2D

use of java.awt.geom.RoundRectangle2D in project intellij-community by JetBrains.

the class TrelloIconBuilder method buildIcon.

public Icon buildIcon(Set<TrelloLabel.LabelColor> colorSet) {
    if (colorSet.isEmpty()) {
        return TasksIcons.Trello;
    }
    Image image = CACHE.get(colorSet);
    if (image == null) {
        BufferedImage bufferedImage = UIUtil.createImage(size, size, BufferedImage.TYPE_INT_ARGB);
        int adjustedSize = size - 1;
        int nStripes = colorSet.size();
        Graphics2D g2d = bufferedImage.createGraphics();
        double diag = adjustedSize * SQRT_2;
        double stripeWidth = diag / nStripes;
        RoundRectangle2D baseRectangle = new RoundRectangle2D.Double(0, 0, adjustedSize, adjustedSize, 2, 2);
        ArrayList<TrelloLabel.LabelColor> colorsList = new ArrayList<>(colorSet);
        for (int i = 0; i < nStripes; i++) {
            Color color = colorsList.get(i).getColor();
            Area stripe = new Area(new Rectangle2D.Double(-diag / 2, (i * stripeWidth), diag, stripeWidth));
            stripe.transform(AffineTransform.getRotateInstance(-Math.PI / 4, 0, 0));
            stripe.intersect(new Area(baseRectangle));
            g2d.setPaint(color);
            g2d.fill(stripe);
        }
        g2d.setPaint(Color.BLACK);
        g2d.draw(baseRectangle);
        image = bufferedImage;
        CACHE.put(colorSet, image);
    }
    return new ImageIcon(image);
}
Also used : RoundRectangle2D(java.awt.geom.RoundRectangle2D) ArrayList(java.util.ArrayList) Rectangle2D(java.awt.geom.Rectangle2D) RoundRectangle2D(java.awt.geom.RoundRectangle2D) BufferedImage(java.awt.image.BufferedImage) BufferedImage(java.awt.image.BufferedImage) Area(java.awt.geom.Area)

Example 17 with RoundRectangle2D

use of java.awt.geom.RoundRectangle2D in project intellij-community by JetBrains.

the class TitlePanel method paintComponent.

protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    int width = getSize().width;
    int height = getSize().height;
    Object oldAntialiasing = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setPaint(new JBColor(Gray._247, UIUtil.getPanelBackground()));
    RoundRectangle2D rect = new RoundRectangle2D.Double(0, 0, width - 1, height - 1, 0, 0);
    g2.fill(rect);
    g2.setPaint(new JBColor(Color.GRAY, Gray._100));
    UIUtil.drawLine(g2, 0, height - 1, width - 1, height - 1);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasing);
}
Also used : RoundRectangle2D(java.awt.geom.RoundRectangle2D) JBColor(com.intellij.ui.JBColor)

Example 18 with RoundRectangle2D

use of java.awt.geom.RoundRectangle2D in project poi by apache.

the class SLGraphics method fillRoundRect.

/**
     * Fills the specified rounded corner rectangle with the current color.
     * The left and right edges of the rectangle
     * are at <code>x</code> and <code>x&nbsp;+&nbsp;width&nbsp;-&nbsp;1</code>,
     * respectively. The top and bottom edges of the rectangle are at
     * <code>y</code> and <code>y&nbsp;+&nbsp;height&nbsp;-&nbsp;1</code>.
     * @param       x the <i>x</i> coordinate of the rectangle to be filled.
     * @param       y the <i>y</i> coordinate of the rectangle to be filled.
     * @param       width the width of the rectangle to be filled.
     * @param       height the height of the rectangle to be filled.
     * @param       arcWidth the horizontal diameter
     *                     of the arc at the four corners.
     * @param       arcHeight the vertical diameter
     *                     of the arc at the four corners.
     * @see         java.awt.Graphics#drawRoundRect
     */
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
    RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight);
    fill(rect);
}
Also used : RoundRectangle2D(java.awt.geom.RoundRectangle2D)

Example 19 with RoundRectangle2D

use of java.awt.geom.RoundRectangle2D in project vcell by virtualcell.

the class ReactionRuleDiagramShape method paintSelf.

@Override
public void paintSelf(Graphics2D g2D, int absPosX, int absPosY) {
    Color newBackgroundColor = backgroundColor;
    int shapeHeight = getSpaceManager().getSize().height;
    int shapeWidth = getSpaceManager().getSize().width;
    // this is the "inside" of the shape; note it's 1 pixel larger than the approximate area occupied by the 2 yellow rectangles we use to depict the rule
    // Rectangle2D contour = new Rectangle2D.Double(absPosX, absPosY, shapeWidth, shapeHeight);
    // g2D.setColor(Color.gray);
    // g2D.draw(contour);
    int offsetX = 0;
    int offsetY = shapeHeight - circleDiameter;
    for (int i = 0; i < 2; i++) {
        int x = absPosX + offsetX + i * displacement;
        int y = absPosY + offsetY - i * displacement;
        RoundRectangle2D icon = new RoundRectangle2D.Double(x, y, circleDiameter, circleDiameter, circleDiameter / 2, circleDiameter / 2);
        g2D.setColor(newBackgroundColor);
        g2D.fill(icon);
        g2D.setColor(forgroundColor);
        g2D.draw(icon);
    }
    // draw label
    if (getDisplayLabels() || isSelected()) {
        g2D.setColor(forgroundColor);
        int textX = absPosX + shapeWidth / 2 - getLabelSize().width / 2;
        int textY = absPosY + offsetY - getLabelSize().height / 2;
        if (getLabel() != null && getLabel().length() > 0) {
            if (isSelected()) {
                Rectangle outlineRectangle = getLabelOutline(absPosX, absPosY);
                drawRaisedOutline(outlineRectangle.x, outlineRectangle.y, outlineRectangle.width, outlineRectangle.height, g2D, Color.white, Color.black, Color.black);
            }
            g2D.drawString(getLabel(), textX, textY);
        }
    }
    if (linkText != null && linkText != "") {
        ShapePaintUtil.paintLinkMarkRule(g2D, this, Color.BLACK);
    }
}
Also used : Color(java.awt.Color) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Rectangle(java.awt.Rectangle)

Example 20 with RoundRectangle2D

use of java.awt.geom.RoundRectangle2D in project vcell by virtualcell.

the class ReactionRuleShortDiagramShape method paintSelf.

@Override
public void paintSelf(Graphics2D g2D, int absPosX, int absPosY) {
    Color newBackgroundColor = backgroundColor;
    int shapeHeight = getSpaceManager().getSize().height;
    int shapeWidth = getSpaceManager().getSize().width;
    // this is the "inside" of the shape; note it's 1 pixel larger than the approximate area occupied by the 2 yellow rectangles we use to depict the rule
    // Rectangle2D contour = new Rectangle2D.Double(absPosX, absPosY, shapeWidth, shapeHeight);
    // g2D.setColor(Color.gray);
    // g2D.draw(contour);
    int offsetX = 0;
    int offsetY = shapeHeight - circleDiameter;
    for (int i = 0; i < 3; i++) {
        int x = absPosX + offsetX + i * displacement;
        int y = absPosY + offsetY - i * displacement;
        RoundRectangle2D icon = new RoundRectangle2D.Double(x, y, circleDiameter, circleDiameter, circleDiameter / 2, circleDiameter / 2);
        g2D.setColor(newBackgroundColor);
        g2D.fill(icon);
        g2D.setColor(forgroundColor);
        g2D.draw(icon);
    }
    // draw label
    if (getDisplayLabels() || isSelected()) {
        g2D.setColor(forgroundColor);
        int textX = absPosX + shapeWidth / 2 - getLabelSize().width / 2;
        int textY = absPosY + offsetY - getLabelSize().height / 2;
        if (getLabel() != null && getLabel().length() > 0) {
            if (isSelected()) {
                Rectangle outlineRectangle = getLabelOutline(absPosX, absPosY);
                drawRaisedOutline(outlineRectangle.x, outlineRectangle.y, outlineRectangle.width, outlineRectangle.height, g2D, Color.white, Color.black, Color.black);
            }
            g2D.drawString(getLabel(), textX, textY);
        }
    }
    if (linkText != null && linkText != "") {
        ShapePaintUtil.paintLinkMarkRule(g2D, this, Color.BLACK);
    }
}
Also used : Color(java.awt.Color) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Rectangle(java.awt.Rectangle)

Aggregations

RoundRectangle2D (java.awt.geom.RoundRectangle2D)24 Color (java.awt.Color)10 Graphics2D (java.awt.Graphics2D)9 BasicStroke (java.awt.BasicStroke)8 Paint (java.awt.Paint)8 Stroke (java.awt.Stroke)7 GradientPaint (java.awt.GradientPaint)6 RadialGradientPaint (java.awt.RadialGradientPaint)5 Rectangle (java.awt.Rectangle)4 Ellipse2D (java.awt.geom.Ellipse2D)4 RbmModelContainer (cbit.vcell.model.Model.RbmModelContainer)3 Area (java.awt.geom.Area)3 Line2D (java.awt.geom.Line2D)3 Point2D (java.awt.geom.Point2D)3 MolecularType (org.vcell.model.rbm.MolecularType)3 Font (java.awt.Font)2 Graphics (java.awt.Graphics)2 Point (java.awt.Point)2 Rectangle2D (java.awt.geom.Rectangle2D)2 ArrayList (java.util.ArrayList)2