Class OrientationAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.gui.widgets.OrientationAction
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.beans.PropertyChangeListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
public class OrientationAction extends javax.swing.AbstractAction implements java.beans.PropertyChangeListener
An action that toggles text orientation.- Since:
- 18221
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.Component
component
private static java.util.List<java.lang.String>
DEFAULT_LOCALIZED_KEYS
Default forLOCALIZED_KEYS
private static java.util.List<java.lang.String>
DEFAULT_RTL_LANGUAGES
Default forRTL_LANGUAGES
private javax.swing.ImageIcon
iconLTR
private javax.swing.ImageIcon
iconRTL
private static java.util.regex.Pattern
LANG_PATTERN
static ListProperty
LOCALIZED_KEYS
Keys whose values are localized Regex fractions are allowed.protected static java.util.regex.Pattern
localizedKeys
private static java.lang.String
NEW_STATE
static ListProperty
RTL_LANGUAGES
Language codes of languages that are right-to-leftprotected static java.util.Set<java.lang.String>
RTLLanguages
-
Constructor Summary
Constructors Constructor Description OrientationAction(java.awt.Component component)
Constructs a newOrientationAction
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
private static java.util.regex.Pattern
compileLocalizedKeys()
static java.awt.ComponentOrientation
getDefaultComponentOrientation()
Returns the default component orientation by the user's localestatic java.awt.ComponentOrientation
getNamelikeOrientation(java.lang.String key)
Returns the text orientation of the value for the given key.static javax.swing.KeyStroke
getShortcutKey()
Returns the shortcut key to assign to this action.static java.awt.ComponentOrientation
getValueOrientation(java.lang.String key)
Returns the text orientation of the value for the given key.void
propertyChange(java.beans.PropertyChangeEvent evt)
void
updateState()
Updates the text and the icon.-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Field Detail
-
DEFAULT_RTL_LANGUAGES
private static final java.util.List<java.lang.String> DEFAULT_RTL_LANGUAGES
Default forRTL_LANGUAGES
-
DEFAULT_LOCALIZED_KEYS
private static final java.util.List<java.lang.String> DEFAULT_LOCALIZED_KEYS
Default forLOCALIZED_KEYS
-
RTL_LANGUAGES
public static final ListProperty RTL_LANGUAGES
Language codes of languages that are right-to-left- See Also:
getValueOrientation(java.lang.String)
-
LOCALIZED_KEYS
public static final ListProperty LOCALIZED_KEYS
Keys whose values are localized Regex fractions are allowed. The items will be merged into a regular expression.- See Also:
getValueOrientation(java.lang.String)
-
LANG_PATTERN
private static final java.util.regex.Pattern LANG_PATTERN
-
NEW_STATE
private static final java.lang.String NEW_STATE
- See Also:
- Constant Field Values
-
component
private java.awt.Component component
-
iconRTL
private javax.swing.ImageIcon iconRTL
-
iconLTR
private javax.swing.ImageIcon iconLTR
-
RTLLanguages
protected static final java.util.Set<java.lang.String> RTLLanguages
-
localizedKeys
protected static final java.util.regex.Pattern localizedKeys
-
-
Constructor Detail
-
OrientationAction
public OrientationAction(java.awt.Component component)
Constructs a newOrientationAction
.- Parameters:
component
- The component to toggle
-
-
Method Detail
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
updateState
public void updateState()
Updates the text and the icon.
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
getShortcutKey
public static javax.swing.KeyStroke getShortcutKey()
Returns the shortcut key to assign to this action.- Returns:
- the shortcut key
-
getDefaultComponentOrientation
public static java.awt.ComponentOrientation getDefaultComponentOrientation()
Returns the default component orientation by the user's locale- Returns:
- the default component orientation
-
getValueOrientation
public static java.awt.ComponentOrientation getValueOrientation(java.lang.String key)
Returns the text orientation of the value for the given key. This is intended for Preset Dialog comboboxes. The choices in the dropdown list are typically translated. Ideally the user needs not see the English value. The algorithm is as follows:- If the key has an explicit language suffix, return the text orientation for that language.
- Else return the text orientation of the user's locale.
rtl-languages
.- Parameters:
key
- the key- Returns:
- the text orientation of the value
-
getNamelikeOrientation
public static java.awt.ComponentOrientation getNamelikeOrientation(java.lang.String key)
Returns the text orientation of the value for the given key. This expansion ofgetValueOrientation(java.lang.String)
is intended for Preset Dialog textfields and for the Add Tag and Edit Tag dialog comboboxes. The algorithm is as follows:- If the key has an explicit language suffix, return the text orientation for that language.
- If the key is usually localized, return the text orientation of the user's locale.
- Else return left to right.
localized-keys
. You can configure which languages are RTL with the list property:rtl-languages
.- Parameters:
key
- the key- Returns:
- the text orientation of the value
-
compileLocalizedKeys
private static java.util.regex.Pattern compileLocalizedKeys()
-
-