public class JoinAreasAction extends JosmAction
Modifier and Type | Class and Description |
---|---|
static class |
JoinAreasAction.AssembledMultipolygon |
static class |
JoinAreasAction.AssembledPolygon
This helper class describes a polygon, assembled from several ways.
|
static class |
JoinAreasAction.JoinAreasResult
This helper class describes join areas action result.
|
static class |
JoinAreasAction.Multipolygon |
(package private) static class |
JoinAreasAction.PolygonLevel
Helper storage class for finding findOuterWays
|
private static class |
JoinAreasAction.RelationRole |
static class |
JoinAreasAction.WayInPolygon
HelperClass - saves a way and the "inside" side.
|
private static class |
JoinAreasAction.WayTraverser
This hepler class implements algorithm traversing trough connected ways.
|
JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
Modifier and Type | Field and Description |
---|---|
private List<Relation> |
addedRelations |
private LinkedList<Command> |
cmds |
private int |
cmdsCount |
sc
changeSupport, enabled
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 and Description |
---|
JoinAreasAction()
Constructs a new
JoinAreasAction . |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e)
Gets called whenever the shortcut is pressed or the menu entry is selected.
|
private JoinAreasAction.RelationRole |
addOwnMultipolygonRelation(Collection<Way> inner)
Will add own multipolygon relation to the "previously existing" relations.
|
private static List<List<Node>> |
buildNodeChunks(Way way,
Collection<Node> splitNodes)
Simple chunking version.
|
private List<JoinAreasAction.Multipolygon> |
collectMultipolygons(Collection<Way> selectedWays)
This method analyzes multipolygon relationships of given ways and collects addition inner ways to consider.
|
private void |
commitCommands(String description)
Commits the command list with a description
|
static List<JoinAreasAction.AssembledPolygon> |
findBoundaryPolygons(Collection<JoinAreasAction.WayInPolygon> multigonWays,
List<Way> discardedResult)
Finds all ways that form inner or outer boundaries.
|
private List<JoinAreasAction.PolygonLevel> |
findOuterWaysImpl(int level,
Collection<JoinAreasAction.AssembledPolygon> boundaryWays)
Collects outer way and corresponding inner ways from all boundaries.
|
private List<JoinAreasAction.AssembledMultipolygon> |
findPolygons(Collection<JoinAreasAction.AssembledPolygon> boundaries)
This method finds which ways are outer and which are inner.
|
private void |
fixRelations(List<JoinAreasAction.RelationRole> rels,
Way outer,
JoinAreasAction.RelationRole ownMultipol,
Set<Relation> relationsToDelete)
Adds the previously removed relations again to the outer way.
|
static List<JoinAreasAction.AssembledPolygon> |
fixTouchingPolygons(List<JoinAreasAction.AssembledPolygon> polygons)
This method checks if polygons have several touching parts and splits them in several polygons.
|
void |
join(Collection<Way> ways)
Joins the given ways.
|
private JoinAreasAction.JoinAreasResult |
joinAreas(List<JoinAreasAction.Multipolygon> areas)
Will join two or more overlapping areas
|
private Way |
joinOrientedWays(List<JoinAreasAction.WayInPolygon> ways)
Joins a list of ways (using CombineWayAction and ReverseWayAction as specified in WayInPath)
|
private JoinAreasAction.Multipolygon |
joinPolygon(JoinAreasAction.AssembledMultipolygon polygon)
Joins the lists of ways.
|
private Way |
joinWays(List<JoinAreasAction.WayInPolygon> ways)
Joins the outer ways and deletes all short ways that can't be part of a multipolygon anyway.
|
private void |
makeCommitsOneAction(String message)
Takes the last cmdsCount actions back and combines them into a single action
(for when the user wants to undo the join action)
|
private List<JoinAreasAction.WayInPolygon> |
markWayInsideSide(List<Way> parts,
boolean isInner)
This method analyzes the way and assigns each part what direction polygon "inside" is.
|
private boolean |
removeDuplicateNodes(List<Way> ways)
This method removes duplicate points (if any) from the input way.
|
private List<JoinAreasAction.RelationRole> |
removeFromAllRelations(OsmPrimitive osm)
Removes a given OsmPrimitive from all relations.
|
private boolean |
resolveTagConflicts(List<JoinAreasAction.Multipolygon> polygons)
Checks if tags of two given ways differ, and presents the user a dialog to solve conflicts
|
private List<Way> |
splitWayOnNodes(Way way,
Set<Node> nodes)
This is a method that splits way into smaller parts, using the prepared nodes list as split points.
|
private void |
stripTags(Collection<Way> ways)
Remove all tags from the all the way
|
private boolean |
testJoin(List<JoinAreasAction.Multipolygon> areas)
Tests if the areas have some intersections to join.
|
protected void |
updateEnabledState()
Override in subclasses to update the enabled state of the action when
something in the JOSM state changes, i.e.
|
protected void |
updateEnabledState(Collection<? extends OsmPrimitive> selection)
Override in subclasses to update the enabled state of the action if the
collection of selected primitives changes.
|
static boolean |
wayInsideWay(JoinAreasAction.AssembledPolygon inside,
JoinAreasAction.AssembledPolygon outside)
Tests if way is inside other way
|
destroy, getCurrentDataSet, getEditLayer, getShortcut, initEnabledState, installAdapters, setTooltip
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
private final LinkedList<Command> cmds
private int cmdsCount
private final transient List<Relation> addedRelations
public JoinAreasAction()
JoinAreasAction
.public void actionPerformed(ActionEvent e)
public void join(Collection<Way> ways)
ways
- Ways to joinprivate boolean testJoin(List<JoinAreasAction.Multipolygon> areas)
areas
- Areas to testtrue
if areas are joinableprivate JoinAreasAction.JoinAreasResult joinAreas(List<JoinAreasAction.Multipolygon> areas) throws UserCancelException
areas
- list of areas to joinUserCancelException
- if user cancels the operationprivate boolean resolveTagConflicts(List<JoinAreasAction.Multipolygon> polygons)
polygons
- ways to checktrue
if all conflicts are resolved, false
if conflicts remain.private boolean removeDuplicateNodes(List<Way> ways)
ways
- the ways to processtrue
if any changes where madeprivate void commitCommands(String description)
description
- The description of what the commands doprivate List<JoinAreasAction.WayInPolygon> markWayInsideSide(List<Way> parts, boolean isInner)
parts
- the split parts of the wayisInner
- - if true, reverts the direction (for multipolygon islands)IllegalArgumentException
- if parts is emptyprivate List<Way> splitWayOnNodes(Way way, Set<Node> nodes)
SplitWayAction.splitWay(org.openstreetmap.josm.gui.layer.OsmDataLayer, org.openstreetmap.josm.data.osm.Way, java.util.List<java.util.List<org.openstreetmap.josm.data.osm.Node>>, java.util.Collection<? extends org.openstreetmap.josm.data.osm.OsmPrimitive>)
for the heavy lifting.way
- way to splitnodes
- split pointsprivate static List<List<Node>> buildNodeChunks(Way way, Collection<Node> splitNodes)
way
- the way to chunksplitNodes
- the places where to cut.private List<JoinAreasAction.AssembledMultipolygon> findPolygons(Collection<JoinAreasAction.AssembledPolygon> boundaries)
boundaries
- list of joined boundaries to search inprivate List<JoinAreasAction.PolygonLevel> findOuterWaysImpl(int level, Collection<JoinAreasAction.AssembledPolygon> boundaryWays)
level
- depth levelboundaryWays
- list of joined boundaries to search inpublic static List<JoinAreasAction.AssembledPolygon> findBoundaryPolygons(Collection<JoinAreasAction.WayInPolygon> multigonWays, List<Way> discardedResult)
multigonWays
- A list of (splitted) ways that form a multigon and share common end nodes on intersections.discardedResult
- this list is filled with ways that are to be discardedpublic static List<JoinAreasAction.AssembledPolygon> fixTouchingPolygons(List<JoinAreasAction.AssembledPolygon> polygons)
polygons
- the polygons to process.public static boolean wayInsideWay(JoinAreasAction.AssembledPolygon inside, JoinAreasAction.AssembledPolygon outside)
outside
- outer polygon descriptioninside
- inner polygon descriptiontrue
if inner is inside outerprivate JoinAreasAction.Multipolygon joinPolygon(JoinAreasAction.AssembledMultipolygon polygon) throws UserCancelException
polygon
- The list of outer ways that belong to that multigon.UserCancelException
- if user cancels the operationprivate Way joinWays(List<JoinAreasAction.WayInPolygon> ways) throws UserCancelException
ways
- The list of outer ways that belong to that multigon.UserCancelException
- if user cancels the operationprivate Way joinOrientedWays(List<JoinAreasAction.WayInPolygon> ways) throws UserCancelException
ways
- The list of ways to join and reverseUserCancelException
- if user cancels the operationprivate List<JoinAreasAction.Multipolygon> collectMultipolygons(Collection<Way> selectedWays)
selectedWays
- the selected waysprivate JoinAreasAction.RelationRole addOwnMultipolygonRelation(Collection<Way> inner)
inner
- List of already closed inner waysprivate List<JoinAreasAction.RelationRole> removeFromAllRelations(OsmPrimitive osm)
osm
- Element to remove from all relationsprivate void fixRelations(List<JoinAreasAction.RelationRole> rels, Way outer, JoinAreasAction.RelationRole ownMultipol, Set<Relation> relationsToDelete)
rels
- List of relations with roles the (original) ways were part ofouter
- The newly created outer area/wayownMultipol
- elements to directly add as outerrelationsToDelete
- set of relations to delete.private void stripTags(Collection<Way> ways)
ways
- The List of Ways to remove all tags fromprivate void makeCommitsOneAction(String message)
message
- The commit message to displayprotected void updateEnabledState()
JosmAction
JosmAction.updateEnabledState(Collection)
to respond to changes in the collection
of selected primitives.
Default behavior is empty.updateEnabledState
in class JosmAction
JosmAction.updateEnabledState(Collection)
,
JosmAction.initEnabledState()
protected void updateEnabledState(Collection<? extends OsmPrimitive> selection)
JosmAction
updateEnabledState
in class JosmAction
selection
- the collection of selected primitives; may be empty, but not nullJosmAction.updateEnabledState()
,
JosmAction.initEnabledState()