Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Gauge.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Gauge.java?rev=1913470&r1=1913469&r2=1913470&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/Gauge.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Gauge.java Tue Oct 31 19:15:47 2023 @@ -1,338 +1,338 @@ -/* - * 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; - -import org.apache.pivot.util.ListenerList; -import org.apache.pivot.util.StringUtils; -import org.apache.pivot.util.Utils; - -/** - * A circular gauge component that can display a single value of an arbitrary - * numeric type. - */ -public class Gauge<T extends Number> extends Component { - private Origin origin; - private String text; - private T value; - private T minValue; - private T maxValue; - private T warningLevel; - private T criticalLevel; - private GaugeListener.Listeners<T> gaugeListeners = new GaugeListener.Listeners<T>(); - /** Runtime class (used to check values at runtime). */ - private Class<? extends Number> clazz; - - /** - * Default constructor for this component, with the default {@link Origin} - * value (which is <code>NORTH</code>). - */ - public Gauge() { - this(Origin.NORTH); - } - - /** - * Constructor for a new gauge object, using the given {@link Origin} value. - * @param origin The "origin" or zero point of the gauge (a compass direction). - */ - public Gauge(Origin origin) { - setOrigin(origin); - installSkin(Gauge.class); - } - - public Origin getOrigin() { - return this.origin; - } - - /** - * Set the "origin" value for this gauge, that is, the point in the circle where - * drawing of the value starts (one of the main compass directions). The gauge - * value will always be drawn clockwise starting from the origin location. - * @param origin The new origin value. - * @throws IllegalArgumentException if the origin value is {@code null}. - */ - public void setOrigin(Origin origin) { - Utils.checkNull(origin, "origin"); - - Origin previousOrigin = this.origin; - - if (previousOrigin != origin) { - this.origin = origin; - gaugeListeners.originChanged(this, previousOrigin); - } - } - - public Class<? extends Number> getType() { - return this.clazz; - } - - /** - * Since this is a generic component that can take any numeric type, for BXML we need - * to specify the specific type of the value (which is also needed for the min/max and - * warning/critical values). - * @param typeName The type name for the value of this component. For convenience you can - * specify just "Integer", "Short", "BigDecimal", or any other subclass of {@link Number} - * here, or you can give the fully-qualified name. - */ - @SuppressWarnings("unchecked") - public void setType(String typeName) { - try { - this.clazz = (Class<? extends Number>) ((typeName.indexOf('.') < 0) - ? Class.forName("java.lang." + typeName) - : Class.forName(typeName)); - } catch (ClassNotFoundException cnfe) { - if (typeName.indexOf('.') < 0) { - // Try "java.math" (for BigDecimal, etc.) types - try { - this.clazz = (Class<? extends Number>) Class.forName("java.math." + typeName); - } catch (ClassNotFoundException cnfe2) { - throw new RuntimeException(cnfe); - } - } - } - } - - /** - * If the {@link #clazz} was set by a prior call to {@link #setType setType()} then - * check the runtime class of the value against it, otherwise call {@link #setType setType()} - * to establish it for the future. - * - * @param value A value presumably compatible with the declared type of this gauge. - * @throws ClassCastException if the value is not compatible with the previously - * established type. - */ - private void setOrCheckClass(T value) { - if (this.clazz != null) { - if (!clazz.isInstance(value)) { - throw new ClassCastException("Value is not an instance of " + clazz.getName()); - } - } else { - setType(value.getClass().getName()); - } - } - - /** - * @return The current (single) value assigned to this component. - */ - public T getValue() { - return value; - } - - /** - * Sets the current value displayed by the gauge. - * @param value The new value, of the same type as declared for the gauge. - * @throws ClassCastException if the type of this value is not what was given - * by the {@link #setType setType()} call or any previous call to the {@code "setXXXValue"} - * methods (which all call {@link #setOrCheckClass}). - */ - public void setValue(T value) { - Utils.checkNull(value, "value"); - setOrCheckClass(value); - - T previousValue = this.value; - - if (value != previousValue) { - this.value = value; - gaugeListeners.valueChanged(this, previousValue); - } - } - - /** - * Used by BXML to set the value. Converts String to a Number using the - * {@link StringUtils#toNumber StringUtils.toNumber()} method, giving the class value set by - * {@link #setType setType()}. - * @param value The string value to convert to a number. - * @see #setValue - */ - @SuppressWarnings("unchecked") - public void setValue(String value) { - setValue((T) StringUtils.toNumber(value, clazz)); - } - - public T getMinValue() { - return minValue; - } - - /** - * Set the minimum value for this gauge, which will correspond to the "origin" - * value of the display. Values given by {@link #setValue} will be offset by - * this minimum value before display. - * @param minValue The new minimum value for the gauge. - * @throws ClassCastException if this value is not null and not of the same - * type as previous values set on this gauge. - */ - public void setMinValue(T minValue) { - if (minValue != null) { - setOrCheckClass(minValue); - } - - T previousMinValue = this.minValue; - - if (minValue != previousMinValue) { - this.minValue = minValue; - gaugeListeners.minValueChanged(this, previousMinValue); - } - } - - /** - * Used by BXML to set the minimum value. Converts string to number using the - * {@link StringUtils#toNumber StringUtils.toNumber()} method. - * @param minValue The string value to convert to a minimum value. - * @throws IllegalArgumentException if the input is null or empty. - */ - @SuppressWarnings("unchecked") - public void setMinValue(String minValue) { - setMinValue((T) StringUtils.toNumber(minValue, clazz)); - } - - public T getMaxValue() { - return maxValue; - } - - /** - * Set the maximum value for this gauge, which will correspond to 360 degrees - * after the origin of the display. Values given by {@link #setValue} will be - * limited to this maximum value for display. - * @param maxValue The new maximum value for the gauge. - * @throws ClassCastException if this value is not null and not of the same - * type as previous values set on this gauge. - */ - public void setMaxValue(T maxValue) { - if (maxValue != null) { - setOrCheckClass(maxValue); - } - - T previousMaxValue = this.maxValue; - - if (previousMaxValue != maxValue) { - this.maxValue = maxValue; - gaugeListeners.maxValueChanged(this, previousMaxValue); - } - } - - /** - * Used by BXML to set the maximum value. Converts string to number using the - * {@link StringUtils#toNumber StringUtils.toNumber()} method. - * @param maxValue The string value to convert to a maximum value. - * @throws IllegalArgumentException if the input is null or empty. - */ - @SuppressWarnings("unchecked") - public void setMaxValue(String maxValue) { - setMaxValue((T) StringUtils.toNumber(maxValue, clazz)); - } - - public T getWarningLevel() { - return this.warningLevel; - } - - /** - * Set a level at which the gauge will start showing "warning" indication - * (basically the warning color set in the skin). - * <p> If the warning (or critical) value is set to {@code null}, and/or - * the warning (or critical) color is set to {@code null} then the display - * will always be the same color, no matter the value. - * <p> The assumption is that the warning level will be less than the critical - * level, and both will be in the range of the min - max values (this is not - * currently checked anywhere). - * @param warningLevel A value of the same type as the other values for - * this gauge at which to set the warning threshold (can be {@code null}). - */ - public final void setWarningLevel(T warningLevel) { - if (warningLevel != null) { - setOrCheckClass(warningLevel); - } - - T previousWarningLevel = this.warningLevel; - - if (previousWarningLevel != warningLevel) { - this.warningLevel = warningLevel; - gaugeListeners.warningLevelChanged(this, previousWarningLevel); - } - } - - /** - * Set the warning level from a string representation of a number. - * @param warningLevel New value. - * @see #setValue(String) - */ - @SuppressWarnings("unchecked") - public void setWarningLevel(String warningLevel) { - setWarningLevel((T) StringUtils.toNumber(warningLevel, clazz)); - } - - public T getCriticalLevel() { - return this.criticalLevel; - } - - /** - * Set a level at which the gauge will start showing "critical" indication - * (basically the critical color set in the skin). - * <p> If the critical (or warning) value is set to {@code null}, and/or - * the critical (or warning) color is set to {@code null} then the display - * will always be the same color, no matter the value. - * <p> The assumption is that the warning level will be less than the critical - * level, and both will be in the range of the min - max values (this is not - * currently checked anywhere). - * @param criticalLevel A value of the same type as the other values for - * this gauge at which to set the critical threshold (can be {@code null}). - */ - public final void setCriticalLevel(T criticalLevel) { - if (criticalLevel != null) { - setOrCheckClass(criticalLevel); - } - - T previousCriticalLevel = this.criticalLevel; - - if (previousCriticalLevel != criticalLevel) { - this.criticalLevel = criticalLevel; - gaugeListeners.criticalLevelChanged(this, previousCriticalLevel); - } - } - - /** - * Set the critical level from a string representation of a number. - * @param criticalLevel New value. - * @see #setValue(String) - */ - @SuppressWarnings("unchecked") - public void setCriticalLevel(String criticalLevel) { - setCriticalLevel((T) StringUtils.toNumber(criticalLevel, clazz)); - } - - public String getText() { - return this.text; - } - - /** - * Set the text string to be displayed in the middle of the gauge. - * @param text The new text to be shown (can be {@code null} or empty). - */ - public void setText(String text) { - // Null text is allowed - String previousText = this.text; - - if ((previousText == null && text != null) - || (previousText != null && text == null) - || (previousText != null && !previousText.equals(text))) { - this.text = text; - gaugeListeners.textChanged(this, previousText); - } - } - - public ListenerList<GaugeListener<T>> getGaugeListeners() { - return gaugeListeners; - } -} +/* + * 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; + +import org.apache.pivot.util.ListenerList; +import org.apache.pivot.util.StringUtils; +import org.apache.pivot.util.Utils; + +/** + * A circular gauge component that can display a single value of an arbitrary + * numeric type. + */ +public class Gauge<T extends Number> extends Component { + private Origin origin; + private String text; + private T value; + private T minValue; + private T maxValue; + private T warningLevel; + private T criticalLevel; + private GaugeListener.Listeners<T> gaugeListeners = new GaugeListener.Listeners<T>(); + /** Runtime class (used to check values at runtime). */ + private Class<? extends Number> clazz; + + /** + * Default constructor for this component, with the default {@link Origin} + * value (which is <code>NORTH</code>). + */ + public Gauge() { + this(Origin.NORTH); + } + + /** + * Constructor for a new gauge object, using the given {@link Origin} value. + * @param origin The "origin" or zero point of the gauge (a compass direction). + */ + public Gauge(Origin origin) { + setOrigin(origin); + installSkin(Gauge.class); + } + + public Origin getOrigin() { + return this.origin; + } + + /** + * Set the "origin" value for this gauge, that is, the point in the circle where + * drawing of the value starts (one of the main compass directions). The gauge + * value will always be drawn clockwise starting from the origin location. + * @param origin The new origin value. + * @throws IllegalArgumentException if the origin value is {@code null}. + */ + public void setOrigin(Origin origin) { + Utils.checkNull(origin, "origin"); + + Origin previousOrigin = this.origin; + + if (previousOrigin != origin) { + this.origin = origin; + gaugeListeners.originChanged(this, previousOrigin); + } + } + + public Class<? extends Number> getType() { + return this.clazz; + } + + /** + * Since this is a generic component that can take any numeric type, for BXML we need + * to specify the specific type of the value (which is also needed for the min/max and + * warning/critical values). + * @param typeName The type name for the value of this component. For convenience you can + * specify just "Integer", "Short", "BigDecimal", or any other subclass of {@link Number} + * here, or you can give the fully-qualified name. + */ + @SuppressWarnings("unchecked") + public void setType(String typeName) { + try { + this.clazz = (Class<? extends Number>) ((typeName.indexOf('.') < 0) + ? Class.forName("java.lang." + typeName) + : Class.forName(typeName)); + } catch (ClassNotFoundException cnfe) { + if (typeName.indexOf('.') < 0) { + // Try "java.math" (for BigDecimal, etc.) types + try { + this.clazz = (Class<? extends Number>) Class.forName("java.math." + typeName); + } catch (ClassNotFoundException cnfe2) { + throw new RuntimeException(cnfe); + } + } + } + } + + /** + * If the {@link #clazz} was set by a prior call to {@link #setType setType()} then + * check the runtime class of the value against it, otherwise call {@link #setType setType()} + * to establish it for the future. + * + * @param value A value presumably compatible with the declared type of this gauge. + * @throws ClassCastException if the value is not compatible with the previously + * established type. + */ + private void setOrCheckClass(T value) { + if (this.clazz != null) { + if (!clazz.isInstance(value)) { + throw new ClassCastException("Value is not an instance of " + clazz.getName()); + } + } else { + setType(value.getClass().getName()); + } + } + + /** + * @return The current (single) value assigned to this component. + */ + public T getValue() { + return value; + } + + /** + * Sets the current value displayed by the gauge. + * @param value The new value, of the same type as declared for the gauge. + * @throws ClassCastException if the type of this value is not what was given + * by the {@link #setType setType()} call or any previous call to the {@code "setXXXValue"} + * methods (which all call {@link #setOrCheckClass}). + */ + public void setValue(T value) { + Utils.checkNull(value, "value"); + setOrCheckClass(value); + + T previousValue = this.value; + + if (value != previousValue) { + this.value = value; + gaugeListeners.valueChanged(this, previousValue); + } + } + + /** + * Used by BXML to set the value. Converts String to a Number using the + * {@link StringUtils#toNumber StringUtils.toNumber()} method, giving the class value set by + * {@link #setType setType()}. + * @param value The string value to convert to a number. + * @see #setValue + */ + @SuppressWarnings("unchecked") + public void setValue(String value) { + setValue((T) StringUtils.toNumber(value, clazz)); + } + + public T getMinValue() { + return minValue; + } + + /** + * Set the minimum value for this gauge, which will correspond to the "origin" + * value of the display. Values given by {@link #setValue} will be offset by + * this minimum value before display. + * @param minValue The new minimum value for the gauge. + * @throws ClassCastException if this value is not null and not of the same + * type as previous values set on this gauge. + */ + public void setMinValue(T minValue) { + if (minValue != null) { + setOrCheckClass(minValue); + } + + T previousMinValue = this.minValue; + + if (minValue != previousMinValue) { + this.minValue = minValue; + gaugeListeners.minValueChanged(this, previousMinValue); + } + } + + /** + * Used by BXML to set the minimum value. Converts string to number using the + * {@link StringUtils#toNumber StringUtils.toNumber()} method. + * @param minValue The string value to convert to a minimum value. + * @throws IllegalArgumentException if the input is null or empty. + */ + @SuppressWarnings("unchecked") + public void setMinValue(String minValue) { + setMinValue((T) StringUtils.toNumber(minValue, clazz)); + } + + public T getMaxValue() { + return maxValue; + } + + /** + * Set the maximum value for this gauge, which will correspond to 360 degrees + * after the origin of the display. Values given by {@link #setValue} will be + * limited to this maximum value for display. + * @param maxValue The new maximum value for the gauge. + * @throws ClassCastException if this value is not null and not of the same + * type as previous values set on this gauge. + */ + public void setMaxValue(T maxValue) { + if (maxValue != null) { + setOrCheckClass(maxValue); + } + + T previousMaxValue = this.maxValue; + + if (previousMaxValue != maxValue) { + this.maxValue = maxValue; + gaugeListeners.maxValueChanged(this, previousMaxValue); + } + } + + /** + * Used by BXML to set the maximum value. Converts string to number using the + * {@link StringUtils#toNumber StringUtils.toNumber()} method. + * @param maxValue The string value to convert to a maximum value. + * @throws IllegalArgumentException if the input is null or empty. + */ + @SuppressWarnings("unchecked") + public void setMaxValue(String maxValue) { + setMaxValue((T) StringUtils.toNumber(maxValue, clazz)); + } + + public T getWarningLevel() { + return this.warningLevel; + } + + /** + * Set a level at which the gauge will start showing "warning" indication + * (basically the warning color set in the skin). + * <p> If the warning (or critical) value is set to {@code null}, and/or + * the warning (or critical) color is set to {@code null} then the display + * will always be the same color, no matter the value. + * <p> The assumption is that the warning level will be less than the critical + * level, and both will be in the range of the min - max values (this is not + * currently checked anywhere). + * @param warningLevel A value of the same type as the other values for + * this gauge at which to set the warning threshold (can be {@code null}). + */ + public final void setWarningLevel(T warningLevel) { + if (warningLevel != null) { + setOrCheckClass(warningLevel); + } + + T previousWarningLevel = this.warningLevel; + + if (previousWarningLevel != warningLevel) { + this.warningLevel = warningLevel; + gaugeListeners.warningLevelChanged(this, previousWarningLevel); + } + } + + /** + * Set the warning level from a string representation of a number. + * @param warningLevel New value. + * @see #setValue(String) + */ + @SuppressWarnings("unchecked") + public void setWarningLevel(String warningLevel) { + setWarningLevel((T) StringUtils.toNumber(warningLevel, clazz)); + } + + public T getCriticalLevel() { + return this.criticalLevel; + } + + /** + * Set a level at which the gauge will start showing "critical" indication + * (basically the critical color set in the skin). + * <p> If the critical (or warning) value is set to {@code null}, and/or + * the critical (or warning) color is set to {@code null} then the display + * will always be the same color, no matter the value. + * <p> The assumption is that the warning level will be less than the critical + * level, and both will be in the range of the min - max values (this is not + * currently checked anywhere). + * @param criticalLevel A value of the same type as the other values for + * this gauge at which to set the critical threshold (can be {@code null}). + */ + public final void setCriticalLevel(T criticalLevel) { + if (criticalLevel != null) { + setOrCheckClass(criticalLevel); + } + + T previousCriticalLevel = this.criticalLevel; + + if (previousCriticalLevel != criticalLevel) { + this.criticalLevel = criticalLevel; + gaugeListeners.criticalLevelChanged(this, previousCriticalLevel); + } + } + + /** + * Set the critical level from a string representation of a number. + * @param criticalLevel New value. + * @see #setValue(String) + */ + @SuppressWarnings("unchecked") + public void setCriticalLevel(String criticalLevel) { + setCriticalLevel((T) StringUtils.toNumber(criticalLevel, clazz)); + } + + public String getText() { + return this.text; + } + + /** + * Set the text string to be displayed in the middle of the gauge. + * @param text The new text to be shown (can be {@code null} or empty). + */ + public void setText(String text) { + // Null text is allowed + String previousText = this.text; + + if ((previousText == null && text != null) + || (previousText != null && text == null) + || (previousText != null && !previousText.equals(text))) { + this.text = text; + gaugeListeners.textChanged(this, previousText); + } + } + + public ListenerList<GaugeListener<T>> getGaugeListeners() { + return gaugeListeners; + } +}
Propchange: pivot/trunk/wtk/src/org/apache/pivot/wtk/Gauge.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/GaugeListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/GaugeListener.java?rev=1913470&r1=1913469&r2=1913470&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/GaugeListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/GaugeListener.java Tue Oct 31 19:15:47 2023 @@ -1,128 +1,128 @@ -/* - * 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; - -import org.apache.pivot.util.ListenerList; - -/** - * Gauge listener interface. - */ -public interface GaugeListener<T extends Number> { - /** - * Gauge listeners. - */ - public static class Listeners<T extends Number> extends ListenerList<GaugeListener<T>> implements GaugeListener<T> { - @Override - public void originChanged(Gauge<T> gauge, Origin previousOrigin) { - forEach(listener -> listener.originChanged(gauge, previousOrigin)); - } - - @Override - public void valueChanged(Gauge<T> gauge, T previousValue) { - forEach(listener -> listener.valueChanged(gauge, previousValue)); - } - - @Override - public void textChanged(Gauge<T> gauge, String previousText) { - forEach(listener -> listener.textChanged(gauge, previousText)); - } - - @Override - public void minValueChanged(Gauge<T> gauge, T previousMinValue) { - forEach(listener -> listener.minValueChanged(gauge, previousMinValue)); - } - - @Override - public void maxValueChanged(Gauge<T> gauge, T previousMaxValue) { - forEach(listener -> listener.maxValueChanged(gauge, previousMaxValue)); - } - - @Override - public void warningLevelChanged(Gauge<T> gauge, T previousWarningLevel) { - forEach(listener -> listener.warningLevelChanged(gauge, previousWarningLevel)); - } - - @Override - public void criticalLevelChanged(Gauge<T> gauge, T previousCriticalLevel) { - forEach(listener -> listener.criticalLevelChanged(gauge, previousCriticalLevel)); - } - } - - /** - * Called when the origin (starting point of the gauge value) changes. - * - * @param gauge The gauge that has changed. - * @param previousOrigin The previous origin value. - */ - default void originChanged(Gauge<T> gauge, Origin previousOrigin) { - } - - /** - * Called when the gauge value changes. - * - * @param gauge The gauge that is changing. - * @param previousValue The old value. - */ - default void valueChanged(Gauge<T> gauge, T previousValue) { - } - - /** - * Called when the gauge's text changes. - * - * @param gauge The gauge whose text changed. - * @param previousText The previous text. - */ - default void textChanged(Gauge<T> gauge, String previousText) { - } - - /** - * Called when min value changes. - * - * @param gauge The gauge that is changing. - * @param previousMinValue The previous minimum. - */ - default void minValueChanged(Gauge<T> gauge, T previousMinValue) { - } - - /** - * Called when max value changes. - * - * @param gauge The gauge that is changing. - * @param previousMaxValue The previous maximum. - */ - default void maxValueChanged(Gauge<T> gauge, T previousMaxValue) { - } - - /** - * Called when the warning level for the gauge has changed. - * - * @param gauge The gauge we're talking about. - * @param previousWarningLevel The previous value for the warning level. - */ - default void warningLevelChanged(Gauge<T> gauge, T previousWarningLevel) { - } - - /** - * Called when the critical level for the gauge has changed. - * - * @param gauge The gauge we're talking about. - * @param previousCriticalLevel The previous value for the critical level. - */ - default void criticalLevelChanged(Gauge<T> gauge, T previousCriticalLevel) { - } -} - +/* + * 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; + +import org.apache.pivot.util.ListenerList; + +/** + * Gauge listener interface. + */ +public interface GaugeListener<T extends Number> { + /** + * Gauge listeners. + */ + public static class Listeners<T extends Number> extends ListenerList<GaugeListener<T>> implements GaugeListener<T> { + @Override + public void originChanged(Gauge<T> gauge, Origin previousOrigin) { + forEach(listener -> listener.originChanged(gauge, previousOrigin)); + } + + @Override + public void valueChanged(Gauge<T> gauge, T previousValue) { + forEach(listener -> listener.valueChanged(gauge, previousValue)); + } + + @Override + public void textChanged(Gauge<T> gauge, String previousText) { + forEach(listener -> listener.textChanged(gauge, previousText)); + } + + @Override + public void minValueChanged(Gauge<T> gauge, T previousMinValue) { + forEach(listener -> listener.minValueChanged(gauge, previousMinValue)); + } + + @Override + public void maxValueChanged(Gauge<T> gauge, T previousMaxValue) { + forEach(listener -> listener.maxValueChanged(gauge, previousMaxValue)); + } + + @Override + public void warningLevelChanged(Gauge<T> gauge, T previousWarningLevel) { + forEach(listener -> listener.warningLevelChanged(gauge, previousWarningLevel)); + } + + @Override + public void criticalLevelChanged(Gauge<T> gauge, T previousCriticalLevel) { + forEach(listener -> listener.criticalLevelChanged(gauge, previousCriticalLevel)); + } + } + + /** + * Called when the origin (starting point of the gauge value) changes. + * + * @param gauge The gauge that has changed. + * @param previousOrigin The previous origin value. + */ + default void originChanged(Gauge<T> gauge, Origin previousOrigin) { + } + + /** + * Called when the gauge value changes. + * + * @param gauge The gauge that is changing. + * @param previousValue The old value. + */ + default void valueChanged(Gauge<T> gauge, T previousValue) { + } + + /** + * Called when the gauge's text changes. + * + * @param gauge The gauge whose text changed. + * @param previousText The previous text. + */ + default void textChanged(Gauge<T> gauge, String previousText) { + } + + /** + * Called when min value changes. + * + * @param gauge The gauge that is changing. + * @param previousMinValue The previous minimum. + */ + default void minValueChanged(Gauge<T> gauge, T previousMinValue) { + } + + /** + * Called when max value changes. + * + * @param gauge The gauge that is changing. + * @param previousMaxValue The previous maximum. + */ + default void maxValueChanged(Gauge<T> gauge, T previousMaxValue) { + } + + /** + * Called when the warning level for the gauge has changed. + * + * @param gauge The gauge we're talking about. + * @param previousWarningLevel The previous value for the warning level. + */ + default void warningLevelChanged(Gauge<T> gauge, T previousWarningLevel) { + } + + /** + * Called when the critical level for the gauge has changed. + * + * @param gauge The gauge we're talking about. + * @param previousCriticalLevel The previous value for the critical level. + */ + default void criticalLevelChanged(Gauge<T> gauge, T previousCriticalLevel) { + } +} + Propchange: pivot/trunk/wtk/src/org/apache/pivot/wtk/GaugeListener.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: pivot/trunk/wtk/src/org/apache/pivot/wtk/HyperlinkButton.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: pivot/trunk/wtk/src/org/apache/pivot/wtk/LocalManifestAdapter.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/NumberRuler.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/NumberRuler.java?rev=1913470&r1=1913469&r2=1913470&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/NumberRuler.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/NumberRuler.java Tue Oct 31 19:15:47 2023 @@ -1,150 +1,150 @@ -/* - * 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; - -import org.apache.pivot.util.ListenerList; -import org.apache.pivot.util.Utils; - -/** - * A column or row heading component that display a line number or - * character column ruler suitable for use with scrolling text controls - * ({@link TextArea} or {@link TextPane}). - */ -public class NumberRuler extends Component { - /** Maximum allowed number of digits to display (arbitrary). */ - private static final int MAX_TEXT_SIZE = 20; - - /** Default number of digits to display for numbers in vertical rulers. */ - private static final int DEFAULT_TEXT_SIZE = 5; - - /** Current orientation for one of these (defaults to vertical, since most commonly used for line numbering). */ - private Orientation orientation = Orientation.VERTICAL; - - /** - * The expected number of digits to allow for in vertical rulers. - * <p> Since we don't know apriori how many rows/lines will be - * shown in a vertical ruler, we rely on the user/caller to tell - * us how much space to allow for the numbers. - * <p> Note: there is probably a better way to figure this out, - * but it would require, in general, expensive re-layout as - * more and more rows are added, and then what to do if rows - * get taken away? - */ - private int textSize = DEFAULT_TEXT_SIZE; - - /** - * The listeners for changes here. - */ - private NumberRulerListener.Listeners rulerListeners = new NumberRulerListener.Listeners(); - - /** - * Default constructor - instantiate our skin. - */ - public NumberRuler() { - installSkin(NumberRuler.class); - } - - /** - * @return The current orientation of this ruler. - */ - public Orientation getOrientation() { - return orientation; - } - - /** - * Set the ruler orientation. - * - * @param newOrientation The new orientation of this ruler: vertical for a line number ruler, - * or horizontal for a character number ruler. - */ - public void setOrientation(final Orientation newOrientation) { - Utils.checkNull(newOrientation, "orientation"); - - if (newOrientation != orientation) { - orientation = newOrientation; - rulerListeners.orientationChanged(this); - } - } - - /** - * @return The number of digits of space to allow for the - * numbers in a vertical ruler. - */ - public int getTextSize() { - return textSize; - } - - /** - * Set the number of digits of space to allow for the numbers. - * - * @param size The (integer) number of digits to allow in vertical - * ruler numbers. The default of {@link #DEFAULT_TEXT_SIZE} allows - * for 99,999 maximum rows. - * @throws IllegalArgumentException if the value is negative, - * or exceeds {@link #MAX_TEXT_SIZE}. - */ - public void setTextSize(final String size) { - Utils.checkNullOrEmpty(size, "size"); - - setTextSize(Integer.parseInt(size)); - } - - /** - * Set the number of digits of space to allow for the numbers. - * - * @param size The (integer) number of digits to allow in vertical - * ruler numbers. The default of {@link #DEFAULT_TEXT_SIZE} allows - * for 99,999 maximum rows. - * @throws IllegalArgumentException if the value is negative, - * or exceeds {@link #MAX_TEXT_SIZE}. - */ - public void setTextSize(final Number size) { - Utils.checkNullOrEmpty(size, "size"); - - setTextSize(size.intValue()); - } - - /** - * Set the number of digits of space to allow for the numbers. - * - * @param size The number of digits to allow in vertical ruler numbers. - * The default of {@link #DEFAULT_TEXT_SIZE} allows - * for 99,999 maximum rows. - * @throws IllegalArgumentException if the value is negative, - * or exceeds {@link #MAX_TEXT_SIZE}. - */ - public void setTextSize(final int size) { - if (size <= 0 || size > MAX_TEXT_SIZE) { - throw new IllegalArgumentException( - "Text size must be positive and less or equal to " + MAX_TEXT_SIZE + "."); - } - - if (size != textSize) { - int previousSize = textSize; - textSize = size; - rulerListeners.textSizeChanged(this, previousSize); - } - } - - /** - * @return The current list of listeners for changes in this component. - */ - public ListenerList<NumberRulerListener> getRulerListeners() { - return rulerListeners; - } - -} +/* + * 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; + +import org.apache.pivot.util.ListenerList; +import org.apache.pivot.util.Utils; + +/** + * A column or row heading component that display a line number or + * character column ruler suitable for use with scrolling text controls + * ({@link TextArea} or {@link TextPane}). + */ +public class NumberRuler extends Component { + /** Maximum allowed number of digits to display (arbitrary). */ + private static final int MAX_TEXT_SIZE = 20; + + /** Default number of digits to display for numbers in vertical rulers. */ + private static final int DEFAULT_TEXT_SIZE = 5; + + /** Current orientation for one of these (defaults to vertical, since most commonly used for line numbering). */ + private Orientation orientation = Orientation.VERTICAL; + + /** + * The expected number of digits to allow for in vertical rulers. + * <p> Since we don't know apriori how many rows/lines will be + * shown in a vertical ruler, we rely on the user/caller to tell + * us how much space to allow for the numbers. + * <p> Note: there is probably a better way to figure this out, + * but it would require, in general, expensive re-layout as + * more and more rows are added, and then what to do if rows + * get taken away? + */ + private int textSize = DEFAULT_TEXT_SIZE; + + /** + * The listeners for changes here. + */ + private NumberRulerListener.Listeners rulerListeners = new NumberRulerListener.Listeners(); + + /** + * Default constructor - instantiate our skin. + */ + public NumberRuler() { + installSkin(NumberRuler.class); + } + + /** + * @return The current orientation of this ruler. + */ + public Orientation getOrientation() { + return orientation; + } + + /** + * Set the ruler orientation. + * + * @param newOrientation The new orientation of this ruler: vertical for a line number ruler, + * or horizontal for a character number ruler. + */ + public void setOrientation(final Orientation newOrientation) { + Utils.checkNull(newOrientation, "orientation"); + + if (newOrientation != orientation) { + orientation = newOrientation; + rulerListeners.orientationChanged(this); + } + } + + /** + * @return The number of digits of space to allow for the + * numbers in a vertical ruler. + */ + public int getTextSize() { + return textSize; + } + + /** + * Set the number of digits of space to allow for the numbers. + * + * @param size The (integer) number of digits to allow in vertical + * ruler numbers. The default of {@link #DEFAULT_TEXT_SIZE} allows + * for 99,999 maximum rows. + * @throws IllegalArgumentException if the value is negative, + * or exceeds {@link #MAX_TEXT_SIZE}. + */ + public void setTextSize(final String size) { + Utils.checkNullOrEmpty(size, "size"); + + setTextSize(Integer.parseInt(size)); + } + + /** + * Set the number of digits of space to allow for the numbers. + * + * @param size The (integer) number of digits to allow in vertical + * ruler numbers. The default of {@link #DEFAULT_TEXT_SIZE} allows + * for 99,999 maximum rows. + * @throws IllegalArgumentException if the value is negative, + * or exceeds {@link #MAX_TEXT_SIZE}. + */ + public void setTextSize(final Number size) { + Utils.checkNullOrEmpty(size, "size"); + + setTextSize(size.intValue()); + } + + /** + * Set the number of digits of space to allow for the numbers. + * + * @param size The number of digits to allow in vertical ruler numbers. + * The default of {@link #DEFAULT_TEXT_SIZE} allows + * for 99,999 maximum rows. + * @throws IllegalArgumentException if the value is negative, + * or exceeds {@link #MAX_TEXT_SIZE}. + */ + public void setTextSize(final int size) { + if (size <= 0 || size > MAX_TEXT_SIZE) { + throw new IllegalArgumentException( + "Text size must be positive and less or equal to " + MAX_TEXT_SIZE + "."); + } + + if (size != textSize) { + int previousSize = textSize; + textSize = size; + rulerListeners.textSizeChanged(this, previousSize); + } + } + + /** + * @return The current list of listeners for changes in this component. + */ + public ListenerList<NumberRulerListener> getRulerListeners() { + return rulerListeners; + } + +} Propchange: pivot/trunk/wtk/src/org/apache/pivot/wtk/NumberRuler.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/NumberRulerListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/NumberRulerListener.java?rev=1913470&r1=1913469&r2=1913470&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/NumberRulerListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/NumberRulerListener.java Tue Oct 31 19:15:47 2023 @@ -1,75 +1,75 @@ -/* - * 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; - -import org.apache.pivot.util.ListenerList; - -/** - * Listener for changes to a {@link NumberRuler} that affect size and position. - */ -public interface NumberRulerListener { - /** - * Default implementation of the listener interface. - * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. - */ - @Deprecated - class Adapter implements NumberRulerListener { - @Override - public void orientationChanged(final NumberRuler ruler) { - // Empty block - } - - @Override - public void textSizeChanged(final NumberRuler ruler, final int previousSize) { - // Empty block - } - } - - /** - * Listeners list for this interface. - */ - class Listeners extends ListenerList<NumberRulerListener> - implements NumberRulerListener { - @Override - public void orientationChanged(final NumberRuler ruler) { - forEach(listener -> listener.orientationChanged(ruler)); - } - @Override - public void textSizeChanged(final NumberRuler ruler, final int previousSize) { - forEach(listener -> listener.textSizeChanged(ruler, previousSize)); - } - } - - /** - * The orientation of the {@link NumberRuler} changed. - * <p> Default operation is to do nothing. - * - * @param ruler The component that has changed. - */ - default void orientationChanged(NumberRuler ruler) { - } - - /** - * The text size (number of characters) of the ruler has changed. - * <p> Default operation is to do nothing. - * - * @param ruler The component that has changed. - * @param previousSize The previous value of the size. - */ - default void textSizeChanged(NumberRuler ruler, int previousSize) { - } -} +/* + * 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; + +import org.apache.pivot.util.ListenerList; + +/** + * Listener for changes to a {@link NumberRuler} that affect size and position. + */ +public interface NumberRulerListener { + /** + * Default implementation of the listener interface. + * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. + */ + @Deprecated + class Adapter implements NumberRulerListener { + @Override + public void orientationChanged(final NumberRuler ruler) { + // Empty block + } + + @Override + public void textSizeChanged(final NumberRuler ruler, final int previousSize) { + // Empty block + } + } + + /** + * Listeners list for this interface. + */ + class Listeners extends ListenerList<NumberRulerListener> + implements NumberRulerListener { + @Override + public void orientationChanged(final NumberRuler ruler) { + forEach(listener -> listener.orientationChanged(ruler)); + } + @Override + public void textSizeChanged(final NumberRuler ruler, final int previousSize) { + forEach(listener -> listener.textSizeChanged(ruler, previousSize)); + } + } + + /** + * The orientation of the {@link NumberRuler} changed. + * <p> Default operation is to do nothing. + * + * @param ruler The component that has changed. + */ + default void orientationChanged(NumberRuler ruler) { + } + + /** + * The text size (number of characters) of the ruler has changed. + * <p> Default operation is to do nothing. + * + * @param ruler The component that has changed. + * @param previousSize The previous value of the size. + */ + default void textSizeChanged(NumberRuler ruler, int previousSize) { + } +} Propchange: pivot/trunk/wtk/src/org/apache/pivot/wtk/NumberRulerListener.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Origin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Origin.java?rev=1913470&r1=1913469&r2=1913470&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/Origin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Origin.java Tue Oct 31 19:15:47 2023 @@ -1,51 +1,51 @@ -/* - * 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; - -/** - * An enumeration of the possible origin (that is, starting point) values - * for a {@link Gauge} component, including the starting angle offset for each. - */ -public enum Origin { - /** Origin is at the top. */ - NORTH(90.0f), - /** Origin is on the right side of the gauge. */ - EAST(360.0f), - /** Origin is at the bottom. */ - SOUTH(270.0f), - /** Origin is to the left side of the gauge. */ - WEST(180.0f); - - /** The angle (degrees) represented by this origin value. */ - private float originAngle; - - /** - * Construct an origin, specifying the angle. - * @param angle The origin angle (in degrees). - */ - Origin(final float angle) { - this.originAngle = angle; - } - - /** - * @return The angle (in degrees) represented by this origin. - */ - public float getOriginAngle() { - return this.originAngle; - } - -} +/* + * 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; + +/** + * An enumeration of the possible origin (that is, starting point) values + * for a {@link Gauge} component, including the starting angle offset for each. + */ +public enum Origin { + /** Origin is at the top. */ + NORTH(90.0f), + /** Origin is on the right side of the gauge. */ + EAST(360.0f), + /** Origin is at the bottom. */ + SOUTH(270.0f), + /** Origin is to the left side of the gauge. */ + WEST(180.0f); + + /** The angle (degrees) represented by this origin value. */ + private float originAngle; + + /** + * Construct an origin, specifying the angle. + * @param angle The origin angle (in degrees). + */ + Origin(final float angle) { + this.originAngle = angle; + } + + /** + * @return The angle (in degrees) represented by this origin. + */ + public float getOriginAngle() { + return this.originAngle; + } + +} Propchange: pivot/trunk/wtk/src/org/apache/pivot/wtk/Origin.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt_ja.json URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt_ja.json?rev=1913470&r1=1913469&r2=1913470&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt_ja.json (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt_ja.json Tue Oct 31 19:15:47 2023 @@ -1,18 +1,18 @@ -/* - * 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. - */ -{ defaultOption: "OK" -} +/* + * 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. + */ +{ defaultOption: "OK" +} Propchange: pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt_ja.json ------------------------------------------------------------------------------ svn:eol-style = native Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Ruler.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Ruler.java?rev=1913470&r1=1913469&r2=1913470&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/Ruler.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Ruler.java Tue Oct 31 19:15:47 2023 @@ -1,57 +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; - -import org.apache.pivot.util.ListenerList; -import org.apache.pivot.util.Utils; - -/** - * A viewport header that displays a ruler along either the top or left side. - */ -public class Ruler extends Component { - - private Orientation orientation; - - private RulerListener.Listeners rulerListeners = new RulerListener.Listeners(); - - public Ruler() { - this(Orientation.HORIZONTAL); - } - - public Ruler(Orientation orientation) { - setOrientation(orientation); - - installSkin(Ruler.class); - } - - public Orientation getOrientation() { - return orientation; - } - - public void setOrientation(Orientation orientation) { - Utils.checkNull(orientation, "orientation"); - - if (this.orientation != orientation) { - this.orientation = orientation; - rulerListeners.orientationChanged(this); - } - } - - public ListenerList<RulerListener> getRulerListeners() { - return rulerListeners; - } -} +/* + * 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; + +import org.apache.pivot.util.ListenerList; +import org.apache.pivot.util.Utils; + +/** + * A viewport header that displays a ruler along either the top or left side. + */ +public class Ruler extends Component { + + private Orientation orientation; + + private RulerListener.Listeners rulerListeners = new RulerListener.Listeners(); + + public Ruler() { + this(Orientation.HORIZONTAL); + } + + public Ruler(Orientation orientation) { + setOrientation(orientation); + + installSkin(Ruler.class); + } + + public Orientation getOrientation() { + return orientation; + } + + public void setOrientation(Orientation orientation) { + Utils.checkNull(orientation, "orientation"); + + if (this.orientation != orientation) { + this.orientation = orientation; + rulerListeners.orientationChanged(this); + } + } + + public ListenerList<RulerListener> getRulerListeners() { + return rulerListeners; + } +} Propchange: pivot/trunk/wtk/src/org/apache/pivot/wtk/Ruler.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/RulerListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/RulerListener.java?rev=1913470&r1=1913469&r2=1913470&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/RulerListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/RulerListener.java Tue Oct 31 19:15:47 2023 @@ -1,39 +1,39 @@ -/* - * 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; - -import org.apache.pivot.util.ListenerList; - - -public interface RulerListener { - /** - * Ruler listeners. - */ - public static class Listeners extends ListenerList<RulerListener> implements RulerListener { - @Override - public void orientationChanged(Ruler ruler) { - forEach(listener -> listener.orientationChanged(ruler)); - } - } - - /** - * Called when the ruler orientation has changed (thus necessitating layout again). - * - * @param ruler The ruler that has changed. - */ - public void orientationChanged(Ruler ruler); -} +/* + * 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; + +import org.apache.pivot.util.ListenerList; + + +public interface RulerListener { + /** + * Ruler listeners. + */ + public static class Listeners extends ListenerList<RulerListener> implements RulerListener { + @Override + public void orientationChanged(Ruler ruler) { + forEach(listener -> listener.orientationChanged(ruler)); + } + } + + /** + * Called when the ruler orientation has changed (thus necessitating layout again). + * + * @param ruler The ruler that has changed. + */ + public void orientationChanged(Ruler ruler); +} Propchange: pivot/trunk/wtk/src/org/apache/pivot/wtk/RulerListener.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/SelectDirection.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/SelectDirection.java?rev=1913470&r1=1913469&r2=1913470&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/SelectDirection.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/SelectDirection.java Tue Oct 31 19:15:47 2023 @@ -1,31 +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.wtk; - -/** - * Enumeration of the possible directions we can select in. In other words, - * which arrow key was first used to initiate selecting? - * <p> All four values used by {@link TextArea} and {@link TextPane} for - * two-dimensional selection logic. {@link TextInput} uses just the - * {@link #LEFT} and {@link #RIGHT} values. - */ -public enum SelectDirection { - LEFT, - RIGHT, - UP, - DOWN -} +/* + * 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; + +/** + * Enumeration of the possible directions we can select in. In other words, + * which arrow key was first used to initiate selecting? + * <p> All four values used by {@link TextArea} and {@link TextPane} for + * two-dimensional selection logic. {@link TextInput} uses just the + * {@link #LEFT} and {@link #RIGHT} values. + */ +public enum SelectDirection { + LEFT, + RIGHT, + UP, + DOWN +} Propchange: pivot/trunk/wtk/src/org/apache/pivot/wtk/SelectDirection.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Style.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Style.java?rev=1913470&r1=1913469&r2=1913470&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/Style.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Style.java Tue Oct 31 19:15:47 2023 @@ -1,95 +1,95 @@ -/* - * 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; - -/** - * An enumeration of oft-used style names in various components (esp. renderers). - * <p> Use of this is tied to the {@link Component.StyleDictionary#get(Style)} - * and {@link Component.StyleDictionary#put(Style,Object)} methods which specifically - * reference this enumeration. - * <p> Of course, these values must also correspond to bean methods in the component - * skins as appropriate. - */ -public enum Style { - activeBackgroundColor, - activeColor, - alignment, - alignToBaseline, - alternateRowBackgroundColor, - alwaysShowScrollButtons, - backgroundColor, - borderColor, - buttonBackgroundColor, - buttonPadding, - candlestick, - checkmarkImage, - closeTransitionDuration, - closeTransitionRate, - color, - criticalColor, - disabledColor, - editOnMouseDown, - fill, - font, - gridFrequency, - headingColor, - hideDisabledFiles, - highlightBackgroundColor, - highlightColor, - horizontalAlignment, - horizontalSpacing, - inactiveSelectionBackgroundColor, - inactiveSelectionColor, - includeTrailingHorizontalGridLine, - includeTrailingVerticalGridLine, - keyboardFolderTraversalEnabled, - margin, - markerSpacing, - minimumAspectRatio, - onlyMaxColor, - opacity, - padding, - resizable, - selectionBackgroundColor, - selectionChangeDuration, - selectionChangeEffect, - selectionChangeRate, - selectionColor, - showBranchControls, - showEmptyBranchControls, - showGridLines, - showHiddenFiles, - showHighlight, - showKeyboardShortcuts, - showVerticalGridLines, - sizeToContent, - sizeToSelection, - spacing, - tabOrientation, - tabWidth, - textColor, - textDecoration, - toolbar, - units, - useShadow, - variableItemHeight, - verticalAlignment, - verticalGridColor, - verticalSpacing, - warningColor, - wrapText -} +/* + * 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; + +/** + * An enumeration of oft-used style names in various components (esp. renderers). + * <p> Use of this is tied to the {@link Component.StyleDictionary#get(Style)} + * and {@link Component.StyleDictionary#put(Style,Object)} methods which specifically + * reference this enumeration. + * <p> Of course, these values must also correspond to bean methods in the component + * skins as appropriate. + */ +public enum Style { + activeBackgroundColor, + activeColor, + alignment, + alignToBaseline, + alternateRowBackgroundColor, + alwaysShowScrollButtons, + backgroundColor, + borderColor, + buttonBackgroundColor, + buttonPadding, + candlestick, + checkmarkImage, + closeTransitionDuration, + closeTransitionRate, + color, + criticalColor, + disabledColor, + editOnMouseDown, + fill, + font, + gridFrequency, + headingColor, + hideDisabledFiles, + highlightBackgroundColor, + highlightColor, + horizontalAlignment, + horizontalSpacing, + inactiveSelectionBackgroundColor, + inactiveSelectionColor, + includeTrailingHorizontalGridLine, + includeTrailingVerticalGridLine, + keyboardFolderTraversalEnabled, + margin, + markerSpacing, + minimumAspectRatio, + onlyMaxColor, + opacity, + padding, + resizable, + selectionBackgroundColor, + selectionChangeDuration, + selectionChangeEffect, + selectionChangeRate, + selectionColor, + showBranchControls, + showEmptyBranchControls, + showGridLines, + showHiddenFiles, + showHighlight, + showKeyboardShortcuts, + showVerticalGridLines, + sizeToContent, + sizeToSelection, + spacing, + tabOrientation, + tabWidth, + textColor, + textDecoration, + toolbar, + units, + useShadow, + variableItemHeight, + verticalAlignment, + verticalGridColor, + verticalSpacing, + warningColor, + wrapText +} Propchange: pivot/trunk/wtk/src/org/apache/pivot/wtk/Style.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputMethodListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputMethodListener.java?rev=1913470&r1=1913469&r2=1913470&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputMethodListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputMethodListener.java Tue Oct 31 19:15:47 2023 @@ -1,128 +1,128 @@ -/* - * 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; - -import java.awt.Rectangle; -import java.awt.event.InputMethodEvent; -import java.awt.event.InputMethodListener; -import java.awt.font.TextHitInfo; -import java.awt.im.InputMethodRequests; -import java.text.AttributedCharacterIterator; - - -/** - * An interface expected to be implemented by every (text) component - * that can interace with the Input Method Editors for on-the-spot - * editing, esp. of Far Eastern languages (Chinese, Japanese, etc.). - * <p> This interface encapsulates both the {@link InputMethodRequests} - * and {@link InputMethodListener} standard interfaces to reduce the - * number of objects needed. - */ -public interface TextInputMethodListener extends InputMethodRequests, InputMethodListener { - - /** - * A default implementation of the {@link TextInputMethodListener} interface that can be used - * to provide the minimum necessary functionality. - * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. - */ - @Deprecated - public static class Adapter implements TextInputMethodListener { - @Override - public AttributedCharacterIterator cancelLatestCommittedText( - AttributedCharacterIterator.Attribute[] attributes) { - return null; - } - - @Override - public AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex, - AttributedCharacterIterator.Attribute[] attributes) { - return null; - } - - @Override - public int getCommittedTextLength() { - return 0; - } - - @Override - public int getInsertPositionOffset() { - return 0; - } - - @Override - public TextHitInfo getLocationOffset(int x, int y) { - return null; - } - - @Override - public AttributedCharacterIterator getSelectedText(AttributedCharacterIterator.Attribute[] attributes) { - return null; - } - - @Override - public Rectangle getTextLocation(TextHitInfo offset) { - return new Rectangle(); - } - - @Override - public void inputMethodTextChanged(InputMethodEvent event) { - // empty block - } - - @Override - public void caretPositionChanged(InputMethodEvent event) { - // empty block - } - } - - default AttributedCharacterIterator cancelLatestCommittedText( - AttributedCharacterIterator.Attribute[] attributes) { - return null; - } - - default AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex, - AttributedCharacterIterator.Attribute[] attributes) { - return null; - } - - default int getCommittedTextLength() { - return 0; - } - - default int getInsertPositionOffset() { - return 0; - } - - default TextHitInfo getLocationOffset(int x, int y) { - return null; - } - - default AttributedCharacterIterator getSelectedText(AttributedCharacterIterator.Attribute[] attributes) { - return null; - } - - default Rectangle getTextLocation(TextHitInfo offset) { - return new Rectangle(); - } - - default void inputMethodTextChanged(InputMethodEvent event) { - } - - default void caretPositionChanged(InputMethodEvent event) { - } - -} +/* + * 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; + +import java.awt.Rectangle; +import java.awt.event.InputMethodEvent; +import java.awt.event.InputMethodListener; +import java.awt.font.TextHitInfo; +import java.awt.im.InputMethodRequests; +import java.text.AttributedCharacterIterator; + + +/** + * An interface expected to be implemented by every (text) component + * that can interace with the Input Method Editors for on-the-spot + * editing, esp. of Far Eastern languages (Chinese, Japanese, etc.). + * <p> This interface encapsulates both the {@link InputMethodRequests} + * and {@link InputMethodListener} standard interfaces to reduce the + * number of objects needed. + */ +public interface TextInputMethodListener extends InputMethodRequests, InputMethodListener { + + /** + * A default implementation of the {@link TextInputMethodListener} interface that can be used + * to provide the minimum necessary functionality. + * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. + */ + @Deprecated + public static class Adapter implements TextInputMethodListener { + @Override + public AttributedCharacterIterator cancelLatestCommittedText( + AttributedCharacterIterator.Attribute[] attributes) { + return null; + } + + @Override + public AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex, + AttributedCharacterIterator.Attribute[] attributes) { + return null; + } + + @Override + public int getCommittedTextLength() { + return 0; + } + + @Override + public int getInsertPositionOffset() { + return 0; + } + + @Override + public TextHitInfo getLocationOffset(int x, int y) { + return null; + } + + @Override + public AttributedCharacterIterator getSelectedText(AttributedCharacterIterator.Attribute[] attributes) { + return null; + } + + @Override + public Rectangle getTextLocation(TextHitInfo offset) { + return new Rectangle(); + } + + @Override + public void inputMethodTextChanged(InputMethodEvent event) { + // empty block + } + + @Override + public void caretPositionChanged(InputMethodEvent event) { + // empty block + } + } + + default AttributedCharacterIterator cancelLatestCommittedText( + AttributedCharacterIterator.Attribute[] attributes) { + return null; + } + + default AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex, + AttributedCharacterIterator.Attribute[] attributes) { + return null; + } + + default int getCommittedTextLength() { + return 0; + } + + default int getInsertPositionOffset() { + return 0; + } + + default TextHitInfo getLocationOffset(int x, int y) { + return null; + } + + default AttributedCharacterIterator getSelectedText(AttributedCharacterIterator.Attribute[] attributes) { + return null; + } + + default Rectangle getTextLocation(TextHitInfo offset) { + return new Rectangle(); + } + + default void inputMethodTextChanged(InputMethodEvent event) { + } + + default void caretPositionChanged(InputMethodEvent event) { + } + +} Propchange: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputMethodListener.java ------------------------------------------------------------------------------ svn:eol-style = native