Package org.openstreetmap.josm.gui.util
Class AdjustmentSynchronizer
- java.lang.Object
-
- org.openstreetmap.josm.gui.util.AdjustmentSynchronizer
-
- All Implemented Interfaces:
AdjustmentListener
,EventListener
public class AdjustmentSynchronizer extends Object implements AdjustmentListener
Synchronizes scrollbar adjustments between a set ofAdjustable
s. Whenever the adjustment of one of the registered Adjustables is updated the adjustment of the other registered Adjustables is adjusted too.- Since:
- 6147
-
-
Field Summary
Fields Modifier and Type Field Description private Map<Adjustable,Boolean>
enabledMap
private ChangeNotifier
observable
private Set<Adjustable>
synchronizedAdjustables
-
Constructor Summary
Constructors Constructor Description AdjustmentSynchronizer()
Constructs a newAdjustmentSynchronizer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
adapt(JCheckBox view, Adjustable adjustable)
Wires aJCheckBox
to the adjustment synchronizer, in such a way that: state changes in the checkbox control whether the adjustable participates in synchronized adjustment state changes in thisAdjustmentSynchronizer
are reflected in theJCheckBox
void
adjustmentValueChanged(AdjustmentEvent e)
Event handler forAdjustmentEvent
sprotected boolean
isParticipatingInSynchronizedScrolling(Adjustable adjustable)
Returns true if an adjustable is participating in synchronized scrollingvoid
participateInSynchronizedScrolling(Adjustable adjustable)
Registers anAdjustable
for participation in synchronized scrolling.protected void
setParticipatingInSynchronizedScrolling(Adjustable adjustable, boolean isParticipating)
Sets whetheradjustable
participates in adjustment synchronization or not
-
-
-
Field Detail
-
synchronizedAdjustables
private final Set<Adjustable> synchronizedAdjustables
-
enabledMap
private final Map<Adjustable,Boolean> enabledMap
-
observable
private final ChangeNotifier observable
-
-
Constructor Detail
-
AdjustmentSynchronizer
public AdjustmentSynchronizer()
Constructs a newAdjustmentSynchronizer
-
-
Method Detail
-
participateInSynchronizedScrolling
public void participateInSynchronizedScrolling(Adjustable adjustable)
Registers anAdjustable
for participation in synchronized scrolling.- Parameters:
adjustable
- the adjustable
-
adjustmentValueChanged
public void adjustmentValueChanged(AdjustmentEvent e)
Event handler forAdjustmentEvent
s- Specified by:
adjustmentValueChanged
in interfaceAdjustmentListener
-
setParticipatingInSynchronizedScrolling
protected void setParticipatingInSynchronizedScrolling(Adjustable adjustable, boolean isParticipating)
Sets whetheradjustable
participates in adjustment synchronization or not- Parameters:
adjustable
- the adjustableisParticipating
-true
ifadjustable
participates in adjustment synchronization
-
isParticipatingInSynchronizedScrolling
protected boolean isParticipatingInSynchronizedScrolling(Adjustable adjustable)
Returns true if an adjustable is participating in synchronized scrolling- Parameters:
adjustable
- the adjustable- Returns:
- true, if the adjustable is participating in synchronized scrolling, false otherwise
- Throws:
IllegalStateException
- if adjustable is not registered for synchronized scrolling
-
adapt
public void adapt(JCheckBox view, Adjustable adjustable)
Wires aJCheckBox
to the adjustment synchronizer, in such a way that:- state changes in the checkbox control whether the adjustable participates in synchronized adjustment
- state changes in this
AdjustmentSynchronizer
are reflected in theJCheckBox
- Parameters:
view
- the checkbox to control whether an adjustable participates in synchronized adjustmentadjustable
- the adjustable- Throws:
IllegalArgumentException
- if view is nullIllegalArgumentException
- if adjustable is null
-
-