|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.AbstractAction
org.openstreetmap.josm.actions.JosmAction
org.openstreetmap.josm.actions.JoinAreasAction
public class JoinAreasAction
Join Areas (i.e. closed ways and multipolygons)
Nested Class Summary | |
---|---|
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
|
private static class |
JoinAreasAction.WayTraverser
This hepler class implements algorithm traversing trough connected ways. |
Field Summary | |
---|---|
private java.util.LinkedList<Command> |
cmds
|
private int |
cmdsCount
|
Fields inherited from class org.openstreetmap.josm.actions.JosmAction |
---|
sc |
Fields inherited from class javax.swing.AbstractAction |
---|
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
---|
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 Summary | |
---|---|
JoinAreasAction()
|
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.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(java.util.Collection<Way> inner,
Way outer)
Will add own multipolygon relation to the "previously existing" relations. |
private java.util.List<java.util.List<Node>> |
buildNodeChunks(Way way,
java.util.Collection<Node> splitNodes)
Simple chunking version. |
private java.util.List<JoinAreasAction.Multipolygon> |
collectMultipolygons(java.util.List<Way> selectedWays)
This method analyzes multipolygon relationships of given ways and collects addition inner ways to consider. |
private void |
commitCommands(java.lang.String description)
Commits the command list with a description |
private java.util.List<Relation> |
filterOwnMultipolygonRelations(java.util.Collection<Relation> relations,
java.util.List<JoinAreasAction.Multipolygon> polygons)
This method filters the list of relations that form the multipolygons. |
static java.util.List<JoinAreasAction.AssembledPolygon> |
findBoundaryPolygons(java.util.Collection<JoinAreasAction.WayInPolygon> multigonWays,
java.util.List<Way> discardedResult)
Finds all ways that form inner or outer boundaries. |
private java.util.List<JoinAreasAction.PolygonLevel> |
findOuterWaysImpl(int level,
java.util.Collection<JoinAreasAction.AssembledPolygon> boundaryWays)
Collects outer way and corresponding inner ways from all boundaries. |
private java.util.List<JoinAreasAction.AssembledMultipolygon> |
findPolygons(java.util.Collection<JoinAreasAction.AssembledPolygon> boundaries)
This method finds witch ways are outer and witch are inner. |
private void |
fixRelations(java.util.ArrayList<JoinAreasAction.RelationRole> rels,
Way outer,
JoinAreasAction.RelationRole ownMultipol,
java.util.Set<Relation> relationsToDelete)
Adds the previously removed relations again to the outer way. |
static java.util.List<JoinAreasAction.AssembledPolygon> |
fixTouchingPolygons(java.util.List<JoinAreasAction.AssembledPolygon> polygons)
This method checks if polygons have several touching parts and splits them in several polygons. |
private JoinAreasAction.JoinAreasResult |
joinAreas(java.util.List<JoinAreasAction.Multipolygon> areas)
Will join two or more overlapping areas |
private Way |
joinOrientedWays(java.util.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(java.util.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(java.lang.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 java.util.ArrayList<JoinAreasAction.WayInPolygon> |
markWayInsideSide(java.util.List<Way> parts,
boolean isInner)
This method analyzes the way and assigns each part what direction polygon "inside" is. |
private boolean |
removeDuplicateNodes(java.util.List<Way> ways)
This method removes duplicate points (if any) from the input way. |
private java.util.ArrayList<JoinAreasAction.RelationRole> |
removeFromAllRelations(OsmPrimitive osm)
Removes a given OsmPrimitive from all relations |
private boolean |
resolveTagConflicts(java.util.List<JoinAreasAction.Multipolygon> polygons)
Checks if tags of two given ways differ, and presents the user a dialog to solve conflicts |
private java.util.ArrayList<Way> |
splitWayOnNodes(Way way,
java.util.Set<Node> nodes)
This is a method splits way into smaller parts, using the prepared nodes list as split points. |
private void |
stripTags(java.util.Collection<Way> ways)
|
private void |
stripTags(Way x)
|
private boolean |
testJoin(java.util.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(java.util.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 |
Methods inherited from class org.openstreetmap.josm.actions.JosmAction |
---|
destroy, getCurrentDataSet, getEditLayer, getShortcut, initEnabledState, installAdapters, setTooltip |
Methods inherited from class javax.swing.AbstractAction |
---|
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.LinkedList<Command> cmds
private int cmdsCount
Constructor Detail |
---|
public JoinAreasAction()
Method Detail |
---|
public void actionPerformed(java.awt.event.ActionEvent e)
private boolean testJoin(java.util.List<JoinAreasAction.Multipolygon> areas)
areas
-
private JoinAreasAction.JoinAreasResult joinAreas(java.util.List<JoinAreasAction.Multipolygon> areas) throws UserCancelException
areas
- - list of areas to join
UserCancelException
private boolean resolveTagConflicts(java.util.List<JoinAreasAction.Multipolygon> polygons)
Way
- First way to checkWay
- Second Way to check
private boolean removeDuplicateNodes(java.util.List<Way> ways)
way
- the way to process
private void commitCommands(java.lang.String description)
String
- The description of what the commands doprivate java.util.ArrayList<JoinAreasAction.WayInPolygon> markWayInsideSide(java.util.List<Way> parts, boolean isInner)
parts
- the split parts of the wayisInner
- - if true, reverts the direction (for multipolygon islands)
private java.util.ArrayList<Way> splitWayOnNodes(Way way, java.util.Set<Node> nodes)
private java.util.List<java.util.List<Node>> buildNodeChunks(Way way, java.util.Collection<Node> splitNodes)
way
- the way to chunksplitNodes
- the places where to cut.
private java.util.List<JoinAreasAction.AssembledMultipolygon> findPolygons(java.util.Collection<JoinAreasAction.AssembledPolygon> boundaries)
boundaryWays
-
private java.util.List<JoinAreasAction.PolygonLevel> findOuterWaysImpl(int level, java.util.Collection<JoinAreasAction.AssembledPolygon> boundaryWays)
boundaryWays
-
public static java.util.List<JoinAreasAction.AssembledPolygon> findBoundaryPolygons(java.util.Collection<JoinAreasAction.WayInPolygon> multigonWays, java.util.List<Way> discardedResult)
Collection
- A list of (splitted) ways that form a multigon and share common end nodes on intersections.Collection
- this list is filled with ways that are to be discarded
public static java.util.List<JoinAreasAction.AssembledPolygon> fixTouchingPolygons(java.util.List<JoinAreasAction.AssembledPolygon> polygons)
polygon
- the polygon to process.public static boolean wayInsideWay(JoinAreasAction.AssembledPolygon inside, JoinAreasAction.AssembledPolygon outside)
outside
- inside
-
private JoinAreasAction.Multipolygon joinPolygon(JoinAreasAction.AssembledMultipolygon polygon) throws UserCancelException
Collection
- The list of outer ways that belong to that multigon.
UserCancelException
private Way joinWays(java.util.List<JoinAreasAction.WayInPolygon> ways) throws UserCancelException
Collection
- The list of outer ways that belong to that multigon.
UserCancelException
private Way joinOrientedWays(java.util.List<JoinAreasAction.WayInPolygon> ways) throws UserCancelException
ArrayList
- The list of ways to join and reverse
UserCancelException
private java.util.List<JoinAreasAction.Multipolygon> collectMultipolygons(java.util.List<Way> selectedWays)
selectedWays
- the selected ways
private java.util.List<Relation> filterOwnMultipolygonRelations(java.util.Collection<Relation> relations, java.util.List<JoinAreasAction.Multipolygon> polygons)
relations
- polygons
-
private JoinAreasAction.RelationRole addOwnMultigonRelation(java.util.Collection<Way> inner, Way outer)
Collection
- List of already closed inner waysWay
- The outer wayArrayList
- The list of relation with roles to add own relation toprivate java.util.ArrayList<JoinAreasAction.RelationRole> removeFromAllRelations(OsmPrimitive osm)
OsmPrimitive
- Element to remove from all relations
private void fixRelations(java.util.ArrayList<JoinAreasAction.RelationRole> rels, Way outer, JoinAreasAction.RelationRole ownMultipol, java.util.Set<Relation> relationsToDelete)
ArrayList
- List of relations with roles the (original) ways were part ofWay
- The newly created outer area/wayrelationsToDelete
- - set of relations to delete.private void stripTags(java.util.Collection<Way> ways)
Collection
- The List of Ways to remove all tags fromprivate void stripTags(Way x)
Way
- The Way to remove all tags fromprivate void makeCommitsOneAction(java.lang.String message)
String
- 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(java.util.Collection<? extends OsmPrimitive> selection)
JosmAction
updateEnabledState
in class JosmAction
selection
- the collection of selected primitives; may be empty, but not nullJosmAction.updateEnabledState()
,
JosmAction.initEnabledState()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |