Package org.openstreetmap.josm.gui.util
Class AdjustmentSynchronizer
- java.lang.Object
-
- org.openstreetmap.josm.gui.util.AdjustmentSynchronizer
-
- All Implemented Interfaces:
java.awt.event.AdjustmentListener,java.util.EventListener
public class AdjustmentSynchronizer extends java.lang.Object implements java.awt.event.AdjustmentListener
Synchronizes scrollbar adjustments between a set ofAdjustables. 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 java.util.Map<java.awt.Adjustable,java.lang.Boolean>enabledMapprivate ChangeNotifierobservableprivate java.util.Set<java.awt.Adjustable>synchronizedAdjustables
-
Constructor Summary
Constructors Constructor Description AdjustmentSynchronizer()Constructs a newAdjustmentSynchronizer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadapt(javax.swing.JCheckBox view, java.awt.Adjustable adjustable)Wires aJCheckBoxto the adjustment synchronizer, in such a way that: state changes in the checkbox control whether the adjustable participates in synchronized adjustment state changes in thisAdjustmentSynchronizerare reflected in theJCheckBoxvoidadjustmentValueChanged(java.awt.event.AdjustmentEvent e)Event handler forAdjustmentEventsprotected booleanisParticipatingInSynchronizedScrolling(java.awt.Adjustable adjustable)Returns true if an adjustable is participating in synchronized scrollingvoidparticipateInSynchronizedScrolling(java.awt.Adjustable adjustable)Registers anAdjustablefor participation in synchronized scrolling.protected voidsetParticipatingInSynchronizedScrolling(java.awt.Adjustable adjustable, boolean isParticipating)Sets whetheradjustableparticipates in adjustment synchronization or not
-
-
-
Field Detail
-
synchronizedAdjustables
private final java.util.Set<java.awt.Adjustable> synchronizedAdjustables
-
enabledMap
private final java.util.Map<java.awt.Adjustable,java.lang.Boolean> enabledMap
-
observable
private final ChangeNotifier observable
-
-
Constructor Detail
-
AdjustmentSynchronizer
public AdjustmentSynchronizer()
Constructs a newAdjustmentSynchronizer
-
-
Method Detail
-
participateInSynchronizedScrolling
public void participateInSynchronizedScrolling(java.awt.Adjustable adjustable)
Registers anAdjustablefor participation in synchronized scrolling.- Parameters:
adjustable- the adjustable
-
adjustmentValueChanged
public void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
Event handler forAdjustmentEvents- Specified by:
adjustmentValueChangedin interfacejava.awt.event.AdjustmentListener
-
setParticipatingInSynchronizedScrolling
protected void setParticipatingInSynchronizedScrolling(java.awt.Adjustable adjustable, boolean isParticipating)
Sets whetheradjustableparticipates in adjustment synchronization or not- Parameters:
adjustable- the adjustableisParticipating-trueifadjustableparticipates in adjustment synchronization
-
isParticipatingInSynchronizedScrolling
protected boolean isParticipatingInSynchronizedScrolling(java.awt.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:
java.lang.IllegalStateException- if adjustable is not registered for synchronized scrolling
-
adapt
public void adapt(javax.swing.JCheckBox view, java.awt.Adjustable adjustable)
Wires aJCheckBoxto 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
AdjustmentSynchronizerare reflected in theJCheckBox
- Parameters:
view- the checkbox to control whether an adjustable participates in synchronized adjustmentadjustable- the adjustable- Throws:
java.lang.IllegalArgumentException- if view is nulljava.lang.IllegalArgumentException- if adjustable is null
-
-