Create a line with 90 degree right angle

I need to have a straight line( horizontal/vertical) in my Diagram
Create line that should be perfectly straight either right angle or 0 degree.
I am using flooplanner app.

Could you please be more specific about what it is that you want? It sounds as if you want the user to draw a shape that is like an “L” with two segments forming a 90-degree angle. Maybe you also want those two segments to be at multiples of 90 degrees?

It really would help if you could show a sequence of sketches or screenshots for how you want it to behave and what the result will be used for.

Yes walter i want user to draw a shape like “L” with two line segment.
angle should only be 0 or 90.
please see below image
all the line marked “X”(cross) should not be allowed.
Only the line marked as (correct) should be allowed.
When drawing a line it should start with either 90 degree or 0 degree.

OK, so you’ll need to create a new Tool class that is designed for this behavior.

I hope you have already seen Polygon Drawing Tool, which demonstrates a much more general version of what I think you want. Polyline Linking Tool is relevant too, although it’s geared towards drawing a new Link, which I assume you don’t care about.

The main difference between your tool and the PolygonDrawingTool are:

  • it will only draw polylines, not polygons
  • the tool automatically finishes upon the third mouse down event
  • the tool automatically constrains the second and third points to be orthogonal to the previous point.

The last requirement I believe can be accomplished by adapting the PolygonDrawingTool.moveLastPoint method to shift the argument Point so that it meets your requirements. But I haven’t tried it to be sure.

Read the code carefully so that you understand what each line is doing. Then you can more confidently make the changes that you need for your purposes.

Hi walter ,

Is there any other way of doing it.
What i need is whenever i am drawing one or more line they should either be 90 degree or at 0 degree.
on each line there is right click event, so if i try to implement using polygon then will i be able to achieve right click event on individual line? Because what i think it will consider entire polygon as single object and right click function will be applicable to entire object rather than individual wall.
I have come across while drawing a line when i press shift button it creates line with either 45 degree or 90 degree or 0 degree.
is it possible to implement when i am drawing a line internally we can achieve (shift button event) so that we are able to achieve 45 or 90 or 0degree.

Before we give you more support, you really need to respond to our attempts to contact you by email.

Hi walter ,

I have replied the team.
Will you be able to help me now?

Did you try adapting the PolygonDrawingTool as I suggested? What problems did you run into?

With PolygonDrawingTool i wil not be able to implement right on individual wall.
What i need is whenever i am drawing one or more line they should either be 90 degree or at 0 degree.
on each line there is right click event, so if i try to implement using polygon then will i be able to achieve right click event on individual line? Because what i think it will consider entire polygon as single object and right click function will be applicable to entire object rather than individual wall.
I have come across while drawing a line when i press shift button it creates line with either 45 degree or 90 degree or 0 degree.

I don’t understand what the problem is. The ability of the user to right-click (or more generally, context click) is completely independent of the operation of a shape-drawing tool.

So you have seen the code in the WallReshapingTool that when the user holds down the Shift key, the reshape method calculates the new point to make sure it’s at a multiple of 45 degrees relative to the previous point. Just change that code to do what you want.