aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes draw smooth dash-ed line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "draw smooth dash-ed line " Watch "draw smooth dash-ed line " New topic
Author

draw smooth dash-ed line

sarveshwar singh
Greenhorn

Joined: Feb 25, 2011
Posts: 13

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.


OCPJP 6
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

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?


luck, db
There are no new questions, but there may be new answers.
sarveshwar singh
Greenhorn

Joined: Feb 25, 2011
Posts: 13

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

Joined: May 03, 2008
Posts: 4664
    
    5

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

Joined: May 03, 2008
Posts: 4664
    
    5

Also, please BeForthrightWhenCrossPostingToOtherSites.
http://www.java-forums.org/java-2d/39707-draw-smooth-dash-ed-line.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: draw smooth dash-ed line