org.protege.editor.owl.ui.renderer.OWLIndividualIcon Maven / Gradle / Ivy
The newest version!
package org.protege.editor.owl.ui.renderer;
import java.awt.*;
/**
* Author: Matthew Horridge
* Stanford University
* Bio-Medical Informatics Research Group
* Date: 03/02/2012
*/
public class OWLIndividualIcon extends OWLEntityIcon {
private static final Color COLOR = OWLSystemColors.getOWLIndividualColor();
public static final BasicStroke HOLLOW_STROKE = new BasicStroke(2);
public OWLIndividualIcon() {
this(FillType.FILLED);
}
public OWLIndividualIcon(FillType fillType) {
super(fillType);
}
@Override
public Color getEntityColor() {
return COLOR;
}
/**
* Draw the icon at the specified location. Icon implementations
* may use the Component argument to get properties useful for
* painting, e.g. the foreground or background color.
*/
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
try {
int width = 12;
int height = 12;
int xOffset = x + getIconWidth() / 2 - width / 2;
int yOffset = y + getIconHeight() / 2 - height / 2;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.rotate(Math.PI / 4, x + getIconWidth() / 2, y + getIconHeight() / 2);
if(getFillType() == FillType.FILLED) {
g2.setColor(Color.GRAY);
g2.fillRoundRect(xOffset, yOffset, width, height, 4, 4);
g2.setColor(COLOR);
g2.fillRoundRect(xOffset + 1, yOffset + 1, width - 2, height - 2, 4, 4);
}
else {
g2.setStroke(HOLLOW_STROKE);
g2.setColor(COLOR);
g2.drawRoundRect(xOffset + 1, yOffset + 1, width - 2, height - 2, 4, 4);
}
} finally {
g2.dispose();
}
}
}