use of org.apache.pivot.wtk.ButtonPressListener 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.ButtonPressListener in project pivot by apache.
the class PushButtons method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
pushButton = (PushButton) namespace.get("pushButton");
pushButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
Alert.alert(MessageType.INFO, "You clicked me!", PushButtons.this);
}
});
}
use of org.apache.pivot.wtk.ButtonPressListener in project pivot by apache.
the class Transitions method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
button1 = (PushButton) namespace.get("button1");
button2 = (PushButton) namespace.get("button2");
button3 = (PushButton) namespace.get("button3");
button4 = (PushButton) namespace.get("button4");
ButtonPressListener buttonPressListener = new ButtonPressListener() {
@Override
public void buttonPressed(final Button button) {
if (collapseTransition == null) {
collapseTransition = new CollapseTransition(button, TRANSITION_DURATION, TRANSITION_RATE);
TransitionListener transitionListener = new TransitionListener() {
@Override
public void transitionCompleted(Transition transition) {
CollapseTransition collapseTransitionLocal = (CollapseTransition) transition;
if (!transition.isReversed()) {
Component component = collapseTransitionLocal.getComponent();
component.getParent().remove(component);
}
Transitions.this.collapseTransition = null;
}
};
collapseTransition.start(transitionListener);
} else {
collapseTransition.reverse();
if (collapseTransition.getComponent() != button) {
collapseTransition.end();
}
}
}
};
button1.getButtonPressListeners().add(buttonPressListener);
button2.getButtonPressListeners().add(buttonPressListener);
button3.getButtonPressListeners().add(buttonPressListener);
button4.getButtonPressListeners().add(buttonPressListener);
}
use of org.apache.pivot.wtk.ButtonPressListener in project pivot by apache.
the class Pivot718 method controlTree.
private void controlTree(BXMLSerializer bxmlSerializer) {
treeDelButton = (PushButton) bxmlSerializer.getNamespace().get("treeDelButton");
tree = (TreeView) bxmlSerializer.getNamespace().get("tree");
tree.getTreeViewSelectionListeners().add(new TreeViewSelectionListener() {
@Override
public void selectedPathAdded(TreeView treeView, Path path) {
System.out.println("selectedPathAdded");
}
@Override
public void selectedPathRemoved(TreeView treeView, Path path) {
System.out.println("selectedPathRemoved");
}
@Override
public void selectedPathsChanged(TreeView treeView, Sequence<Path> previousSelectedPaths) {
System.out.println("selectedPathsChanged");
}
@Override
public void selectedNodeChanged(TreeView treeView, Object previousSelectedNode) {
System.out.println("selectedNodeChanged");
}
});
treeDelButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
TreeNode selectedNode = (TreeNode) tree.getSelectedNode();
System.out.println("delete :: " + selectedNode);
if (selectedNode != null) {
TreeBranch parent = selectedNode.getParent();
if (parent != null) {
parent.remove(selectedNode);
}
}
}
});
}
use of org.apache.pivot.wtk.ButtonPressListener in project pivot by apache.
the class Pivot734 method controlTree.
private void controlTree(BXMLSerializer bxmlSerializer) {
treeButtonAdd = (PushButton) bxmlSerializer.getNamespace().get("treeButtonAdd");
treeButtonRemove = (PushButton) bxmlSerializer.getNamespace().get("treeButtonRemove");
tree = (TreeView) bxmlSerializer.getNamespace().get("tree");
boolean treeStyleForShowEmptyBranchControls = tree.getStyles().getBoolean(Style.showEmptyBranchControls);
System.out.println("tree style for showEmptyBranchControls is " + treeStyleForShowEmptyBranchControls);
tree.getTreeViewSelectionListeners().add(new TreeViewSelectionListener() {
@Override
public void selectedPathAdded(TreeView treeView, Path path) {
System.out.println("selectedPathAdded");
}
@Override
public void selectedPathRemoved(TreeView treeView, Path path) {
System.out.println("selectedPathRemoved");
}
@Override
public void selectedPathsChanged(TreeView treeView, Sequence<Path> previousSelectedPaths) {
System.out.println("selectedPathsChanged");
}
@Override
public void selectedNodeChanged(TreeView treeView, Object previousSelectedNode) {
System.out.println("selectedNodeChanged");
}
});
treeButtonAdd.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
Object x = tree.getSelectedNode();
System.out.println("add a 'new branch' element to the selected element :: " + x);
if (x != null && x instanceof TreeBranch) {
((TreeBranch) x).add(newBranch);
}
}
});
treeButtonRemove.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
Object x = tree.getSelectedNode();
System.out.println("remove a 'new branch' element under the selected element :: " + x);
if (x != null && x instanceof TreeBranch) {
((TreeBranch) x).remove(newBranch);
}
}
});
}
Aggregations