swing - Java Subtract lines -


Then I have a simple rectangle, which is drawn with lines drawn on the screen that runs under the sides is. So something looks like:
Enter image details here

this line is In fact, the entire line is going down completely from the top of the screen, it is only slightly cut off. But what I want to do, this 1 row is divided into two rows where it sometimes pierces the rectangle. So it will look like this:
Enter image details here

What I was thinking A line of rectangular was moving down on the left side (top-left top to bottom-left) and then to reduce that line to achieve two resulting lines.

But Java does not have a line deduction function, so I'm a bit lost ... plus I think there is a better way. Any ideas?

I will use Java-2D for this.

Enter image details here

  import Java.awt *; Import java.awt.geom. *; Import java.awt.image.BufferedImage; Import javax.swing. *; Square rectangular framelline {public static buffard image mill image () {buffard image bi = new buffard image (600,200, buffard image .ipep_inderg); Graphics 2DGG = B.Archief Graphics (); Rectangle 2D Rect = New Rectangle 2D Double (50,50,100,100); // We never draw it, it is used as a field, which is used as a bit more than the actual rectangle so that it can be reduced from the lines to give space. Int Pad = 8; Rectangle 2D Rectbufer = new rectangle 2d Double (50-pad, 50-pad, 100+ (2 * pad), 100 + (2 * pad)); // We can not create a field from a line 2d, yet // we can create one field from one (very thin) rectangle 2d rectangle 2 = new rectangle 2d. Double (0, 50,600, .02D); Rectangle 2d line 2 = new rectangle 2d. Double (0,14.98,800, .02D); Field line = new zone (line1); Lines.add (new area (line2)); Lines. Subtract (new area (rectbuffer)); G.setColor (Color.RED); G.setStroke (new Basic Stotok (3, Basic Stroke. CAP_ROUND, Basicstroke.join_rund)); G.draw (rect); G.setColor (Color.MAGENTA.darker () dark color ().); G. Ststroke (New Basic Stochok (6, Basicstroke. CAP_RODD, Basicstroke.JOIN_Rund); G.draw (lines); g.dispose (); Let's return; } Public Static Zero Main (String [] Args) {Runnabal R = New Runnabal () {@ Override Public Wide Run) (JLABL GUI = New JLab (new image) (rectangular edited frummins.gate image)); JoyptionPan .shomasejialogyog (null, gui);}}; // swing GUI should be made on ADT // http://docs.oracle.com/javase/tutorial/uiswing/concurrency and SwingUtilities.invokeLater (r);}}    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -