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 2017/10/05 23:27:44 UTC
svn commit: r1811278 - in /pivot/trunk/wtk/src/org/apache/pivot/wtk:
Bounds.java ConstrainedVisual.java Visual.java skin/ComponentSkin.java
skin/WindowSkin.java
Author: rwhitcomb
Date: Thu Oct 5 23:27:44 2017
New Revision: 1811278
URL: http://svn.apache.org/viewvc?rev=1811278&view=rev
Log:
More work with Dimensions:
* Use Dimensions.ZERO in more places.
* Add new default methods to Visual and ConstrainedVisual to get/set
size in terms of Dimensions.
* Remove the "public" modifiers from the methods in these two interfaces
since they are not necessary.
* Update "getClientArea" in WindowSkin to use this new interface
(that is, construct Bounds from Dimensions).
* Correct typo in Bounds.
* Implement "getSize()" in ComponentSkin directly using the width and
height saved values (instead of "getWidth()" and "getHeight()").
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/Bounds.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/ConstrainedVisual.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Visual.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Bounds.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Bounds.java?rev=1811278&r1=1811277&r2=1811278&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Bounds.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Bounds.java Thu Oct 5 23:27:44 2017
@@ -405,7 +405,7 @@ public final class Bounds implements Ser
* <pre>{ "x": nnn, "y": nnn, "width": nnn, "height": nnn }</pre>
* <p> The format of a JSON list format will be:
* <pre>[ x, y, width, height ]</pre>
- * <p> Also accepted is a simple list (comma- or semi-colon-separated) of four
+ * <p> Also accepted is a simple list (comma- or semicolon-separated) of four
* integer values.
*
* @param boundsValue The JSON string containing the map or list of bounds values
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ConstrainedVisual.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ConstrainedVisual.java?rev=1811278&r1=1811277&r2=1811278&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ConstrainedVisual.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ConstrainedVisual.java Thu Oct 5 23:27:44 2017
@@ -26,7 +26,16 @@ public interface ConstrainedVisual exten
* @param width The visual's new width.
* @param height The visual's new height.
*/
- public void setSize(int width, int height);
+ void setSize(int width, int height);
+
+ /**
+ * Default method to set the visual size via a {@link Dimensions} value.
+ *
+ * @param size The complete size of this visual.
+ */
+ default void setSize(Dimensions size) {
+ setSize(size.width, size.height);
+ }
/**
* Returns the visual's preferred width given the provided height
@@ -36,7 +45,7 @@ public interface ConstrainedVisual exten
* <tt>-1</tt> for no constraint.
* @return The preferred width given the height constraint.
*/
- public int getPreferredWidth(int height);
+ int getPreferredWidth(int height);
/**
* Returns the visual's preferred height given the provided width
@@ -46,13 +55,13 @@ public interface ConstrainedVisual exten
* <tt>-1</tt> for no constraint.
* @return The preferred height given the width constraint.
*/
- public int getPreferredHeight(int width);
+ int getPreferredHeight(int width);
/**
* Returns the visual's unconstrained preferred size.
* @return The unconstrained preferred size for this component.
*/
- public Dimensions getPreferredSize();
+ Dimensions getPreferredSize();
/**
* Returns the baseline for a given width and height.
@@ -62,5 +71,5 @@ public interface ConstrainedVisual exten
* @return The baseline relative to the origin of this visual, or <tt>-1</tt>
* if this visual does not have a baseline.
*/
- public int getBaseline(int width, int height);
+ int getBaseline(int width, int height);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Visual.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Visual.java?rev=1811278&r1=1811277&r2=1811278&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Visual.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Visual.java Thu Oct 5 23:27:44 2017
@@ -27,13 +27,27 @@ public interface Visual {
* Returns the visual's width.
* @return Current width of this visual.
*/
- public int getWidth();
+ int getWidth();
/**
* Returns the visual's height.
* @return Current height of this visual.
*/
- public int getHeight();
+ int getHeight();
+
+ /**
+ * Default method to return the visual's complete size
+ * via a {@link Dimensions} object. Note that if the
+ * width and height calculations for a particular object
+ * are lengthy and could be better done together rather
+ * than separately, that component should be free to
+ * override this default implementation.
+ *
+ * @return The visual's complete size.
+ */
+ default Dimensions getSize() {
+ return new Dimensions(getWidth(), getHeight());
+ }
/**
* Returns the visual's baseline.
@@ -41,12 +55,12 @@ public interface Visual {
* @return The baseline relative to the origin of the visual, or <tt>-1</tt>
* if this visual does not have a baseline.
*/
- public int getBaseline();
+ int getBaseline();
/**
* Paints the visual.
*
* @param graphics The graphics context in which to paint the visual.
*/
- public void paint(Graphics2D graphics);
+ void paint(Graphics2D graphics);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java?rev=1811278&r1=1811277&r2=1811278&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java Thu Oct 5 23:27:44 2017
@@ -73,6 +73,11 @@ public abstract class ComponentSkin impl
}
@Override
+ public Dimensions getSize() {
+ return new Dimensions(width, height);
+ }
+
+ @Override
public void setSize(int width, int height) {
this.width = width;
this.height = height;
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java?rev=1811278&r1=1811277&r2=1811278&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java Thu Oct 5 23:27:44 2017
@@ -92,7 +92,7 @@ public class WindowSkin extends Containe
Window window = (Window) getComponent();
Component content = window.getContent();
- return (content != null) ? content.getPreferredSize() : new Dimensions(0, 0);
+ return (content != null) ? content.getPreferredSize() : Dimensions.ZERO;
}
@Override
@@ -107,7 +107,7 @@ public class WindowSkin extends Containe
@Override
public Bounds getClientArea() {
- return new Bounds(0, 0, getWidth(), getHeight());
+ return new Bounds(getSize());
}
@Override