use of org.apache.pivot.wtk.MessageType in project pivot by apache.
the class TerraFormSkin method paint.
@Override
public void paint(Graphics2D graphics) {
super.paint(graphics);
GraphicsUtilities.setAntialiasingOn(graphics);
Form form = (Form) getComponent();
Form.SectionSequence sections = form.getSections();
for (int sectionIndex = 0, sectionCount = sections.getLength(); sectionIndex < sectionCount; sectionIndex++) {
Form.Section section = sections.get(sectionIndex);
for (int fieldIndex = 0, fieldCount = section.getLength(); fieldIndex < fieldCount; fieldIndex++) {
Component field = section.get(fieldIndex);
if (field.isVisible()) {
Form.Flag flag = Form.getFlag(field);
if (flag != null) {
if (showFlagIcons) {
MessageType messageType = flag.getMessageType();
Image flagIcon = null;
switch(messageType) {
case ERROR:
{
flagIcon = errorIcon;
break;
}
case WARNING:
{
flagIcon = warningIcon;
break;
}
case QUESTION:
{
flagIcon = questionIcon;
break;
}
case INFO:
{
flagIcon = infoIcon;
break;
}
default:
{
flagIcon = infoIcon;
break;
}
}
Label label = labels.get(sectionIndex).get(fieldIndex);
int flagIconX = label.getX() - (flagIcon.getWidth() + flagIconOffset);
int flagIconY = label.getY() + (label.getHeight() - flagIcon.getHeight()) / 2;
graphics.translate(flagIconX, flagIconY);
flagIcon.paint(graphics);
graphics.translate(-flagIconX, -flagIconY);
}
if (showFlagHighlight) {
MessageType messageType = flag.getMessageType();
Color highlightColor = null;
switch(messageType) {
case ERROR:
{
highlightColor = errorHighlightColor;
break;
}
case WARNING:
{
highlightColor = warningHighlightColor;
break;
}
case QUESTION:
{
highlightColor = questionHighlightColor;
break;
}
case INFO:
{
highlightColor = infoHighlightColor;
break;
}
default:
{
break;
}
}
Bounds fieldBounds = field.getBounds();
graphics.setColor(highlightColor);
graphics.setStroke(new BasicStroke(1));
graphics.drawRect(fieldBounds.x - FLAG_HIGHLIGHT_PADDING, fieldBounds.y - FLAG_HIGHLIGHT_PADDING, fieldBounds.width + FLAG_HIGHLIGHT_PADDING * 2 - 1, fieldBounds.height + FLAG_HIGHLIGHT_PADDING * 2 - 1);
}
}
}
}
}
}
Aggregations