Class HistoryBrowserModel
java.lang.Object
org.openstreetmap.josm.gui.util.ChangeNotifier
org.openstreetmap.josm.gui.history.HistoryBrowserModel
- All Implemented Interfaces:
DataSetListener,MainLayerManager.ActiveLayerChangeListener
public class HistoryBrowserModel
extends ChangeNotifier
implements MainLayerManager.ActiveLayerChangeListener, DataSetListener
This is the model used by the history browser.
The model state consists of the following elements:
- the
Historyof a specificOsmPrimitive - a dedicated version in this
Historycalled thePointInTimeType.REFERENCE_POINT_IN_TIME - another version in this
Historycalled thePointInTimeType.CURRENT_POINT_IN_TIME
HistoryBrowser always compares the PointInTimeType.REFERENCE_POINT_IN_TIME with the
PointInTimeType.CURRENT_POINT_IN_TIME.
This model provides various TableModels for JTables used in HistoryBrowser, for
instance:
getTagTableModel(PointInTimeType)replies aTableModelfor the tags of either of the two selected versionsgetNodeListTableModel(PointInTimeType)replies aTableModelfor the list of nodes of the two selected versions (if the current history provides information about aWay-
getRelationMemberTableModel(PointInTimeType)replies aTableModelfor the list of relation members of the two selected versions (if the current history provides information about aRelation
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classCreates aHistoryOsmPrimitivefrom aOsmPrimitive -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate HistoryOsmPrimitiveprivate final DiffTableModelprivate final DiffTableModelprivate final TagTableModelprivate final ColorScaleprivate Historythe history of an OsmPrimitiveprivate HistoryOsmPrimitivelatest isn't a reference of history.private HistoryOsmPrimitiveprivate final DiffTableModelprivate final DiffTableModelprivate final TagTableModelprivate final VersionTableModel -
Constructor Summary
ConstructorsConstructorDescriptionconstructorHistoryBrowserModel(History history) Creates a new history browser model for a given history. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled whenever the active or edit layer changed.private booleancanShowAsLatest(OsmPrimitive primitive) voiddataChanged(DataChangedEvent event) Called after big changes in dataset.private voidReplies the history OSM primitive for thePointInTimeType.CURRENT_POINT_IN_TIMEreplies the history managed by this modelReturns the key set (union of current and reference point in type key sets).Returns the latestHistoryOsmPrimitive.getNodeListTableModel(PointInTimeType pointInTimeType) Replies the node list table model for the respective point in time.replies the history OSM primitive for a given point in timegetPrimitive(int row) Returns theHistoryPrimitiveat the given row.Replies the history OSM primitive for thePointInTimeType.REFERENCE_POINT_IN_TIMEgetRelationMemberTableModel(PointInTimeType pointInTimeType) Replies the relation member table model for the respective point in time.getTagTableModel(PointInTimeType pointInTimeType) Replies the tag table model for the respective point in time.getVersionColor(int row) Returns the color for the primitive in the given rowgetVersionColor(HistoryOsmPrimitive primitive) Returns the color for the given primitive timestampReplies the table model to be used in aJTablewhich shows the list of versions in this history.private voidprivate voidShould be called every time either reference of current changes to update the diff.private voidbooleanisCurrentPointInTime(int row) Determines if the given row is the current point in time.booleanisLatest(int row) Determines if the given row is the latest.booleanisLatest(HistoryOsmPrimitive primitive) Returns true ifprimitiveis the latest primitive representing the version currently edited in the current data layer.booleanisReferencePointInTime(int row) Determines if the given row is the reference point in time.(package private) booleanisSamePrimitive(History history) voidnodeMoved(NodeMovedEvent event) A node's coordinates were modified.voidMinor dataset change, currently only changeset id changed is supported, but can be extended in future.voidA bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.voidA bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.voidA relation's members have changed.voidsetCurrentPointInTime(int row) Sets the current point in time to the given row.voidsetCurrentPointInTime(HistoryOsmPrimitive current) Sets theHistoryOsmPrimitivewhich plays the role of the current point in time (seePointInTimeType).voidsetHistory(History history) sets the history to be managed by this modelprotected voidsetLatest(HistoryOsmPrimitive latest) Sets the latestHistoryOsmPrimitive.voidsetReferencePointInTime(int row) Sets the reference point in time to the given row.voidsetReferencePointInTime(HistoryOsmPrimitive reference) Sets theHistoryOsmPrimitivewhich plays the role of a reference point in time (seePointInTimeType).voidtagsChanged(TagsChangedEvent event) There was some change in the tag set of a primitive.voidRemoves this model as listener for data change and layer change events.voidA way's node list was changed.Methods inherited from class org.openstreetmap.josm.gui.util.ChangeNotifier
addChangeListener, fireStateChanged, removeChangeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.data.osm.event.DataSetListener
dataChangedIndividualEvents
-
Field Details
-
history
the history of an OsmPrimitive -
reference
-
current
-
latest
latest isn't a reference of history. It's a clone of the currently editedOsmPrimitivein the current edit layer. -
versionTableModel
-
currentTagTableModel
-
referenceTagTableModel
-
currentRelationMemberTableModel
-
referenceRelationMemberTableModel
-
referenceNodeListTableModel
-
currentNodeListTableModel
-
dateScale
-
-
Constructor Details
-
HistoryBrowserModel
public HistoryBrowserModel()constructor -
HistoryBrowserModel
Creates a new history browser model for a given history.- Parameters:
history- the history. Must not be null.- Throws:
IllegalArgumentException- if history is null
-
-
Method Details
-
getHistory
replies the history managed by this model- Returns:
- the history
-
isSamePrimitive
-
canShowAsLatest
-
setHistory
sets the history to be managed by this model- Parameters:
history- the history
-
fireModelChange
-
getVersionTableModel
Replies the table model to be used in aJTablewhich shows the list of versions in this history.- Returns:
- the table model
-
initTagTableModels
-
initNodeListTableModels
Should be called every time either reference of current changes to update the diff. TODO: Maybe rename to reflect this? eg. updateNodeListTableModels -
initMemberListTableModels
-
getTagTableModel
Replies the tag table model for the respective point in time.- Parameters:
pointInTimeType- the type of the point in time (must not be null)- Returns:
- the tag table model
- Throws:
IllegalArgumentException- if pointInTimeType is null
-
getNodeListTableModel
Replies the node list table model for the respective point in time.- Parameters:
pointInTimeType- the type of the point in time (must not be null)- Returns:
- the node list table model
- Throws:
IllegalArgumentException- if pointInTimeType is null
-
getRelationMemberTableModel
Replies the relation member table model for the respective point in time.- Parameters:
pointInTimeType- the type of the point in time (must not be null)- Returns:
- the relation member table model
- Throws:
IllegalArgumentException- if pointInTimeType is null
-
setReferencePointInTime
Sets theHistoryOsmPrimitivewhich plays the role of a reference point in time (seePointInTimeType).- Parameters:
reference- the reference history primitive. Must not be null.- Throws:
IllegalArgumentException- if reference is nullIllegalStateException- if this model isn't a assigned a history yetIllegalArgumentException- if reference isn't an history primitive for the history managed by this mode- See Also:
-
setCurrentPointInTime
Sets theHistoryOsmPrimitivewhich plays the role of the current point in time (seePointInTimeType).- Parameters:
current- the reference history primitive. Must not benull.- Throws:
IllegalArgumentException- if reference isnullIllegalStateException- if this model isn't a assigned a history yetIllegalArgumentException- if reference isn't an history primitive for the history managed by this mode- See Also:
-
getCurrentPointInTime
Replies the history OSM primitive for thePointInTimeType.CURRENT_POINT_IN_TIME- Returns:
- the history OSM primitive for the
PointInTimeType.CURRENT_POINT_IN_TIME(may be null)
-
getReferencePointInTime
Replies the history OSM primitive for thePointInTimeType.REFERENCE_POINT_IN_TIME- Returns:
- the history OSM primitive for the
PointInTimeType.REFERENCE_POINT_IN_TIME(may be null)
-
getPointInTime
replies the history OSM primitive for a given point in time- Parameters:
type- the type of the point in time (must not be null)- Returns:
- the respective primitive. Can be null.
- Throws:
IllegalArgumentException- if type is null
-
isLatest
Returns true ifprimitiveis the latest primitive representing the version currently edited in the current data layer.- Parameters:
primitive- the primitive to check- Returns:
- true if
primitiveis the latest primitive
-
setReferencePointInTime
Sets the reference point in time to the given row.- Parameters:
row- row number
-
setCurrentPointInTime
Sets the current point in time to the given row.- Parameters:
row- row number
-
isReferencePointInTime
Determines if the given row is the reference point in time.- Parameters:
row- row number- Returns:
trueif the given row is the reference point in time
-
isCurrentPointInTime
Determines if the given row is the current point in time.- Parameters:
row- row number- Returns:
trueif the given row is the current point in time
-
getPrimitive
Returns theHistoryPrimitiveat the given row.- Parameters:
row- row number- Returns:
- the
HistoryPrimitiveat the given row
-
isLatest
Determines if the given row is the latest.- Parameters:
row- row number- Returns:
trueif the given row is the latest
-
getLatest
Returns the latestHistoryOsmPrimitive.- Returns:
- the latest
HistoryOsmPrimitive - Since:
- 11646
-
getKeySet
Returns the key set (union of current and reference point in type key sets).- Returns:
- the key set (union of current and reference point in type key sets)
- Since:
- 11647
-
setLatest
Sets the latestHistoryOsmPrimitive.- Parameters:
latest- the latestHistoryOsmPrimitive
-
unlinkAsListener
Removes this model as listener for data change and layer change events. -
nodeMoved
Description copied from interface:DataSetListenerA node's coordinates were modified.- Specified by:
nodeMovedin interfaceDataSetListener- Parameters:
event- The event for the node that was moved.
-
primitivesAdded
Description copied from interface:DataSetListenerA bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.- Specified by:
primitivesAddedin interfaceDataSetListener- Parameters:
event- An event for an collection of newly-visible primitives
-
primitivesRemoved
Description copied from interface:DataSetListenerA bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.- Specified by:
primitivesRemovedin interfaceDataSetListener- Parameters:
event- An event for an collection of newly-invisible primitives
-
relationMembersChanged
Description copied from interface:DataSetListenerA relation's members have changed.- Specified by:
relationMembersChangedin interfaceDataSetListener- Parameters:
event- The event for the relation that was modified.
-
tagsChanged
Description copied from interface:DataSetListenerThere was some change in the tag set of a primitive. It can have been a tag addition, tag removal or change in tag value.- Specified by:
tagsChangedin interfaceDataSetListener- Parameters:
event- the event for the primitive, whose tags were affected.
-
wayNodesChanged
Description copied from interface:DataSetListenerA way's node list was changed.- Specified by:
wayNodesChangedin interfaceDataSetListener- Parameters:
event- The event for the way that was modified.
-
dataChanged
Description copied from interface:DataSetListenerCalled after big changes in dataset. Usually other events are stopped using Dataset.beginUpdate() and after operation is completed (Dataset.endUpdate()),DataSetListener.dataChanged(DataChangedEvent event)is called.- Specified by:
dataChangedin interfaceDataSetListener- Parameters:
event- data change event
-
otherDatasetChange
Description copied from interface:DataSetListenerMinor dataset change, currently only changeset id changed is supported, but can be extended in future.- Specified by:
otherDatasetChangein interfaceDataSetListener- Parameters:
event- the event for data modification
-
activeOrEditLayerChanged
Description copied from interface:MainLayerManager.ActiveLayerChangeListenerCalled whenever the active or edit layer changed.You can be sure that this layer is still contained in this set.
Listeners are called in the EDT thread and you can manipulate the layer manager in the current thread.
- Specified by:
activeOrEditLayerChangedin interfaceMainLayerManager.ActiveLayerChangeListener- Parameters:
e- The change event.
-
getVersionColor
Returns the color for the primitive in the given row- Parameters:
row- row number- Returns:
- the color for the primitive in the given row
-
getVersionColor
Returns the color for the given primitive timestamp- Parameters:
primitive- the history primitive- Returns:
- the color for the given primitive timestamp
-