You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/10/02 02:45:00 UTC
svn commit: r1003722 [5/5] - in /pivot/trunk:
demos/src/org/apache/pivot/demos/clock/
examples/src/org/apache/pivot/examples/svg/ tests/src/org/apache/pivot/tests/
tutorials/src/org/apache/pivot/tutorials/drawing/
tutorials/src/org/apache/pivot/tutoria...
Modified: pivot/trunk/tests/src/org/apache/pivot/tests/EnumBean.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/EnumBean.java?rev=1003722&r1=1003721&r2=1003722&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/EnumBean.java (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/EnumBean.java Sat Oct 2 00:44:59 2010
@@ -45,8 +45,6 @@ import org.apache.pivot.wtk.TreeView;
import org.apache.pivot.wtk.VerticalAlignment;
import org.apache.pivot.wtk.media.BufferedImageSerializer;
import org.apache.pivot.wtk.media.Picture;
-import org.apache.pivot.wtk.media.drawing.Arc;
-import org.apache.pivot.wtk.media.drawing.Path;
import org.apache.pivot.wtk.skin.CardPaneSkin;
import org.apache.pivot.wtk.text.BulletedList;
import org.apache.pivot.wtk.text.NumberedList;
@@ -64,7 +62,6 @@ public class EnumBean {
// Public non-static field for testing BeanAdapter#get("~orientationField");
public Orientation orientationField;
- private Arc.Type arcType;
private BindType bindType;
private BufferedImageSerializer.Format bufferedImageSerializerFormat;
private BulletedList.Style bulletedListStyle;
@@ -86,7 +83,6 @@ public class EnumBean {
private Mouse.ScrollType mouseScrollType;
private NumberedList.Style numberedListStyle;
private Orientation orientation;
- private Path.WindingRule windingRule;
private Picture.Interpolation interpolation;
private Query.Method queryMethod;
private ScrollPane.Corner.Placement placement;
@@ -103,14 +99,6 @@ public class EnumBean {
private VerticalAlignment verticalAlignment;
private Vote vote;
- public Arc.Type getArcType() {
- return arcType;
- }
-
- public void setArcType(Arc.Type arcType) {
- this.arcType = arcType;
- }
-
public BindType getBindType() {
return bindType;
}
@@ -280,14 +268,6 @@ public class EnumBean {
this.orientation = orientation;
}
- public Path.WindingRule getWindingRule() {
- return windingRule;
- }
-
- public void setWindingRule(Path.WindingRule windingRule) {
- this.windingRule = windingRule;
- }
-
public Picture.Interpolation getInterpolation() {
return interpolation;
}
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/panels.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/panels.bxml?rev=1003722&r1=1003721&r2=1003722&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/panels.bxml (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/panels.bxml Sat Oct 2 00:44:59 2010
@@ -20,30 +20,12 @@ limitations under the License.
xmlns:bxml="http://pivot.apache.org/bxml"
xmlns:media="org.apache.pivot.wtk.media"
xmlns="org.apache.pivot.wtk">
- <StackPane>
- <ImageView styles="{horizontalAlignment:'left', verticalAlignment:'top'}">
- <media:Drawing xmlns="org.apache.pivot.wtk.media.drawing">
- <Canvas>
- <Rectangle x="20" y="20" width="320" height="240"
- fill="{paintType:'gradient',
- startX:0, startY:0, startColor:'#4444ff',
- endX:320, endY:240, endColor:'#000044'}"
- stroke="#0000aa" strokeThickness="4"
- cornerRadius="10"/>
- </Canvas>
- </media:Drawing>
- </ImageView>
-
- <Panel>
- <PushButton buttonData="Button 1"
- styles="{color:'#ffffff', backgroundColor:'#000066', borderColor:'#0000dd'}"
- x="30" y="30" width="120" height="24"/>
- <PushButton buttonData="Button 2"
- styles="{color:'#ffffff', backgroundColor:'#000066', borderColor:'#0000dd'}"
- x="30" y="60" width="120" height="24"/>
- <PushButton buttonData="Button 3"
- styles="{color:'#ffffff', backgroundColor:'#000066', borderColor:'#0000dd'}"
- x="30" y="90" width="120" height="24"/>
- </Panel>
- </StackPane>
+ <Panel>
+ <PushButton buttonData="Button 1"
+ x="20" y="20" width="120" height="24"/>
+ <PushButton buttonData="Button 2"
+ x="40" y="50" width="120" height="24"/>
+ <PushButton buttonData="Button 3"
+ x="60" y="80" width="120" height="24"/>
+ </Panel>
</Window>
Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/lists/RepeatableListButtons.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/lists/RepeatableListButtons.java?rev=1003722&view=auto
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/lists/RepeatableListButtons.java (added)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/lists/RepeatableListButtons.java Sat Oct 2 00:44:59 2010
@@ -0,0 +1,31 @@
+/*
+ * 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.tutorials.lists;
+
+import java.net.URL;
+
+import org.apache.pivot.beans.Bindable;
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.util.Resources;
+import org.apache.pivot.wtk.Window;
+
+public class RepeatableListButtons extends Window implements Bindable {
+ @Override
+ public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
+ // TODO
+ }
+}
Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/lists/repeatable_list_buttons.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/lists/repeatable_list_buttons.bxml?rev=1003722&view=auto
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/lists/repeatable_list_buttons.bxml (added)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/lists/repeatable_list_buttons.bxml Sat Oct 2 00:44:59 2010
@@ -0,0 +1,24 @@
+<?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.
+-->
+
+<lists:ListButtons title="List Buttons" maximized="true"
+ xmlns:bxml="http://pivot.apache.org/bxml"
+ xmlns:lists="org.apache.pivot.tutorials.lists"
+ xmlns="org.apache.pivot.wtk">
+ <!-- TODO -->
+</lists:ListButtons>
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuButtons.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuButtons.java?rev=1003722&r1=1003721&r2=1003722&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuButtons.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuButtons.java Sat Oct 2 00:44:59 2010
@@ -16,92 +16,16 @@
*/
package org.apache.pivot.tutorials.menus;
-import java.awt.Color;
-import java.awt.Paint;
import java.net.URL;
import org.apache.pivot.beans.Bindable;
import org.apache.pivot.collections.Map;
import org.apache.pivot.util.Resources;
-import org.apache.pivot.wtk.Action;
-import org.apache.pivot.wtk.Bounds;
-import org.apache.pivot.wtk.Component;
-import org.apache.pivot.wtk.ListButton;
-import org.apache.pivot.wtk.Point;
import org.apache.pivot.wtk.Window;
-import org.apache.pivot.wtk.content.ColorItem;
-import org.apache.pivot.wtk.media.Drawing;
-import org.apache.pivot.wtk.media.drawing.Ellipse;
-import org.apache.pivot.wtk.media.drawing.Rectangle;
-import org.apache.pivot.wtk.media.drawing.Shape;
-import org.apache.pivot.wtk.media.drawing.Text;
public class MenuButtons extends Window implements Bindable {
- private ListButton colorListButton = null;
- private Drawing drawing = null;
- private Rectangle border = null;
-
- public MenuButtons() {
- Action.getNamedActions().put("newCircle", new Action() {
- @Override
- public void perform(Component source) {
- Ellipse ellipse = new Ellipse();
- ellipse.setSize(50, 50);
-
- ellipse.setStroke((Paint)null);
- ellipse.setFill(getSelectedColor());
- ellipse.setOrigin(getRandomLocation(ellipse));
-
- drawing.getCanvas().add(ellipse);
- }
- });
-
- Action.getNamedActions().put("newSquare", new Action() {
- @Override
- public void perform(Component source) {
- Rectangle rectangle = new Rectangle();
- rectangle.setSize(50, 50);
-
- rectangle.setStroke((Paint)null);
- rectangle.setFill(getSelectedColor());
- rectangle.setOrigin(getRandomLocation(rectangle));
-
- drawing.getCanvas().add(rectangle);
- }
- });
-
- Action.getNamedActions().put("newText", new Action() {
- @Override
- public void perform(Component source) {
- Text text = new Text();
- text.setText("ABC");
- text.setFont("Arial BOLD 24");
-
- text.setFill(getSelectedColor());
- text.setOrigin(getRandomLocation(text));
-
- drawing.getCanvas().add(text);
- }
- });
- }
-
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
- colorListButton = (ListButton)namespace.get("colorListButton");
- drawing = (Drawing)namespace.get("drawing");
- border = (Rectangle)namespace.get("border");
- }
-
- public Color getSelectedColor() {
- ColorItem colorItem = (ColorItem)colorListButton.getSelectedItem();
- return colorItem.getColor();
- }
-
- public Point getRandomLocation(Shape shape) {
- Bounds bounds = shape.getBounds();
- int x = (int)(Math.random() * (border.getWidth() - bounds.width));
- int y = (int)(Math.random() * (border.getHeight() - bounds.height));
-
- return new Point(x, y);
+ // TODO
}
}
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_buttons.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_buttons.bxml?rev=1003722&r1=1003721&r2=1003722&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_buttons.bxml (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_buttons.bxml Sat Oct 2 00:44:59 2010
@@ -21,72 +21,5 @@ limitations under the License.
xmlns:content="org.apache.pivot.wtk.content"
xmlns:menus="org.apache.pivot.tutorials.menus"
xmlns="org.apache.pivot.wtk">
- <TablePane styles="{verticalSpacing:2}">
- <columns>
- <TablePane.Column width="1*"/>
- </columns>
-
- <TablePane.Row height="-1">
- <BoxPane styles="{fill:true}">
- <MenuButton>
- <buttonData>
- <content:ButtonData icon="@shape_square_add.png" text="New Shape"/>
- </buttonData>
-
- <Menu>
- <Menu.Section>
- <Menu.Item buttonData="Circle" action="newCircle"/>
- <Menu.Item buttonData="Square" action="newSquare"/>
- <Menu.Item buttonData="Text" action="newText"/>
- </Menu.Section>
- </Menu>
- </MenuButton>
-
- <ListButton bxml:id="colorListButton" listSize="6" selectedIndex="0">
- <dataRenderer>
- <content:ListButtonColorItemRenderer/>
- </dataRenderer>
-
- <itemRenderer>
- <content:ListViewColorItemRenderer/>
- </itemRenderer>
-
- <content:ColorItem color="#000000" name="Black"/>
- <content:ColorItem color="#0000AA" name="Blue"/>
- <content:ColorItem color="#00AA00" name="Green"/>
- <content:ColorItem color="#00AAAA" name="Cyan"/>
- <content:ColorItem color="#AA0000" name="Red"/>
- <content:ColorItem color="#AA00AA" name="Magenta"/>
- <content:ColorItem color="#AA5500" name="Brown"/>
- <content:ColorItem color="#AAAAAA" name="Light Gray"/>
- <content:ColorItem color="#555555" name="Dark Gray"/>
- <content:ColorItem color="#5555FF" name="Bright Blue"/>
- <content:ColorItem color="#55FF55" name="Bright Green"/>
- <content:ColorItem color="#55FFFF" name="Bright Cyan"/>
- <content:ColorItem color="#FF5555" name="Bright Red"/>
- <content:ColorItem color="#FF55FF" name="Bright Magenta"/>
- <content:ColorItem color="#FFFF55" name="Bright Yellow"/>
- <content:ColorItem color="#FFFFFF" name="White"/>
- </ListButton>
- </BoxPane>
- </TablePane.Row>
-
- <TablePane.Row height="1*">
- <Border styles="{padding:2}">
- <ScrollPane horizontalScrollBarPolicy="fill_to_capacity"
- verticalScrollBarPolicy="fill_to_capacity">
- <ImageView bxml:id="imageView">
- <image>
- <Drawing bxml:id="drawing"
- xmlns="org.apache.pivot.wtk.media">
- <Canvas xmlns="org.apache.pivot.wtk.media.drawing">
- <Rectangle bxml:id="border" stroke="$bxml:null" fill="#eeeeee" width="480" height="360"/>
- </Canvas>
- </Drawing>
- </image>
- </ImageView>
- </ScrollPane>
- </Border>
- </TablePane.Row>
- </TablePane>
+ <!-- TODO -->
</menus:MenuButtons>
Modified: pivot/trunk/tutorials/www/index.xml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/www/index.xml?rev=1003722&r1=1003721&r2=1003722&view=diff
==============================================================================
--- pivot/trunk/tutorials/www/index.xml (original)
+++ pivot/trunk/tutorials/www/index.xml Sat Oct 2 00:44:59 2010
@@ -64,6 +64,7 @@ limitations under the License.
</document-item>
<document-item id="lists">
<document-item id="list-buttons"/>
+ <document-item id="repeatable-list-buttons"/>
</document-item>
<document-item id="text">
<document-item id="suggestion-popups"/>
Added: pivot/trunk/tutorials/www/repeatable-list-buttons.xml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/www/repeatable-list-buttons.xml?rev=1003722&view=auto
==============================================================================
--- pivot/trunk/tutorials/www/repeatable-list-buttons.xml (added)
+++ pivot/trunk/tutorials/www/repeatable-list-buttons.xml Sat Oct 2 00:44:59 2010
@@ -0,0 +1,58 @@
+<?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.
+-->
+
+<document id="repeatable-list-buttons">
+ <properties>
+ <title>Repeatable List Buttons</title>
+ </properties>
+
+ <body>
+ <p>The following example...</p>
+
+ <application class="org.apache.pivot.wtk.ScriptApplication"
+ width="480" height="340">
+ <libraries>
+ <library>core</library>
+ <library>wtk</library>
+ <library>wtk-terra</library>
+ <library>tutorials</library>
+ </libraries>
+ <startup-properties>
+ <src>org/apache/pivot/tutorials/lists/repeatable_list_buttons.wtkx</src>
+ </startup-properties>
+ </application>
+
+ <p>
+ The WTKX source for the example is...
+ </p>
+
+ <source type="xml" location="org/apache/pivot/tutorials/lists/repeatable_list_buttons.wtkx">
+ <![CDATA[
+ ]]>
+ </source>
+
+ <p>
+ The Java source for the example is below:
+ </p>
+
+ <source type="java" location="org/apache/pivot/tutorials/lists/RepeatableListButtons.java">
+ <![CDATA[
+ ]]>
+ </source>
+ </body>
+</document>
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java?rev=1003722&r1=1003721&r2=1003722&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java Sat Oct 2 00:44:59 2010
@@ -59,21 +59,21 @@ public class TerraCalendarButtonSkin ext
// Size and position the popup
Display display = calendarButton.getDisplay();
Dimensions displaySize = display.getSize();
-
+
Point buttonLocation = calendarButton.mapPointToAncestor(display, 0, 0);
window.setLocation(buttonLocation.x, buttonLocation.y + getHeight() - 1);
int width = getWidth();
- window.setMinimumWidth(width - TRIGGER_WIDTH - 1);
-
- int popupWidth = window.getPreferredWidth();
+ window.setMinimumWidth(width - TRIGGER_WIDTH - 1);
+
+ int popupWidth = window.getPreferredWidth();
if (buttonLocation.x + popupWidth > displaySize.width) {
window.setX(buttonLocation.x + width - popupWidth);
}
int popupHeight = window.getPreferredHeight();
int maximumHeight = displaySize.height - window.getY();
- if (popupHeight > maximumHeight
+ if (popupHeight > maximumHeight
&& buttonLocation.y > maximumHeight) {
window.setY(buttonLocation.y - window.getPreferredHeight() + 1);
}
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java?rev=1003722&r1=1003721&r2=1003722&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java Sat Oct 2 00:44:59 2010
@@ -57,21 +57,21 @@ public class TerraColorChooserButtonSkin
// Size and position the popup
Display display = colorChooserButton.getDisplay();
Dimensions displaySize = display.getSize();
-
+
Point buttonLocation = colorChooserButton.mapPointToAncestor(display, 0, 0);
window.setLocation(buttonLocation.x, buttonLocation.y + getHeight() - 1);
int width = getWidth();
- window.setMinimumWidth(width - TRIGGER_WIDTH - 1);
-
- int popupWidth = window.getPreferredWidth();
+ window.setMinimumWidth(width - TRIGGER_WIDTH - 1);
+
+ int popupWidth = window.getPreferredWidth();
if (buttonLocation.x + popupWidth > displaySize.width) {
window.setX(buttonLocation.x + width - popupWidth);
}
int popupHeight = window.getPreferredHeight();
int maximumHeight = displaySize.height - window.getY();
- if (popupHeight > maximumHeight
+ if (popupHeight > maximumHeight
&& buttonLocation.y > maximumHeight) {
window.setY(buttonLocation.y - window.getPreferredHeight() + 1);
}
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java?rev=1003722&r1=1003721&r2=1003722&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java Sat Oct 2 00:44:59 2010
@@ -79,29 +79,29 @@ public class TerraListButtonSkin extends
// Size and position the popup
Display display = listButton.getDisplay();
Dimensions displaySize = display.getSize();
-
+
Point buttonLocation = listButton.mapPointToAncestor(display, 0, 0);
window.setLocation(buttonLocation.x, buttonLocation.y + getHeight() - 1);
int width = getWidth();
window.setMinimumWidth(width - TRIGGER_WIDTH - 1);
-
- int popupWidth = window.getPreferredWidth();
+
+ int popupWidth = window.getPreferredWidth();
if (buttonLocation.x + popupWidth > displaySize.width) {
window.setX(buttonLocation.x + width - popupWidth);
}
-
- window.setMaximumHeight(Integer.MAX_VALUE);
+
+ window.setMaximumHeight(Integer.MAX_VALUE);
int popupHeight = window.getPreferredHeight();
int maximumHeight = displaySize.height - window.getY();
- if (popupHeight > maximumHeight
+ if (popupHeight > maximumHeight
&& buttonLocation.y > maximumHeight) {
window.setMaximumHeight(buttonLocation.y);
window.setY(buttonLocation.y - window.getPreferredHeight() + 1);
} else {
- window.setMaximumHeight(maximumHeight);
+ window.setMaximumHeight(maximumHeight);
}
-
+
repaintComponent();
ApplicationContext.queueCallback(new Runnable() {
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java?rev=1003722&r1=1003721&r2=1003722&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java Sat Oct 2 00:44:59 2010
@@ -72,29 +72,29 @@ public class TerraMenuButtonSkin extends
// Size and position the popup
Display display = menuButton.getDisplay();
Dimensions displaySize = display.getSize();
-
+
Point buttonLocation = menuButton.mapPointToAncestor(display, 0, 0);
window.setLocation(buttonLocation.x, buttonLocation.y + getHeight() - 1);
int width = getWidth();
window.setMinimumWidth(width - TRIGGER_WIDTH - 1);
-
- int popupWidth = window.getPreferredWidth();
+
+ int popupWidth = window.getPreferredWidth();
if (buttonLocation.x + popupWidth > displaySize.width) {
window.setX(buttonLocation.x + width - popupWidth);
}
-
- window.setMaximumHeight(Integer.MAX_VALUE);
+
+ window.setMaximumHeight(Integer.MAX_VALUE);
int popupHeight = window.getPreferredHeight();
int maximumHeight = displaySize.height - window.getY();
- if (popupHeight > maximumHeight
+ if (popupHeight > maximumHeight
&& buttonLocation.y > maximumHeight) {
window.setMaximumHeight(buttonLocation.y);
window.setY(buttonLocation.y - window.getPreferredHeight() + 1);
} else {
- window.setMaximumHeight(maximumHeight);
+ window.setMaximumHeight(maximumHeight);
}
-
+
repaintComponent();
}
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme_default.json
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme_default.json?rev=1003722&r1=1003721&r2=1003722&view=diff
==============================================================================
Binary files - no diff available.
Modified: pivot/trunk/wtk/.classpath
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/.classpath?rev=1003722&r1=1003721&r2=1003722&view=diff
==============================================================================
--- pivot/trunk/wtk/.classpath (original)
+++ pivot/trunk/wtk/.classpath Sat Oct 2 00:44:59 2010
@@ -4,5 +4,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="lib" path="lib/svgSalamander-tiny.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Added: pivot/trunk/wtk/lib/svgSalamander-tiny.jar
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/lib/svgSalamander-tiny.jar?rev=1003722&view=auto
==============================================================================
Binary file - no diff available.
Propchange: pivot/trunk/wtk/lib/svgSalamander-tiny.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Drawing.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Drawing.java?rev=1003722&r1=1003721&r2=1003722&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Drawing.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Drawing.java Sat Oct 2 00:44:59 2010
@@ -17,185 +17,82 @@
package org.apache.pivot.wtk.media;
import java.awt.Graphics2D;
-import java.awt.Paint;
import java.awt.RenderingHints;
-import org.apache.pivot.beans.DefaultProperty;
-import org.apache.pivot.util.ListenerList;
-import org.apache.pivot.wtk.Bounds;
-import org.apache.pivot.wtk.Dimensions;
-import org.apache.pivot.wtk.GraphicsUtilities;
-import org.apache.pivot.wtk.media.drawing.Canvas;
-import org.apache.pivot.wtk.media.drawing.CanvasListener;
+import org.apache.pivot.wtk.media.Image;
+
+import com.kitfox.svg.SVGDiagram;
+import com.kitfox.svg.SVGElementException;
+import com.kitfox.svg.SVGException;
+import com.kitfox.svg.SVGRoot;
+import com.kitfox.svg.animation.AnimationElement;
/**
- * Image representing a vector drawing.
+ * Image encapsulating an SVG diagram.
*/
-@DefaultProperty("canvas")
public class Drawing extends Image {
- private static class DrawingListenerList extends ListenerList<DrawingListener>
- implements DrawingListener {
- @Override
- public void canvasChanged(Drawing drawing, Canvas previousCanvas) {
- for (DrawingListener listener : this) {
- listener.canvasChanged(drawing, previousCanvas);
- }
- }
-
- @Override
- public void backgroundChanged(Drawing drawing, Paint previousBackground) {
- for (DrawingListener listener : this) {
- listener.backgroundChanged(drawing, previousBackground);
- }
- }
- }
-
- private Canvas canvas = null;
- private Paint background = null;
+ private SVGDiagram diagram;
- private Dimensions size = null;
-
- private int baseline = -1;
-
- private CanvasListener canvasListener = new CanvasListener() {
- @Override
- public void regionUpdated(Canvas canvas, int x, int y, int width, int height) {
- imageListeners.regionUpdated(Drawing.this, x, y, width, height);
+ public Drawing(SVGDiagram diagram) {
+ if (diagram == null) {
+ throw new IllegalArgumentException();
}
- @Override
- public void canvasInvalidated(Canvas canvas) {
- int previousWidth = size.width;
- int previousHeight = size.height;
+ this.diagram = diagram;
+ }
- invalidate();
+ public SVGDiagram getDiagram() {
+ return diagram;
+ }
- imageListeners.sizeChanged(Drawing.this, previousWidth, previousHeight);
+ public void update() {
+ try {
+ diagram.updateTime(0.0);
+ } catch (SVGException exception) {
+ throw new RuntimeException(exception);
}
- };
-
- private DrawingListenerList drawingListeners = new DrawingListenerList();
- public Drawing() {
- this(null);
- }
-
- public Drawing(Canvas canvas) {
- setCanvas(canvas);
+ imageListeners.regionUpdated(this, 0, 0, getWidth(), getHeight());
}
@Override
public int getWidth() {
- validate();
- return size.width;
+ return (int)Math.ceil(diagram.getWidth());
}
@Override
public int getHeight() {
- validate();
- return size.height;
- }
-
- @Override
- public int getBaseline() {
- return baseline;
+ return (int)Math.ceil(diagram.getHeight());
}
- public void setBaseline(int baseline) {
- int previousBaseline = this.baseline;
+ public void setSize(int width, int height) {
+ int previousWidth = getWidth();
+ int previousHeight = getHeight();
- if (baseline != previousBaseline) {
- this.baseline = baseline;
- imageListeners.baselineChanged(this, previousBaseline);
+ SVGRoot root = diagram.getRoot();
+ try {
+ root.setAttribute("width", AnimationElement.AT_XML, Integer.toString(width));
+ root.setAttribute("height", AnimationElement.AT_XML, Integer.toString(height));
+ } catch (SVGElementException exception) {
+ throw new RuntimeException(exception);
}
- }
- private void invalidate() {
- size = null;
- }
-
- private void validate() {
- if (size == null) {
- int width, height;
- if (canvas == null) {
- width = 0;
- height = 0;
- } else {
- Bounds canvasBounds = canvas.getBounds();
- width = Math.max(canvasBounds.x + canvasBounds.width, 0);
- height = Math.max(canvasBounds.y + canvasBounds.height, 0);
- }
-
- size = new Dimensions(width, height);
+ try {
+ diagram.updateTime(0.0);
+ } catch (SVGException exception) {
+ throw new RuntimeException(exception);
}
- }
- public Canvas getCanvas() {
- return canvas;
- }
-
- public void setCanvas(Canvas canvas) {
- Canvas previousCanvas = this.canvas;
-
- if (previousCanvas != canvas) {
- this.canvas = canvas;
-
- if (previousCanvas != null) {
- previousCanvas.getCanvasListeners().remove(canvasListener);
- }
-
- if (canvas != null) {
- canvas.getCanvasListeners().add(canvasListener);
- }
-
- size = null;
-
- drawingListeners.canvasChanged(this, previousCanvas);
- }
- }
-
- public Paint getBackground() {
- return background;
- }
-
- public void setBackground(Paint background) {
- Paint previousBackground = this.background;
- if (previousBackground != background) {
- this.background = background;
- drawingListeners.backgroundChanged(this, previousBackground);
- }
- }
-
- public final void setBackground(String background) {
- if (background == null) {
- throw new IllegalArgumentException("background is null.");
- }
-
- setBackground(GraphicsUtilities.decodePaint(background));
+ imageListeners.sizeChanged(this, previousWidth, previousHeight);
}
@Override
public void paint(Graphics2D graphics) {
- int width = getWidth();
- int height = getHeight();
-
- graphics.clipRect(0, 0, width, height);
-
- if (background != null) {
- graphics.setPaint(background);
- graphics.fillRect(0, 0, width, height);
+ try {
+ graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ diagram.render(graphics);
+ } catch (SVGException exception) {
+ throw new RuntimeException(exception);
}
-
- if (canvas != null) {
- // TODO Make this configurable?
- graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
-
- canvas.draw(graphics);
- }
- }
-
- public ListenerList<DrawingListener> getDrawingListeners() {
- return drawingListeners;
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Image.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Image.java?rev=1003722&r1=1003721&r2=1003722&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Image.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Image.java Sat Oct 2 00:44:59 2010
@@ -23,7 +23,6 @@ import java.io.InputStream;
import java.net.URL;
import java.util.concurrent.ExecutorService;
-import org.apache.pivot.beans.BXMLSerializer;
import org.apache.pivot.io.IOTask;
import org.apache.pivot.serialization.SerializationException;
import org.apache.pivot.util.ListenerList;
@@ -32,6 +31,8 @@ import org.apache.pivot.util.concurrent.
import org.apache.pivot.wtk.Dimensions;
import org.apache.pivot.wtk.Visual;
+import com.kitfox.svg.SVGDiagram;
+
/**
* Abstract base class for images. An image is either a bitmapped "picture"
* or a vector "drawing".
@@ -91,14 +92,14 @@ public abstract class Image implements V
InputStream inputStream = null;
try {
- // NOTE We don't open the stream until the callback
- // executes because this is a potentially time-consuming
- // operation
+ // NOTE We don't open the stream until the callback executes because
+ // this is a potentially time-consuming operation
inputStream = new MonitoredInputStream(new BufferedInputStream(location.openStream()));
- if (location.getFile().endsWith("bxml")) {
- BXMLSerializer serializer = new BXMLSerializer();
- image = (Drawing)serializer.readObject(inputStream);
+ if (location.getFile().endsWith(SVGDiagramSerializer.SVG_EXTENSION)) {
+ SVGDiagramSerializer serializer = new SVGDiagramSerializer();
+ SVGDiagram diagram = serializer.readObject(inputStream);
+ image = new Drawing(diagram);
} else {
BufferedImageSerializer serializer = new BufferedImageSerializer();
BufferedImage bufferedImage = serializer.readObject(inputStream);
Added: pivot/trunk/wtk/src/org/apache/pivot/wtk/media/SVGDiagramSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/SVGDiagramSerializer.java?rev=1003722&view=auto
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/media/SVGDiagramSerializer.java (added)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/media/SVGDiagramSerializer.java Sat Oct 2 00:44:59 2010
@@ -0,0 +1,57 @@
+/*
+ * 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.media;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+
+import org.apache.pivot.serialization.Serializer;
+
+import com.kitfox.svg.SVGCache;
+import com.kitfox.svg.SVGDiagram;
+import com.kitfox.svg.SVGUniverse;
+
+/**
+ * SVG diagram serializer.
+ */
+public class SVGDiagramSerializer implements Serializer<SVGDiagram> {
+ private static int index = 0;
+
+ public static final String MIME_TYPE = "image/svg+xml";
+ public static final String SVG_EXTENSION = "svg";
+
+ private static final String NAME_PREFIX = "svgimage_";
+
+ @Override
+ public SVGDiagram readObject(InputStream inputStream) throws IOException {
+ SVGUniverse universe = SVGCache.getSVGUniverse();
+ URI location = universe.loadSVG(inputStream, NAME_PREFIX + (index++));
+ return universe.getDiagram(location, true);
+ }
+
+ @Override
+ public void writeObject(SVGDiagram diagram, OutputStream outputStream) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getMIMEType(SVGDiagram diagram) {
+ return MIME_TYPE;
+ }
+}