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 ares 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.
|
| Modifier and Type | Field and Description |
|---|---|
private LinkedList<Command> |
cmds |
private int |
cmdsCount |
scchangeSupport, enabledACCELERATOR_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() |
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(ActionEvent e)
Gets called whenever the shortcut is pressed or the menu entry is selected
Checks whether the selected objects are suitable to join and joins them if so
|
private JoinAreasAction.RelationRole |
addOwnMultigonRelation(Collection<Way> inner,
Way outer)
Will add own multipolygon relation to the "previously existing" relations.
|
private List<List<Node>> |
buildNodeChunks(Way way,
Collection<Node> splitNodes)
Simple chunking version.
|
private List<JoinAreasAction.Multipolygon> |
collectMultipolygons(List<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.
|
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 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 void |
stripTags(Way x)
Remove all tags from 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. when a layer is removed or added.
|
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, setTooltipaddPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabledprivate LinkedList<Command> cmds
private int cmdsCount
public JoinAreasAction()
public void actionPerformed(ActionEvent e)
private boolean testJoin(List<JoinAreasAction.Multipolygon> areas)
areas - Areas to testprivate JoinAreasAction.JoinAreasResult joinAreas(List<JoinAreasAction.Multipolygon> areas) throws UserCancelException
areas - list of areas to joinUserCancelExceptionprivate 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)private List<Way> splitWayOnNodes(Way way, Set<Node> nodes)
private 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 - public 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.UserCancelExceptionprivate Way joinWays(List<JoinAreasAction.WayInPolygon> ways) throws UserCancelException
ways - The list of outer ways that belong to that multigon.UserCancelExceptionprivate Way joinOrientedWays(List<JoinAreasAction.WayInPolygon> ways) throws UserCancelException
ways - The list of ways to join and reverseUserCancelExceptionprivate List<JoinAreasAction.Multipolygon> collectMultipolygons(List<Way> selectedWays)
selectedWays - the selected waysprivate JoinAreasAction.RelationRole addOwnMultigonRelation(Collection<Way> inner, Way outer)
inner - List of already closed inner waysouter - The outer wayprivate 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 stripTags(Way x)
x - The Way to remove all tags fromprivate void makeCommitsOneAction(String message)
message - The commit message to displayprotected void updateEnabledState()
JosmActionJosmAction.updateEnabledState(Collection) to respond to changes in the collection
of selected primitives.
Default behavior is empty.updateEnabledState in class JosmActionJosmAction.updateEnabledState(Collection),
JosmAction.initEnabledState()protected void updateEnabledState(Collection<? extends OsmPrimitive> selection)
JosmActionupdateEnabledState in class JosmActionselection - the collection of selected primitives; may be empty, but not nullJosmAction.updateEnabledState(),
JosmAction.initEnabledState()