Author: rwhitcomb
Date: Mon Oct 30 16:59:08 2023
New Revision: 1913448
URL: http://svn.apache.org/viewvc?rev=1913448&view=rev
Log:
PIVOT-1032: Small style changes in the wtk/text classes.
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/text/BulletedList.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/text/List.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/text/NodeListener.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/text/NumberedList.java
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/BulletedList.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/BulletedList.java?rev=1913448&r1=1913447&r2=1913448&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/BulletedList.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/BulletedList.java Mon Oct 30
16:59:08 2023
@@ -27,9 +27,9 @@ public class BulletedList extends List {
* List bullet styles.
*/
public enum Style {
- /** unicode character 0x2022 aka. "BULLET" */
+ /** Unicode character 0x2022 aka "BULLET". */
CIRCLE,
- /** unicode character 0x25e6 aka. "WHITE BULLET" */
+ /** Unicode character 0x25e6 aka "WHITE BULLET". */
CIRCLE_OUTLINE
}
@@ -41,7 +41,7 @@ public class BulletedList extends List {
super();
}
- public BulletedList(BulletedList bulletedList, boolean recursive) {
+ public BulletedList(final BulletedList bulletedList, final boolean
recursive) {
super(bulletedList, recursive);
this.style = bulletedList.style;
}
@@ -50,18 +50,18 @@ public class BulletedList extends List {
return style;
}
- public void setStyle(Style style) {
- Utils.checkNull(style, "style");
+ public void setStyle(final Style newStyle) {
+ Utils.checkNull(newStyle, "style");
Style previousStyle = this.style;
- if (previousStyle != style) {
- this.style = style;
+ if (previousStyle != newStyle) {
+ this.style = newStyle;
bulletedListListeners.styleChanged(this, previousStyle);
}
}
@Override
- public BulletedList duplicate(boolean recursive) {
+ public BulletedList duplicate(final boolean recursive) {
return new BulletedList(this, recursive);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java?rev=1913448&r1=1913447&r2=1913448&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java Mon Oct 30
16:59:08 2023
@@ -37,7 +37,7 @@ import org.apache.pivot.wtk.GraphicsUtil
public abstract class Element extends Node implements Sequence<Node>,
Iterable<Node> {
private int characterCount = 0;
private ArrayList<Node> nodes = new ArrayList<>();
- private java.awt.Font font;
+ private Font font;
private Color foregroundColor;
private Color backgroundColor;
private boolean underline;
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/List.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/List.java?rev=1913448&r1=1913447&r2=1913448&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/List.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/List.java Mon Oct 30 16:59:08
2023
@@ -16,6 +16,8 @@
*/
package org.apache.pivot.wtk.text;
+import org.apache.pivot.util.Utils;
+
/**
* Abstract base class for list elements. <p> TODO Add indent and item spacing
* properties.
@@ -25,44 +27,65 @@ public abstract class List extends Block
* Element representing a list item.
*/
public static class Item extends Element {
+ /**
+ * Default constructor.
+ */
public Item() {
super();
}
- public Item(Item item, boolean recursive) {
+ /**
+ * Copy constructor with option to copy the children also.
+ *
+ * @param item Item to copy.
+ * @param recursive Whether to copy the children as well.
+ */
+ public Item(final Item item, final boolean recursive) {
super(item, recursive);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
- public void insert(Node node, int index) {
- if (!(node instanceof Block)) {
- throw new IllegalArgumentException("Child node must be an
instance of "
- + Block.class.getName());
- }
+ public void insert(final Node node, final int index) {
+ Utils.notInstanceOf("Child node", node, Block.class);
super.insert(node, index);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
- public Item duplicate(boolean recursive) {
+ public Item duplicate(final boolean recursive) {
return new Item(this, recursive);
}
}
+ /**
+ * Default constructor.
+ */
public List() {
super();
}
- public List(List list, boolean recursive) {
+ /**
+ * Copy constructor with option to copy the children.
+ *
+ * @param list List element to copy.
+ * @param recursive Option to copy the children as well.
+ */
+ public List(final List list, final boolean recursive) {
super(list, recursive);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
- public void insert(Node node, int index) {
- if (!(node instanceof Item)) {
- throw new IllegalArgumentException("Child node must be an instance
of "
- + Item.class.getName());
- }
+ public void insert(final Node node, final int index) {
+ Utils.notInstanceOf("Child node", node, Item.class);
super.insert(node, index);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/NodeListener.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/NodeListener.java?rev=1913448&r1=1913447&r2=1913448&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/NodeListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/NodeListener.java Mon Oct 30
16:59:08 2023
@@ -28,12 +28,12 @@ public interface NodeListener {
*/
public static class Listeners extends ListenerList<NodeListener>
implements NodeListener {
@Override
- public void parentChanged(Node node, Element previousParent) {
+ public void parentChanged(final Node node, final Element
previousParent) {
forEach(listener -> listener.parentChanged(node, previousParent));
}
@Override
- public void offsetChanged(Node node, int previousOffset) {
+ public void offsetChanged(final Node node, final int previousOffset) {
forEach(listener -> listener.offsetChanged(node, previousOffset));
}
@@ -41,7 +41,7 @@ public interface NodeListener {
* @param offset Offset relative to this node.
*/
@Override
- public void nodeInserted(Node node, int offset) {
+ public void nodeInserted(final Node node, final int offset) {
forEach(listener -> listener.nodeInserted(node, offset));
}
@@ -49,7 +49,7 @@ public interface NodeListener {
* @param offset Offset relative to this node.
*/
@Override
- public void nodesRemoved(Node node, Sequence<Node> removed, int
offset) {
+ public void nodesRemoved(final Node node, final Sequence<Node>
removed, final int offset) {
forEach(listener -> listener.nodesRemoved(node, removed, offset));
}
@@ -57,7 +57,7 @@ public interface NodeListener {
* @param offset Offset relative to this node.
*/
@Override
- public void rangeInserted(Node node, int offset, int characterCount) {
+ public void rangeInserted(final Node node, final int offset, final int
characterCount) {
forEach(listener -> listener.rangeInserted(node, offset,
characterCount));
}
@@ -65,7 +65,8 @@ public interface NodeListener {
* @param offset Offset relative to this node.
*/
@Override
- public void rangeRemoved(Node node, int offset, int characterCount,
CharSequence removedChars) {
+ public void rangeRemoved(final Node node, final int offset, final int
characterCount,
+ final CharSequence removedChars) {
forEach(listener -> listener.rangeRemoved(node, offset,
characterCount, removedChars));
}
}
@@ -77,22 +78,22 @@ public interface NodeListener {
@Deprecated
public class Adapter implements NodeListener {
@Override
- public void offsetChanged(Node node, int previousOffset) {
+ public void offsetChanged(final Node node, final int previousOffset) {
// empty block
}
@Override
- public void parentChanged(Node node, Element previousParent) {
+ public void parentChanged(final Node node, final Element
previousParent) {
// empty block
}
@Override
- public void nodeInserted(Node node, int offset) {
+ public void nodeInserted(final Node node, final int offset) {
// empty block
}
@Override
- public void nodesRemoved(Node node, Sequence<Node> removed, int
offset) {
+ public void nodesRemoved(final Node node, final Sequence<Node>
removed, final int offset) {
// empty block
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/NumberedList.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/NumberedList.java?rev=1913448&r1=1913447&r2=1913448&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/NumberedList.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/NumberedList.java Mon Oct 30
16:59:08 2023
@@ -27,41 +27,84 @@ public class NumberedList extends List {
* List numbering styles.
*/
public enum Style {
- DECIMAL, LOWER_ALPHA, UPPER_ALPHA, LOWER_ROMAN, UPPER_ROMAN
+ /** Decimal numbers, such as <code>1</code>, <code>2</code>, or
<code>3</code>. */
+ DECIMAL,
+ /** Lower case alphabetic, such as <code>a</code>, <code>b</code>, or
<code>c</code>. */
+ LOWER_ALPHA,
+ /** Upper case alphabetic, such as <code>A</code>, <code>B</code>, or
<code>C</code>. */
+ UPPER_ALPHA,
+ /** Lower case Roman numerals, such as <code>i</code>,
<code>ii</code>, <code>iii</code>. */
+ LOWER_ROMAN,
+ /** Upper case Roman numerals, such as <code>I</code>,
<code>II</code>, <code>III</code>. */
+ UPPER_ROMAN
}
+ /**
+ * The numbering style for this list.
+ */
private Style style = Style.DECIMAL;
+ /**
+ * The list of listeners of this list (mostly the skin classes).
+ */
private NumberedListListener.Listeners numberedListListeners = new
NumberedListListener.Listeners();
+ /**
+ * Default constructor using the default numbering style.
+ */
public NumberedList() {
super();
}
- public NumberedList(NumberedList numberedList, boolean recursive) {
+ /**
+ * "Copy" constructor using the style of the given list, and whether the
copy is recursive
+ * (also copying all child elements).
+ *
+ * @param numberedList Element to copy from.
+ * @param recursive Whether to copy all children as well.
+ */
+ public NumberedList(final NumberedList numberedList, final boolean
recursive) {
super(numberedList, recursive);
this.style = numberedList.style;
}
+ /**
+ * Access the number style of this list.
+ *
+ * @return The list's number style.
+ */
public Style getStyle() {
return style;
}
- public void setStyle(Style style) {
- Utils.checkNull(style, "style");
+ /**
+ * Set the new numbering style for this list.
+ *
+ * @param newStyle The updated numbering style for this list.
+ */
+ public void setStyle(final Style newStyle) {
+ Utils.checkNull(newStyle, "style");
- Style previousStyle = this.style;
- if (previousStyle != style) {
- this.style = style;
+ Style previousStyle = style;
+ if (previousStyle != newStyle) {
+ style = newStyle;
numberedListListeners.styleChanged(this, previousStyle);
}
}
+ /**
+ * {@inheritDoc}
+ */
@Override
- public NumberedList duplicate(boolean recursive) {
+ public NumberedList duplicate(final boolean recursive) {
return new NumberedList(this, recursive);
}
+ /**
+ * Access the list of listeners for changes to this element.
+ *
+ * @return The list of listeners.
+ */
public ListenerList<NumberedListListener> getNumberedListListeners() {
return numberedListListeners;
}