You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2018/09/11 16:34:37 UTC
svn commit: r1840591 - in /pivot/trunk:
tests/src/org/apache/pivot/tests/VerticalButtonTest.java
wtk/src/org/apache/pivot/wtk/content/VerticalButtonDataRenderer.java
Author: rwhitcomb
Date: Tue Sep 11 16:34:37 2018
New Revision: 1840591
URL: http://svn.apache.org/viewvc?rev=1840591&view=rev
Log:
PIVOT-1040: Add the (simple) renderer that allows these vertical buttons.
Add a test program to illustrate/test the renderer.
Added:
pivot/trunk/tests/src/org/apache/pivot/tests/VerticalButtonTest.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/content/VerticalButtonDataRenderer.java
Added: pivot/trunk/tests/src/org/apache/pivot/tests/VerticalButtonTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/VerticalButtonTest.java?rev=1840591&view=auto
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/VerticalButtonTest.java (added)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/VerticalButtonTest.java Tue Sep 11 16:34:37 2018
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.tests;
+
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.wtk.Alert;
+import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.DesktopApplicationContext;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.Frame;
+import org.apache.pivot.wtk.PushButton;
+import org.apache.pivot.wtk.TextPane;
+import org.apache.pivot.wtk.content.ButtonData;
+import org.apache.pivot.wtk.content.VerticalButtonDataRenderer;
+import org.apache.pivot.wtk.media.Image;
+import org.apache.pivot.wtk.text.ComponentNode;
+import org.apache.pivot.wtk.text.Document;
+import org.apache.pivot.wtk.text.Paragraph;
+import org.apache.pivot.wtk.text.TextNode;
+
+
+public final class VerticalButtonTest implements Application {
+ private Frame frame = null;
+
+ private void browse() {
+ try {
+ Desktop.getDesktop().browse(new URI("https://pivot.apache.org"));
+ } catch (URISyntaxException | IOException ex) {
+ Alert.alert(ex.getMessage(), frame);
+ }
+ }
+
+ @Override
+ public void startup(final Display display, final Map<String, String> properties) throws Exception {
+ frame = new Frame();
+ frame.setTitle("Vertical Button Test");
+ frame.setPreferredSize(480, 360);
+
+ Image image = Image.load(getClass().getResource("go-home.png"));
+ PushButton button1 = new PushButton(new ButtonData(image, "Home"));
+ button1.setDataRenderer(new VerticalButtonDataRenderer());
+ button1.getButtonPressListeners().add((button) -> browse());
+ TextPane textPane = new TextPane();
+ Document document = new Document();
+ TextNode text1 = new TextNode("Link to the Apache Pivot site: ");
+ ComponentNode compNode1 = new ComponentNode(button1);
+ Paragraph para1 = new Paragraph();
+ para1.add(text1);
+ document.add(para1);
+ document.add(compNode1);
+ textPane.setDocument(document);
+
+ frame.setContent(textPane);
+
+ frame.open(display);
+ }
+
+ @Override
+ public boolean shutdown(final boolean optional) {
+ if (frame != null) {
+ frame.close();
+ }
+
+ return false;
+ }
+
+ public static void main(final String[] args) {
+ DesktopApplicationContext.main(VerticalButtonTest.class, args);
+ }
+}
Added: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/VerticalButtonDataRenderer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/VerticalButtonDataRenderer.java?rev=1840591&view=auto
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/VerticalButtonDataRenderer.java (added)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/VerticalButtonDataRenderer.java Tue Sep 11 16:34:37 2018
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.wtk.content;
+
+import org.apache.pivot.wtk.Orientation;
+
+/**
+ * A button data renderer that just positions the image and label vertically
+ * on top of each other.
+ */
+public class VerticalButtonDataRenderer extends ButtonDataRenderer {
+ public VerticalButtonDataRenderer() {
+ super();
+ setOrientation(Orientation.VERTICAL);
+ }
+}