italic = getItemTextStyle(item, ((Label)item).getStyle()).isItalic();
} else if (item instanceof HomePieceOfFurniture
&& ((HomePieceOfFurniture)item).isVisible()) {
italic = getItemTextStyle(item, ((HomePieceOfFurniture)item).getNameStyle()).isItalic();
} else if (item instanceof Room) {
Room room = (Room)item;
italic = getItemTextStyle(room, room.getNameStyle()).isItalic();
if (italic != getItemTextStyle(room, room.getAreaStyle()).isItalic()) {
italic = null;
}
} else if (item instanceof DimensionLine) {
italic = getItemTextStyle(item, ((DimensionLine)item).getLengthStyle()).isItalic();
} else {
continue;
}
if (selectionItalicStyle == null) {
selectionItalicStyle = italic;
} else if (italic == null || !selectionItalicStyle.equals(italic)) {
selectionItalicStyle = null;
break;
}
}
// Apply new italic style to all selected items
if (selectionItalicStyle == null) {
selectionItalicStyle = Boolean.TRUE;
} else {
selectionItalicStyle = !selectionItalicStyle;
}
List<Selectable> itemsWithText = new ArrayList<Selectable>();
List<TextStyle> oldTextStyles = new ArrayList<TextStyle>();
List<TextStyle> textStyles = new ArrayList<TextStyle>();
for (Selectable item : this.home.getSelectedItems()) {
if (item instanceof Label) {
Label label = (Label)item;
itemsWithText.add(label);
TextStyle oldTextStyle = getItemTextStyle(label, label.getStyle());
oldTextStyles.add(oldTextStyle);
textStyles.add(oldTextStyle.deriveItalicStyle(selectionItalicStyle));
} else if (item instanceof HomePieceOfFurniture) {
HomePieceOfFurniture piece = (HomePieceOfFurniture)item;
if (piece.isVisible()) {
itemsWithText.add(piece);
TextStyle oldNameStyle = getItemTextStyle(piece, piece.getNameStyle());
oldTextStyles.add(oldNameStyle);
textStyles.add(oldNameStyle.deriveItalicStyle(selectionItalicStyle));
}
} else if (item instanceof Room) {
final Room room = (Room)item;
itemsWithText.add(room);
TextStyle oldNameStyle = getItemTextStyle(room, room.getNameStyle());
oldTextStyles.add(oldNameStyle);
textStyles.add(oldNameStyle.deriveItalicStyle(selectionItalicStyle));
TextStyle oldAreaStyle = getItemTextStyle(room, room.getAreaStyle());
oldTextStyles.add(oldAreaStyle);
textStyles.add(oldAreaStyle.deriveItalicStyle(selectionItalicStyle));
} else if (item instanceof DimensionLine) {
DimensionLine dimensionLine = (DimensionLine)item;
itemsWithText.add(dimensionLine);