Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

draw smooth dash-ed line

 
sarveshwar singh
Greenhorn
Posts: 13
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi !!

i am working on a project that displays graph, a graph can be drawn as simple plain line , dash-ed line , dotted line or dash -dotted line. i don't have any problem with drawing all these of lines , but the problem is lines are not so smooth and if i zoom my graph they become very rough.

please suggest some dash-type for BasicStroke object such that line would be smoother(if possible please explain mechanism for drawing smooth line)



Thanks,
Sarveshwar Singh.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problem is lines are not so smooth and if i zoom my graph they become very rough.

Have you tried casting the Graphics to Graphics2D and applying a suitable RenderingHints.KEY_ANTIALIASING?
 
sarveshwar singh
Greenhorn
Posts: 13
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problem is solved when i enable ANTIALIASING(i have already cast Graphics it to Graphics2D)...but another problem arise....rendering became very slow for dashed-lines (no problem with plain line)..

Thanks for the help.!!
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rendering became very slow

May help.
http://download.oracle.com/javase/1.5.0/docs/guide/2d/flags.html
http://java.sun.com/products/java-media/2D/perf_graphics.html
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, please BeForthrightWhenCrossPostingToOtherSites.
http://www.java-forums.org/java-2d/39707-draw-smooth-dash-ed-line.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic