You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/11/03 15:41:30 UTC

svn commit: r832438 - in /incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer: ./ navigation/

Author: tvolkert
Date: Tue Nov  3 14:41:29 2009
New Revision: 832438

URL: http://svn.apache.org/viewvc?rev=832438&view=rev
Log:
Final components added to component explorer

Added:
    incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/IMG_1147.jpg   (with props)
    incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/Ruler.java
    incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/RulerListener.java
    incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/RulerSkin.java
    incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/panorama.wtkx
    incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/scroll_pane.wtkx
Modified:
    incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java
    incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/component_explorer.wtkx

Modified: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java?rev=832438&r1=832437&r2=832438&view=diff
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java (original)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java Tue Nov  3 14:41:29 2009
@@ -269,7 +269,10 @@
 
             // Ensure that it's visible to the user
             Path branchPath = new Path(initialSelectedPath, initialSelectedPath.getLength() - 1);
-            treeView.expandBranch(branchPath);
+            while (branchPath.getLength() > 0) {
+                treeView.expandBranch(branchPath);
+                branchPath.remove(branchPath.getLength() - 1, 1);
+            }
 
             final Path path = initialSelectedPath;
             ApplicationContext.queueCallback(new Runnable() {

Added: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/IMG_1147.jpg
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/IMG_1147.jpg?rev=832438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/IMG_1147.jpg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/component_explorer.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/component_explorer.wtkx?rev=832438&r1=832437&r2=832438&view=diff
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/component_explorer.wtkx (original)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/component_explorer.wtkx Tue Nov  3 14:41:29 2009
@@ -369,7 +369,8 @@
                                         <corner>
                                             <BoxPane styles="{padding:{right:6},
                                                 horizontalAlignment:'right', fill:true}">
-                                                <MenuButton styles="{toolbar:true}">
+                                                <MenuButton styles="{toolbar:true,
+                                                    padding:{top:1, left:2, bottom:1, right:2}}">
                                                     <wtkx:define>
                                                         <ButtonGroup wtkx:id="horizontalScrollBarPolicyGroup"/>
                                                         <ButtonGroup wtkx:id="verticalScrollBarPolicyGroup"/>
@@ -483,7 +484,8 @@
                                 <corner>
                                     <BoxPane styles="{padding:{right:6},
                                         horizontalAlignment:'right', fill:true}">
-                                        <MenuButton styles="{toolbar:true}">
+                                        <MenuButton styles="{toolbar:true,
+                                            padding:{top:1, left:2, bottom:1, right:2}}">
                                             <buttonData>
                                                 <content:ButtonData icon="@preferences-system.png"/>
                                             </buttonData>

