use of org.apache.pivot.wtk.PushButton in project pivot by apache.
the class TerraPromptSkin method install.
@Override
public void install(Component component) {
super.install(component);
Prompt prompt = (Prompt) component;
prompt.setPreferredWidth(320);
prompt.setMinimumWidth(160);
prompt.getPromptListeners().add(this);
// Load the prompt content
BXMLSerializer bxmlSerializer = new BXMLSerializer();
Component content;
try {
content = (Component) bxmlSerializer.readObject(TerraPromptSkin.class, "terra_prompt_skin.bxml");
} catch (Exception exception) {
throw new RuntimeException(exception);
}
prompt.setContent(content);
typeImageView = (ImageView) bxmlSerializer.getNamespace().get("typeImageView");
messageLabel = (Label) bxmlSerializer.getNamespace().get("messageLabel");
messageBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("messageBoxPane");
optionButtonBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("optionButtonBoxPane");
for (Object option : prompt.getOptions()) {
PushButton optionButton = new PushButton(option);
optionButton.setStyleName(BUTTON_STYLE_NAME);
optionButton.getButtonPressListeners().add(optionButtonPressListener);
optionButtonBoxPane.add(optionButton);
}
messageTypeChanged(prompt, null);
messageChanged(prompt, null);
bodyChanged(prompt, null);
}
use of org.apache.pivot.wtk.PushButton in project pivot by apache.
the class TerraPushButtonSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
PushButton pushButton = (PushButton) getComponent();
Button.DataRenderer dataRenderer = pushButton.getDataRenderer();
dataRenderer.render(pushButton.getButtonData(), pushButton, false);
Dimensions preferredContentSize = dataRenderer.getPreferredSize();
int preferredWidth = preferredContentSize.width + paddingWidth();
int preferredHeight = preferredContentSize.height + paddingHeight();
// Adjust for preferred aspect ratio
float aspectRatio = (float) preferredWidth / (float) preferredHeight;
if (!Float.isNaN(minimumAspectRatio) && aspectRatio < minimumAspectRatio) {
preferredWidth = (int) (preferredHeight * minimumAspectRatio);
}
if (!Float.isNaN(maximumAspectRatio) && aspectRatio > maximumAspectRatio) {
preferredHeight = (int) (preferredWidth / maximumAspectRatio);
}
return new Dimensions(preferredWidth, preferredHeight);
}
use of org.apache.pivot.wtk.PushButton in project pivot by apache.
the class TerraPushButtonSkin method getBaseline.
@Override
public int getBaseline(int width, int height) {
PushButton pushButton = (PushButton) getComponent();
Button.DataRenderer dataRenderer = pushButton.getDataRenderer();
dataRenderer.render(pushButton.getButtonData(), pushButton, false);
int clientWidth = Math.max(width - paddingWidth(), 0);
int clientHeight = Math.max(height - paddingHeight(), 0);
int baseline = dataRenderer.getBaseline(clientWidth, clientHeight);
if (baseline != -1) {
baseline += padding.top + 1;
}
return baseline;
}
use of org.apache.pivot.wtk.PushButton in project pivot by apache.
the class TerraAlertSkin method install.
@Override
public void install(Component component) {
super.install(component);
Alert alert = (Alert) component;
alert.setPreferredWidth(320);
alert.setMinimumWidth(160);
alert.getAlertListeners().add(this);
// Load the alert content
BXMLSerializer bxmlSerializer = new BXMLSerializer();
Component content;
try {
content = (Component) bxmlSerializer.readObject(TerraAlertSkin.class, "terra_alert_skin.bxml");
} catch (Exception exception) {
throw new RuntimeException(exception);
}
alert.setContent(content);
typeImageView = (ImageView) bxmlSerializer.getNamespace().get("typeImageView");
messageLabel = (Label) bxmlSerializer.getNamespace().get("messageLabel");
messageBorder = (Border) bxmlSerializer.getNamespace().get("messageBorder");
messageBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("messageBoxPane");
optionButtonBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("optionButtonBoxPane");
// Explicitly set the message border color and background color, this can't be done properly in the constructor
// as messageBorder is null at that point.
setBorderBackgroundColor(borderBackgroundColor);
setBorderColor(borderColor);
for (Object option : alert.getOptions()) {
PushButton optionButton = new PushButton(option);
optionButton.setStyleName(BUTTON_STYLE_NAME);
optionButton.getButtonPressListeners().add(optionButtonPressListener);
optionButtonBoxPane.add(optionButton);
}
messageTypeChanged(alert, null);
messageChanged(alert, null);
bodyChanged(alert, null);
}
use of org.apache.pivot.wtk.PushButton in project pivot by apache.
the class ActivityIndicators method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
activityIndicator1 = (ActivityIndicator) namespace.get("activityIndicator1");
activityIndicator2 = (ActivityIndicator) namespace.get("activityIndicator2");
activityIndicator3 = (ActivityIndicator) namespace.get("activityIndicator3");
activityButton = (PushButton) namespace.get("activityButton");
activityButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
activityIndicator1.setActive(!activityIndicator1.isActive());
activityIndicator2.setActive(!activityIndicator2.isActive());
activityIndicator3.setActive(!activityIndicator3.isActive());
updateButtonData();
}
});
updateButtonData();
}
Aggregations