775 snippets from 1604 members, and growing!
|
login
|
join
about
bytebin
members
tags
snippets
join
Snippets
Submit a Snippet
Search Snippets
New Snippets
Top Snippets
Top Tags
PHP
(138)
JavaScript
(125)
Java
(66)
VBSCRIPT
(58)
String
(44)
CSS
(31)
CSharp
(28)
File
(28)
HTML
(27)
mysql
(25)
C
(24)
VB.NET
(24)
python
(24)
CPlusPlus
(23)
groovy
(23)
New Snippets
Shell keepalive t...
Clean PHP Templat...
PHP/MySQL impleme...
Analyte - Easy to...
Easy SQLite inter...
Very lightweight ...
AutoComplete plug...
AutoComplete plug...
Connection Java -...
View PostgreSql
Venture Capital Jobs
New Members
KennethCC
me
jamesmcm
Can
Kelmi
ysg
dannymo2
chorny
wallie
Hackdemian
Top Members
dannyboy
sundaramkumar
mattrmiller
Pio
i_kenneth
ASmith
ctiggerf
sehrgut
bertheymans
SCoon
Home
/
Snippets
/
Draw Dotted Line
/
Comments
Draw Dotted Line
Snippet Menu
Revisions
Comments
Related Snippets
Add to Favorites
Email Snippet
Download Snippet
Print Snippet
Blog Snippet
snippet
|
revisions
|
comments
|
related
|
Add to Favorites
|
email
download
|
print
|
blog it
New Comment
Graphics2D version
Tue. Feb. 14th, 2006 5:22 AM
TimYates
Really cool bit of code!
Just as an aside, with Graphics2D, you can use the Stroke API
private
void
drawDashedLine
(
Graphics2D
g,
int
x1,
int
y1,
int
x2,
int
y2,
float
dashlength,
float
spacelength,
float
width
)
{
float
[
]
dashValues =
new
float
[
]
{
dashLength, spaceLength
}
;
Stroke
stroke =
new
BasicStroke
(
width,
BasicStroke
.
CAP_BUTT
,
BasicStroke
.
JOIN_BEVEL
,
0
, dashvalues,
0
)
;
g.
setStroke
(
stroke
)
;
Line2D
line =
new
Line2D
.
Double
(
x1, y1, x2, y2
)
;
g.
draw
(
line
)
;
}
Reply
New Comment
Just as an aside, with Graphics2D, you can use the Stroke API
private void drawDashedLine( Graphics2D g, int x1, int y1, int x2, int y2, float dashlength, float spacelength, float width )
{
float[] dashValues = new float[] { dashLength, spaceLength } ;
Stroke stroke = new BasicStroke( width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, dashvalues, 0 ) ;
g.setStroke( stroke ) ;
Line2D line = new Line2D.Double( x1, y1, x2, y2 ) ;
g.draw( line ) ;
}