// Now see what order they should be in.
MenuItemComponentRenderer first;
MenuItemComponentRenderer second;
final StyleProperty ORDER_PROPERTY
= StylePropertyDetails.MCS_MENU_ITEM_ORDER;
StyleValue order = properties.getComputedValue(ORDER_PROPERTY);
if (order == MCSMenuItemOrderKeywords.IMAGE_FIRST) {
first = imageRenderer;
second = textRenderer;
} else if (order == MCSMenuItemOrderKeywords.TEXT_FIRST) {
first = textRenderer;
second = imageRenderer;
} else {
throw new IllegalStateException
("Unknown keyword " + order + " for "
+ ORDER_PROPERTY.getName());
}
// Determine which component, or components is active.
final StyleProperty ACTIVE_AREA_PROPERTY
= StylePropertyDetails.MCS_MENU_ITEM_ACTIVE_AREA;
// Get the enumeration value from the properties.
StyleValue activeArea = properties.getComputedValue(ACTIVE_AREA_PROPERTY);
ActiveMenuItemComponent activeComponent;
if (activeArea == MCSMenuItemActiveAreaKeywords.IMAGE_ONLY) {
if (first == imageRenderer) {
activeComponent = ActiveMenuItemComponent.FIRST;
} else {
activeComponent = ActiveMenuItemComponent.SECOND;
}
} else if (activeArea == MCSMenuItemActiveAreaKeywords.TEXT_ONLY) {
if (first == textRenderer) {
activeComponent = ActiveMenuItemComponent.FIRST;
} else {
activeComponent = ActiveMenuItemComponent.SECOND;
}
} else if (activeArea == MCSMenuItemActiveAreaKeywords.BOTH) {
activeComponent = ActiveMenuItemComponent.BOTH;
} else {
throw new IllegalStateException
("Unknown keyword " + activeArea + " for "
+ ACTIVE_AREA_PROPERTY.getName());
}
// Now see what separator should be used.
separator = selector.selectMenuItemSeparator(menu);