Class OrientationAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.gui.widgets.OrientationAction
-
- All Implemented Interfaces:
ActionListener
,PropertyChangeListener
,Serializable
,Cloneable
,EventListener
,Action
public class OrientationAction extends AbstractAction implements PropertyChangeListener
An action that toggles text orientation.- Since:
- 18221
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private Component
component
private static List<String>
DEFAULT_LOCALIZED_KEYS
Default forLOCALIZED_KEYS
private static List<String>
DEFAULT_RTL_LANGUAGES
Default forRTL_LANGUAGES
private ImageIcon
iconLTR
private ImageIcon
iconRTL
private static Pattern
LANG_PATTERN
static ListProperty
LOCALIZED_KEYS
Keys whose values are localized Regex fractions are allowed.protected static Pattern
localizedKeys
private static String
NEW_STATE
static ListProperty
RTL_LANGUAGES
Language codes of languages that are right-to-leftprotected static Set<String>
RTLLanguages
-
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
-
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
-
Constructor Summary
Constructors Constructor Description OrientationAction(Component component)
Constructs a newOrientationAction
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(ActionEvent e)
private static Pattern
compileLocalizedKeys()
static ComponentOrientation
getDefaultComponentOrientation()
Returns the default component orientation by the user's localestatic ComponentOrientation
getNamelikeOrientation(String key)
Returns the text orientation of the value for the given key.static KeyStroke
getShortcutKey()
Returns the shortcut key to assign to this action.static ComponentOrientation
getValueOrientation(String key)
Returns the text orientation of the value for the given key.void
propertyChange(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 List<String> DEFAULT_RTL_LANGUAGES
Default forRTL_LANGUAGES
-
DEFAULT_LOCALIZED_KEYS
private static final List<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 Pattern LANG_PATTERN
-
NEW_STATE
private static final String NEW_STATE
- See Also:
- Constant Field Values
-
RTLLanguages
protected static final Set<String> RTLLanguages
-
localizedKeys
protected static final Pattern localizedKeys
-
-
Constructor Detail
-
OrientationAction
public OrientationAction(Component component)
Constructs a newOrientationAction
.- Parameters:
component
- The component to toggle
-
-
Method Detail
-
actionPerformed
public void actionPerformed(ActionEvent e)
- Specified by:
actionPerformed
in interfaceActionListener
-
updateState
public void updateState()
Updates the text and the icon.
-
propertyChange
public void propertyChange(PropertyChangeEvent evt)
- Specified by:
propertyChange
in interfacePropertyChangeListener
-
getShortcutKey
public static KeyStroke getShortcutKey()
Returns the shortcut key to assign to this action.- Returns:
- the shortcut key
-
getDefaultComponentOrientation
public static ComponentOrientation getDefaultComponentOrientation()
Returns the default component orientation by the user's locale- Returns:
- the default component orientation
-
getValueOrientation
public static ComponentOrientation getValueOrientation(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 ComponentOrientation getNamelikeOrientation(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 Pattern compileLocalizedKeys()
-
-