public void updateGUI() {
// Update the GUI of the Position HUD Panel
positionHUDPanel.updateGUI();
// Fetch the currently selected Cell. If none, then do nothing
Cell cell = getSelectedCell();
if (cell == null) {
affordanceHUD.setName(BUNDLE.getString("Edit_Object_None_Selected"));
translateToggleButton.setSelected(false);
translateToggleButton.setEnabled(false);
rotateToggleButton.setSelected(false);
rotateToggleButton.setEnabled(false);
resizeToggleButton.setSelected(false);
resizeToggleButton.setEnabled(false);
sizeSlider.setValue(50);
sizeSlider.setEnabled(false);
return;
}
// Set the name of the Cell label
String name = BUNDLE.getString("Edit_Object");
name = MessageFormat.format(name, cell.getName());
affordanceHUD.setName(name);
Logger.getLogger(AffordanceHUDPanel.class.getName()).warning("Setting name to " + name);
// Enable all of the buttons on theHUD
translateToggleButton.setEnabled(true);
rotateToggleButton.setEnabled(true);
resizeToggleButton.setEnabled(true);
sizeSlider.setEnabled(true);
// See if there is a translate component on the Cell. If so, then set
// the toggle button state.
CellComponent component = cell.getComponent(TranslateAffordanceCellComponent.class);
translateToggleButton.setSelected(component != null);
translateToggleButton.repaint();
// In theory each affordance component can hold a different size value.
// In practice this can never happen since the GUI enforces all of the
// affordances to have the same size. So we just use the size from the
// translate affordance to initialize the slider value
if (component != null) {
float size = ((AffordanceCellComponent) component).getSize();
sizeSlider.setValue((int) ((size - 1.0f) * 100.0f));
}
else {
sizeSlider.setValue(50);
}
// See if there is a rotate component on the Cell. If so, then set the
// toggle button state.
component = cell.getComponent(RotateAffordanceCellComponent.class);
rotateToggleButton.setSelected(component != null);
rotateToggleButton.repaint();
// See if there is a resize component on the Cell. If so, then set the
// toggle button state.
component = cell.getComponent(ResizeAffordanceCellComponent.class);
resizeToggleButton.setSelected(component != null);
resizeToggleButton.repaint();
}