Added: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/Ruler.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/Ruler.java?rev=832438&view=auto
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/Ruler.java (added)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/Ruler.java Tue Nov  3 14:41:29 2009
@@ -0,0 +1,67 @@
+/*
+ * 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.demos.explorer.navigation;
+
+import org.apache.pivot.util.ListenerList;
+import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.Orientation;
+
+public class Ruler extends Component {
+    private static class RulerListenerList extends ListenerList<RulerListener>
+        implements RulerListener {
+        public void orientationChanged(Ruler ruler) {
+            for (RulerListener listener : this) {
+                listener.orientationChanged(ruler);
+            }
+        }
+    }
+
+    private Orientation orientation;
+
+    private RulerListenerList rulerListeners = new RulerListenerList();
+
+    public Ruler() {
+        setSkin(new RulerSkin());
+    }
+
+    public Orientation getOrientation() {
+        return orientation;
+    }
+
+    public void setOrientation(Orientation orientation) {
+        if (orientation == null) {
+            throw new IllegalArgumentException();
+        }
+
+        if (this.orientation != orientation) {
+            this.orientation = orientation;
+            rulerListeners.orientationChanged(this);
+        }
+    }
+
+    public void setOrientation(String orientation) {
+        if (orientation == null) {
+            throw new IllegalArgumentException();
+        }
+
+        setOrientation(Orientation.valueOf(orientation.toUpperCase()));
+    }
+
+    public ListenerList<RulerListener> getRulerListeners() {
+        return rulerListeners;
+    }
+}

Added: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/RulerListener.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/RulerListener.java?rev=832438&view=auto
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/RulerListener.java (added)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/RulerListener.java Tue Nov  3 14:41:29 2009
@@ -0,0 +1,21 @@
+/*
+ * 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.demos.explorer.navigation;
+
+public interface RulerListener {
+    public void orientationChanged(Ruler ruler);
+}

Added: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/RulerSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/RulerSkin.java?rev=832438&view=auto
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/RulerSkin.java (added)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/RulerSkin.java Tue Nov  3 14:41:29 2009
@@ -0,0 +1,104 @@
+/*
+ * 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.demos.explorer.navigation;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+
+import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.Orientation;
+import org.apache.pivot.wtk.skin.ComponentSkin;
+
+class RulerSkin extends ComponentSkin implements RulerListener {
+    @Override
+    public void install(Component component) {
+        super.install(component);
+
+        Ruler ruler = (Ruler)component;
+        ruler.getRulerListeners().add(this);
+    }
+
+    @Override
+    public void layout() {
+        // No-op
+    }
+
+    @Override
+    public int getPreferredHeight(int width) {
+        Ruler ruler = (Ruler)getComponent();
+        Orientation orientation = ruler.getOrientation();
+
+        return (orientation == Orientation.HORIZONTAL) ? 20 : 0;
+    }
+
+    @Override
+    public int getPreferredWidth(int height) {
+        Ruler ruler = (Ruler)getComponent();
+        Orientation orientation = ruler.getOrientation();
+
+        return (orientation == Orientation.VERTICAL) ? 20 : 0;
+    }
+
+    @Override
+    public void paint(Graphics2D graphics) {
+        int width = getWidth();
+        int height = getHeight();
+
+        Ruler ruler = (Ruler)getComponent();
+
+        graphics.setColor(new Color(0xFF, 0xFF, 0xE0));
+        graphics.fillRect(0, 0, width, height);
+
+        graphics.setColor(Color.BLACK);
+        graphics.drawRect(0, 0, width - 1, height - 1);
+
+        Orientation orientation = ruler.getOrientation();
+        switch (orientation) {
+            case HORIZONTAL: {
+                for (int i = 0, n = width / 5 + 1; i < n; i++) {
+                    int x = i * 5;
+
+                    if (i % 4 == 0) {
+                        graphics.drawLine(x, 0, x, height / 2);
+                    } else {
+                        graphics.drawLine(x, 0, x, height / 4);
+                    }
+                }
+
+                break;
+            }
+
+            case VERTICAL: {
+                for (int i = 0, n = height / 5 + 1; i < n; i++) {
+                    int y = i * 5;
+
+                    if (i % 4 == 0) {
+                        graphics.drawLine(0, y, width / 2, y);
+                    } else {
+                        graphics.drawLine(0, y, width / 4, y);
+                    }
+                }
+
+                break;
+            }
+        }
+    }
+
+    public void orientationChanged(Ruler ruler) {
+        invalidateComponent();
+    }
+}

Added: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/panorama.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/panorama.wtkx?rev=832438&view=auto
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/panorama.wtkx (added)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/panorama.wtkx Tue Nov  3 14:41:29 2009
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<Panorama xmlns:wtkx="http://pivot.apache.org/wtkx"
+    xmlns="org.apache.pivot.wtk">
+    <view>
+        <ImageView image="org/apache/pivot/demos/explorer/IMG_1147.jpg"
+            tooltipText="Pemaquid Point Lighthouse, Bristol ME"/>
+    </view>
+</Panorama>

Added: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/scroll_pane.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/scroll_pane.wtkx?rev=832438&view=auto
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/scroll_pane.wtkx (added)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/navigation/scroll_pane.wtkx Tue Nov  3 14:41:29 2009
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<ScrollPane xmlns:wtkx="http://pivot.apache.org/wtkx"
+    xmlns:navigation="org.apache.pivot.demos.explorer.navigation"
+    xmlns="org.apache.pivot.wtk">
+    <view>
+        <ImageView image="org/apache/pivot/demos/explorer/IMG_1147.jpg"
+            tooltipText="Pemaquid Point Lighthouse, Bristol ME"/>
+    </view>
+    <columnHeader>
+        <navigation:Ruler orientation="horizontal"/>
+    </columnHeader>
+    <rowHeader>
+        <navigation:Ruler orientation="vertical"/>
+    </rowHeader>
+</ScrollPane>