• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

draw smooth dash-ed line

 
Greenhorn
Posts: 13
Netbeans IDE MySQL Database Java
  • 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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • 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
Netbeans IDE MySQL Database Java
  • 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: 5167
11
Netbeans IDE Opera Java
  • 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: 5167
11
Netbeans IDE Opera Java
  • 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
 
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!