Class ExtrudeAction

    • Constructor Detail

      • ExtrudeAction

        public ExtrudeAction()
        Creates a new ExtrudeAction
        Since:
        11713
    • Method Detail

      • getModeHelpText

        public java.lang.String getModeHelpText()
        Description copied from class: MapMode
        Returns a short translated help message describing how this map mode can be used, to be displayed in status line.
        Overrides:
        getModeHelpText in class MapMode
        Returns:
        a short translated help message describing how this map mode can be used
      • layerIsSupported

        public boolean layerIsSupported​(Layer l)
        Description copied from class: MapMode
        Determines if layer l is supported by this map mode. By default, all tools will work with all layers. Can be overwritten to require a special type of layer
        Overrides:
        layerIsSupported in class MapMode
        Parameters:
        l - layer
        Returns:
        true if the layer is supported by this map mode
      • modifiersExChanged

        public void modifiersExChanged​(int modifiers)
        This method is called to indicate different modes via cursor when the Alt/Ctrl/Shift modifier is pressed,
        Specified by:
        modifiersExChanged in interface ModifierExListener
        Parameters:
        modifiers - The new extended modifiers
      • toggleDualAlign

        private void toggleDualAlign()
        Toggles dual alignment mode.
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent e)
        If the left mouse button is pressed over a segment or a node, switches to appropriate mode, depending on Ctrl/Alt/Shift modifiers and dualAlignEnabled.
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
        Overrides:
        mousePressed in class MapMode
        Parameters:
        e - current mouse event
      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent e)
        Performs action depending on what mode we're in.
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
        Overrides:
        mouseDragged in class MapMode
        Parameters:
        e - current mouse event
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent e)
        Does anything that needs to be done, then switches back to select mode.
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
        Overrides:
        mouseReleased in class MapMode
        Parameters:
        e - current mouse event
      • addNewNode

        private static void addNewNode​(java.awt.event.MouseEvent e)
        Inserts node into nearby segment.
        Parameters:
        e - current mouse point
      • createNewRectangle

        private void createNewRectangle()
        Creates a new way that shares segment with selected way.
      • hasNodeOtherWays

        private static boolean hasNodeOtherWays​(Node node,
                                                Way myWay)
        This method tests if node has other ways apart from the given one.
        Parameters:
        node - node to test
        myWay - way known to contain this node
        Returns:
        true if node belongs only to myWay, false if there are more ways.
      • calculateSegmentOffset

        private static EastNorth calculateSegmentOffset​(EastNorth segmentP1,
                                                        EastNorth segmentP2,
                                                        EastNorth moveDirection,
                                                        EastNorth targetPos)
        This method calculates offset amount by which to move the given segment perpendicularly for it to be in line with mouse position.
        Parameters:
        segmentP1 - segment's first point
        segmentP2 - segment's second point
        moveDirection - direction of movement
        targetPos - mouse position
        Returns:
        offset amount of P1 and P2.
      • calculatePossibleDirectionsBySegment

        private void calculatePossibleDirectionsBySegment()
        Gathers possible move directions - perpendicular to the selected segment and parallel to neighboring segments.
      • checkDualAlignConditions

        private boolean checkDualAlignConditions()
        Checks dual alignment conditions: 1. selected segment has both neighboring segments, 2. selected segment is not parallel with neighboring segments.
        Returns:
        true if dual alignment conditions are satisfied
      • calculateBestMovementAndNewNodes

        private EastNorth calculateBestMovementAndNewNodes​(EastNorth mouseEn)
        Calculate newN1en, newN2en best suitable for given mouse coordinates For dual align, calculates positions of new nodes, aligning them to neighboring segments. Elsewhere, just adds the vetor returned by calculateBestMovement to initialN1en, initialN2en.
        Parameters:
        mouseEn - mouse coordinates
        Returns:
        best movement vector
      • getPreviousNodeIndex

        private int getPreviousNodeIndex​(int index)
        Gets a node index from selected way before given index.
        Parameters:
        index - index of current node
        Returns:
        index of previous node or -1 if there are no nodes there.
      • getPreviousNode

        private Node getPreviousNode​(int index)
        Gets a node from selected way before given index.
        Parameters:
        index - index of current node
        Returns:
        previous node or null if there are no nodes there.
      • getNextNodeIndex

        private int getNextNodeIndex​(int index)
        Gets a node index from selected way after given index.
        Parameters:
        index - index of current node
        Returns:
        index of next node or -1 if there are no nodes there.
      • getNextNode

        private Node getNextNode​(int index)
        Gets a node from selected way after given index.
        Parameters:
        index - index of current node
        Returns:
        next node or null if there are no nodes there.
      • paint

        public void paint​(java.awt.Graphics2D g,
                          MapView mv,
                          Bounds box)
        Description copied from interface: MapViewPaintable
        Paint the dataset using the engine set.
        Specified by:
        paint in interface MapViewPaintable
        Parameters:
        g - Graphics
        mv - The object that can translate GeoPoints to screen coordinates.
        box - Bounding box
      • isOppositeDirection

        private static boolean isOppositeDirection​(EastNorth from1,
                                                   EastNorth to1,
                                                   EastNorth from2,
                                                   EastNorth to2)
        Determines if from1-to1 and from2-to2 vectors directions are opposite
        Parameters:
        from1 - vector1 start
        to1 - vector1 end
        from2 - vector2 start
        to2 - vector2 end
        Returns:
        true if from1-to1 and from2-to2 vectors directions are opposite
      • drawAngleSymbol

        private void drawAngleSymbol​(java.awt.Graphics2D g2,
                                     java.awt.geom.Point2D center,
                                     java.awt.geom.Point2D normal,
                                     boolean mirror)
        Draws right angle symbol at specified position.
        Parameters:
        g2 - the Graphics2D object used to draw on
        center - center point of angle
        normal - vector of normal
        mirror - true if symbol should be mirrored by the normal
      • createSemiInfiniteLine

        private static java.awt.geom.Line2D createSemiInfiniteLine​(java.awt.geom.Point2D start,
                                                                   java.awt.geom.Point2D unitvector,
                                                                   java.awt.Graphics2D g)
        Creates a new Line that extends off the edge of the viewport in one direction
        Parameters:
        start - The start point of the line
        unitvector - A unit vector denoting the direction of the line
        g - the Graphics2D object it will be used on
        Returns:
        created line