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);
}
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);
}
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 + width - 1</code>,
* respectively. The top and bottom edges of the rectangle are at
* <code>y</code> and <code>y + height - 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);
}
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);
}
}
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);
}
}
Aggregations