use of org.apache.pivot.wtk.Label in project pivot by apache.
the class ComponentInspectorSkin method addScopeControl.
private static Component addScopeControl(final Dictionary<String, Object> dictionary, final String key, Form.Section section) {
Scope scope = (Scope) dictionary.get(key);
BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
section.add(boxPane);
Form.setLabel(boxPane, key);
FlowPane flowPane = new FlowPane();
flowPane.getStyles().put(Style.alignToBaseline, true);
flowPane.getStyles().put(Style.horizontalSpacing, 5);
boxPane.add(flowPane);
TextInput textInput = new TextInput();
textInput.setTextSize(10);
textInput.setMaximumLength(10);
textInput.setValidator(new IntValidator());
textInput.setText(scope == null ? "" : String.valueOf(scope.start));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInputLocal = (TextInput) component;
Scope scopeLocal = (Scope) dictionary.get(key);
try {
int start = Integer.parseInt(textInputLocal.getText());
dictionary.put(key, new Scope(start, scopeLocal == null ? start : scopeLocal.end, scopeLocal == null ? start : scopeLocal.extent));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInputLocal.setText(scopeLocal == null ? "" : String.valueOf(scopeLocal.start));
}
}
}
});
Label label = new Label("start");
label.getStyles().put(Style.font, "{italic:true}");
flowPane.add(label);
flowPane = new FlowPane();
flowPane.getStyles().put(Style.alignToBaseline, true);
flowPane.getStyles().put(Style.horizontalSpacing, 5);
boxPane.add(flowPane);
textInput = new TextInput();
textInput.setTextSize(10);
textInput.setMaximumLength(10);
textInput.setValidator(new IntValidator());
textInput.setText(scope == null ? "" : String.valueOf(scope.end));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInputLocal = (TextInput) component;
Scope scopeLocal = (Scope) dictionary.get(key);
try {
int end = Integer.parseInt(textInputLocal.getText());
dictionary.put(key, new Scope(scopeLocal == null ? end : scopeLocal.start, end, scopeLocal == null ? end : scopeLocal.extent));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInputLocal.setText(scopeLocal == null ? "" : String.valueOf(scopeLocal.end));
}
}
}
});
label = new Label("end");
label.getStyles().put(Style.font, "{italic:true}");
flowPane.add(label);
flowPane = new FlowPane();
flowPane.getStyles().put(Style.alignToBaseline, true);
flowPane.getStyles().put(Style.horizontalSpacing, 5);
boxPane.add(flowPane);
textInput = new TextInput();
textInput.setTextSize(10);
textInput.setMaximumLength(10);
textInput.setValidator(new IntValidator());
textInput.setText(scope == null ? "" : String.valueOf(scope.extent));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInputLocal = (TextInput) component;
Scope scopeLocal = (Scope) dictionary.get(key);
try {
int extent = Integer.parseInt(textInputLocal.getText());
dictionary.put(key, new Scope(scopeLocal == null ? extent : scopeLocal.start, scopeLocal == null ? extent : scopeLocal.end, extent));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInputLocal.setText(scopeLocal == null ? "" : String.valueOf(scopeLocal.extent));
}
}
}
});
label = new Label("extent");
label.getStyles().put(Style.font, "{italic:true}");
flowPane.add(label);
return boxPane;
}
use of org.apache.pivot.wtk.Label in project pivot by apache.
the class ComponentInspectorSkin method addDimensionsControl.
private static Component addDimensionsControl(final Dictionary<String, Object> dictionary, final String key, Form.Section section) {
Dimensions dimensions = (Dimensions) dictionary.get(key);
BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
section.add(boxPane);
Form.setLabel(boxPane, key);
FlowPane flowPane = new FlowPane();
flowPane.getStyles().put(Style.alignToBaseline, true);
flowPane.getStyles().put(Style.horizontalSpacing, 5);
boxPane.add(flowPane);
TextInput textInput = new TextInput();
textInput.setTextSize(4);
textInput.setMaximumLength(5);
textInput.setValidator(new IntValidator());
textInput.setText(String.valueOf(dimensions.width));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInputLocal = (TextInput) component;
Dimensions dimensionsLocal = (Dimensions) dictionary.get(key);
try {
int width = Integer.parseInt(textInputLocal.getText());
dictionary.put(key, new Dimensions(width, dimensionsLocal.height));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInputLocal.setText(String.valueOf(dimensionsLocal.width));
}
}
}
});
Label label = new Label("width");
label.getStyles().put(Style.font, "{italic:true}");
flowPane.add(label);
flowPane = new FlowPane();
flowPane.getStyles().put(Style.alignToBaseline, true);
flowPane.getStyles().put(Style.horizontalSpacing, 5);
boxPane.add(flowPane);
textInput = new TextInput();
textInput.setTextSize(4);
textInput.setMaximumLength(5);
textInput.setValidator(new IntValidator());
textInput.setText(String.valueOf(dimensions.height));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInputLocal = (TextInput) component;
Dimensions dimensionsLocal = (Dimensions) dictionary.get(key);
try {
int height = Integer.parseInt(textInputLocal.getText());
dictionary.put(key, new Dimensions(dimensionsLocal.width, height));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInputLocal.setText(String.valueOf(dimensionsLocal.height));
}
}
}
});
label = new Label("height");
label.getStyles().put(Style.font, "{italic:true}");
flowPane.add(label);
return boxPane;
}
use of org.apache.pivot.wtk.Label in project pivot by apache.
the class ComponentInspectorSkin method addLimitsControl.
private static Component addLimitsControl(final Dictionary<String, Object> dictionary, final String key, Form.Section section) {
Limits limits = (Limits) dictionary.get(key);
BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
section.add(boxPane);
Form.setLabel(boxPane, key);
FlowPane flowPane = new FlowPane();
flowPane.getStyles().put(Style.alignToBaseline, true);
flowPane.getStyles().put(Style.horizontalSpacing, 5);
boxPane.add(flowPane);
TextInput textInput = new TextInput();
textInput.setTextSize(10);
textInput.setMaximumLength(10);
textInput.setValidator(new IntValidator());
textInput.setText(String.valueOf(limits.minimum));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInputLocal = (TextInput) component;
Limits limitsLocal = (Limits) dictionary.get(key);
try {
int min = Integer.parseInt(textInputLocal.getText());
dictionary.put(key, new Limits(min, limitsLocal.maximum));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInputLocal.setText(String.valueOf(limitsLocal.minimum));
}
}
}
});
Label label = new Label("min");
label.getStyles().put(Style.font, "{italic:true}");
flowPane.add(label);
flowPane = new FlowPane();
flowPane.getStyles().put(Style.alignToBaseline, true);
flowPane.getStyles().put(Style.horizontalSpacing, 5);
boxPane.add(flowPane);
textInput = new TextInput();
textInput.setTextSize(10);
textInput.setMaximumLength(10);
textInput.setValidator(new IntValidator());
textInput.setText(String.valueOf(limits.maximum));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInputLocal = (TextInput) component;
Limits limitsLocal = (Limits) dictionary.get(key);
try {
int max = Integer.parseInt(textInputLocal.getText());
dictionary.put(key, new Limits(limitsLocal.minimum, max));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInputLocal.setText(String.valueOf(limitsLocal.maximum));
}
}
}
});
label = new Label("max");
label.getStyles().put(Style.font, "{italic:true}");
flowPane.add(label);
return boxPane;
}
use of org.apache.pivot.wtk.Label in project pivot by apache.
the class Pivot964Pivot method startup.
@Override
public void startup(Display display, Map<String, String> properties) {
// force dimensions for host frame
display.getHostWindow().setSize(1028, 600);
window = new Window();
prepareSVG();
final ImageView image = new ImageView(new Drawing(diagram));
BoxPane bp = new BoxPane();
TablePane tp = new TablePane();
setStyles(tp, "{padding: 4}");
TablePane.Column c1 = new TablePane.Column(-1);
TablePane.Column c2 = new TablePane.Column(-1);
tp.getColumns().add(c1);
tp.getColumns().add(c2);
TablePane.Row r1 = new TablePane.Row(-1);
TablePane.Row r2 = new TablePane.Row(-1);
TablePane.Row r3 = new TablePane.Row(-1);
PushButton pb1 = new PushButton("Visible");
PushButton pb2 = new PushButton("Invisible (bug)");
r1.add(pb1);
r1.add(pb2);
final Spinner sp1 = new Spinner(new ListAdapter<>(spinnerData));
sp1.setPreferredWidth(80);
sp1.setSelectedIndex(0);
final Spinner sp2 = new Spinner(new ListAdapter<>(spinnerData));
sp2.setPreferredWidth(80);
sp2.setSelectedIndex(0);
BoxPane bp1 = new BoxPane();
setStyles(bp1, "{verticalAlignment:'center', padding: 4, spacing: 2}");
bp1.add(new Label("X:"));
bp1.add(sp1);
r2.add(bp1);
BoxPane bp2 = new BoxPane();
setStyles(bp2, "{verticalAlignment:'center', padding: 4, spacing: 2}");
bp2.add(new Label("Y:"));
bp2.add(sp2);
r2.add(bp2);
tp.getRows().add(r1);
tp.getRows().add(r2);
r3.add(new Label(" Max X=507"));
r3.add(new Label(" Max Y=269"));
tp.getRows().add(r3);
bp.add(image);
bp.add(tp);
pb1.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button arg0) {
try {
root.setAttribute("viewBox", AnimationElement.AT_XML, "0 0 2368 1652");
root.updateTime(0f);
image.repaint();
} catch (SVGElementException e) {
e.printStackTrace();
} catch (SVGException e) {
e.printStackTrace();
}
}
});
pb2.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button arg0) {
try {
String xOffset = (String) sp1.getSelectedItem();
String yOffset = (String) sp2.getSelectedItem();
String viewBox = String.format("%1$s %2$s 2368 1652", xOffset, yOffset);
root.setAttribute("viewBox", AnimationElement.AT_XML, viewBox);
root.updateTime(0f);
image.repaint();
} catch (SVGElementException e) {
e.printStackTrace();
} catch (SVGException e) {
e.printStackTrace();
}
}
});
window.setContent(bp);
window.setMaximized(true);
window.open(display);
}
use of org.apache.pivot.wtk.Label in project pivot by apache.
the class BXMLExplorerDocument method setComponentIconOnTreeNode.
private static void setComponentIconOnTreeNode(TreeNode treeNode, Object comp) {
String resource = null;
if (comp instanceof Label) {
resource = "label.png";
}
if (comp instanceof ImageView) {
resource = "/org/apache/pivot/tutorials/IMG_0725_2.jpg";
}
if (comp instanceof PushButton) {
resource = "pushbutton.png";
}
if (comp instanceof RadioButton) {
resource = "radiobutton.png";
}
if (comp instanceof Checkbox) {
resource = "checkbox.png";
}
if (comp instanceof LinkButton) {
resource = "linkbutton.png";
}
if (comp instanceof TablePane) {
resource = "tablepane.png";
}
if (resource != null) {
URL url = BXMLExplorerDocument.class.getResource(resource);
if (url == null) {
throw new IllegalStateException("could not load resource " + resource);
}
treeNode.setIcon(url);
}
}
Aggregations